Skip to content

newline ignored when using emphasize-lines #204

Description

@jmd-dk

Describe the bug

Whenever I use :emphasize-lines: within a .. code-block::, the newline in between the line(s) that is emphasized and the next disappears after copy-paste via sphinx-copybutton 0.5.1. There is no such problem with 0.5.0.

Reproduce the bug

The below simple example shows the bug:

.. code-block::
   :emphasize-lines: 1

   a = 1
   b = 2

The Sphinx generated HTML renders as

a = 1
b = 2

Copying using the copy button and then pasting should preserve this, which is indeed the usual behaviour (e.g. sphinx-copybutton 0.5.0). With sphinx-copybutton 0.5.1 however, pasting results in

a = 1b = 2

List your environment

  • sphinx-copybutton 0.5.1
  • sphinx 6.1.3
  • sphinx-rtd-theme 1.2.0
  • Python 3.11.2
  • HTML page viewed with Google Chrome 108.0.5359.98
  • Linux Mint 20

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions