Skip to content

sphinx-copybutton: Is there a way to exclude whole lines from copy? #1057

Closed Answered by kathatherine
kathatherine asked this question in Q&A
Discussion options

You must be logged in to vote

Just being a good citizen and answering my own question. Got some regex help and the following did the job for us:

copybutton_prompt_text = r"(?!#)"
copybutton_prompt_is_regexp = True

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!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kathatherine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant