Skip to content

Line numbers being included with code listings starting with Sphinx 4.0.0 #1168

@pvcraven

Description

@pvcraven

Problem

Starting with Sphinx 4.0.0 copying a block of code with :linenos: includes the line numbers along with the code when copied.

To Reproduce
Use Sphinx 4.0.0 or later. Create an RST that references an external file, something like:

.. literalinclude:: array_backed_grid.py
    :caption: array_backed_grid.py
    :linenos:

Expected behavior
The ability to copy code without line numbers. This worked fine with Sphinx 3.5.7 and before.Example:

s2

Starting with 4.0.0 we get:

s1

Sphinx copy button extension includes line numbers as well.

According to @mgeier the theme might need to be updated to support the new Sphinx 4.0.0 setup? See comments here:
sphinx-doc/sphinx#9363

Environment info

  • OS: Windows 10
  • Python version: 3.9.5
  • Sphinx version: 4.0.0 to 4.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions