sphinx-copybutton: Is there a way to exclude whole lines from copy? #1057
-
Here's my dilemma. My team is hoping to utilize sphinx-copybutton in our documentation, but we include comments in many of our code blocks. Sometimes a LOT of comments, in order to explain many different parts of a given command. Take this as an example:
And here's the doc page where this example shows up: https://server-docs.anaconda.com/en/latest/admin/upgrade.html We're thinking about presenting the information in a different way, outside of the codeblocks, but wanted to check. Is there a way, in the current implementation, to exclude entire lines beginning with We considered including a character manually at the beginnings of all lines we want copied out and then utilizing If anyone knows of an easy solution to excluding based on a starting character, I'd love to hear it. Otherwise, we may need to rethink our codeblock usage so we can utilize the copybutton. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Just being a good citizen and answering my own question. Got some regex help and the following did the job for us:
It ensures code block lines beginning with |
Beta Was this translation helpful? Give feedback.
Just being a good citizen and answering my own question. Got some regex help and the following did the job for us:
It ensures code block lines beginning with
#
are not copied, while preserving spaces if we have yaml example text or things of that nature. Works great!