-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using the copybutton in code blocks, exclude copying the prompt #2036
Conversation
@@ -113,6 +113,7 @@ | |||
# Exclude copy button from appearing over notebook cell numbers by using :not() | |||
# The default copybutton selector is `div.highlight pre` | |||
# https://github.com/executablebooks/sphinx-copybutton/blob/master/sphinx_copybutton/__init__.py#L82 | |||
copybutton_exclude = ".linenos, .gp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also noticed on that page:
To skip all console outputs, add .go to the string above.
@stevepiercy did you intentionally not include that? Seems also useful (prompt outputs are usually not runnable code and would interfere with copy-paste-run)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@drammock I didn't include it because console output is not something that I would copy and paste into a terminal session. For example, in MyST source:
```console
A
billion
lines
of
...
stacktrace
```
However it might be useful in some other context of which I am not aware. Perhaps notebooks or some other utility? I selected only the options with which I am familiar. I can ammend my PR to what you think is best.
See: - https://sphinx-copybutton.readthedocs.io/en/latest/use.html#automatic-exclusion-of-prompts-from-the-copies - pydata/pydata-sphinx-theme#2036 Alternatively, don't use prompts in shell commands.
Since this has been approved for a while I will go ahead and merge and if needed we can iterate on this. Thanks for your contribution @stevepiercy ✨🙏🏽 |
See: - https://sphinx-copybutton.readthedocs.io/en/latest/use.html#automatic-exclusion-of-prompts-from-the-copies - pydata/pydata-sphinx-theme#2036 Alternatively, don't use prompts in shell commands.
When I use the copybutton in code blocks, I expect to be able to paste the code into my terminal without having to delete the prompt that gets copied. This PR fixes that issue by excluding CSS classes that Pygments generates in code blocks.
See https://sphinx-copybutton.readthedocs.io/en/latest/use.html#automatic-exclusion-of-prompts-from-the-copies