sphinx-copybutton icon indicating copy to clipboard operation
sphinx-copybutton copied to clipboard

newline ignored when using emphasize-lines

Open jmd-dk opened this issue 2 years ago • 1 comments

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

jmd-dk avatar Mar 21 '23 11:03 jmd-dk

This is still a problem with sphinx-copybutton 0.5.2.

jmd-dk avatar May 31 '23 09:05 jmd-dk