mystmd icon indicating copy to clipboard operation
mystmd copied to clipboard

When copying code manually from `{code}` directive with `linenos` enabled, blank lines are copied between each code line

Open mfisher87 opened this issue 1 month ago • 13 comments
trafficstars

When I have a code block like so:

```{code} python
:linenos:

print("Hello, world!")
print("Good night, moon!")
print("I'm a monster! Don't look at me!")
```

If I only want to copy the first two lines by selecting them and CTRL+C or right-click copy (i.e. not using the copy button at the top right of the code block), a blank line is inserted between each line I copied.

print("Hello, world!")

print("Good night, moon!")

With :linenos: turned off, the copy works as expected.

print("Hello, world!")
print("Good night, moon!")

Image

mfisher87 avatar Oct 22 '25 16:10 mfisher87