Skip to content

html output: Line numbers misalign with code lines (since sphinx 3.1.0, theme independent) #8254

@jonascj

Description

@jonascj

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
scrot_2020-09-29_133401_746x561

scrot_2020-09-29_132448_753x597

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions