Describe the bug
In Sphinx 3.1.0 and later versions the line numbers of code blocks misalign with the code lines they number, as shown in the screenshots below. Version 3.0.4 aligns them properly like older versions 2.x and 1.x. Tested for both the alabaster and classic theme.
To Reproduce
Steps to reproduce the behavior:
pip install sphinx==3.1.0
sphinx-quickstart
cat >> index.rst << EOL
.. code-block:: python
:linenos:
import math
for x in range(0,10):
print(math.sqrt(x))
EOL
make html
firefox _build/html/index.html
Expected behavior
The line numbers and code lines should align as in the second screenshot (from sphinx v. 3.0.4).
Your project
A MWE is attached (make html with sphinx v. 3.1.0 to see the problem)
lineno-misalign-bug.zip
Screenshots


Environment info
- OS: Linux
- Python version: 3.7.4
- Sphinx version: 3.0.4, 3.1.0, 3.2.1
- Extra tools: a browser to view html output