The "copybutton_skip_text" feature is incomplete
I'm not planning to ever use this feature, but I still feel this should be mentioned:
The option copybutton_skip_text seems to expect a single line of text (by default '>>> '). However the Python prompt can also have another form, namely '... '.
For example, https://github.com/sbrunner/sphinx-prompt (example: http://sbrunner.github.io/sphinx-prompt/) seems to allow multiple prompts.
Also, if the prompt is ignored, shouldn't the outputs be ignored as well?
As another example, the Python docs have their own copy button (see for example here: https://docs.python.org/3/tutorial/controlflow.html), which does hide both types of prompts as well as the outputs. Here's the code for that: https://github.com/python/python-docs-theme/blob/master/python_docs_theme/static/copybutton.js
As it is implemented currently, this feature could also backfire, for example if the code contains an e-mail conversation:
>>> BTW, my favorite ... is ...
>>> and I don't like ...
>>
>> What? I totally disagree!
>
> Anyway ...
I'm not sure how realistic such a case is, but I think I would be more at ease if such a case could be avoided. The Python thing mentioned above seems to use Pygments annotations, which should also avoid such mistakes (I think).
Thanks for the feedback - some quick thoughts:
The option copybutton_skip_text seems to expect a single line of text (by default '>>> '). However the Python prompt can also have another form, namely '... '.
That's a good point, I believe that it was also suggested in https://github.com/choldgraf/sphinx-copybutton/issues/52#issuecomment-574272086
Also, if the prompt is ignored, shouldn't the outputs be ignored as well?
agree to make this configurable (also in https://github.com/choldgraf/sphinx-copybutton/issues/52#issuecomment-574272086 I believe) https://github.com/choldgraf/sphinx-copybutton/issues/52
For your final example - to clarify, you are asking about the situation where a user wants both to skip python prompts in the copying, but also to include other lines that do have the same text (e.g. >>> ) but that should be copied because they're not actually Python prompts. Is that right?
For your final example - to clarify, you are asking about the situation where a user wants both to skip python prompts in the copying, but also to include other lines that do have the same text (e.g.
>>>) but that should be copied because they're not actually Python prompts. Is that right?
No, I'm talking about the case where a user is blissfully unaware of the "skipping" feature and uses something like an e-mail conversation in a code block and is surprised why suddenly some of the > markers are missing in the copied text.
If I understood correctly, the current implementation doesn't take the language of the code block into concern, right? I think it's not good to willy-nilly remove arbitrary strings of characters from arbitrary text.
I think something like the thing from the Python docs makes mores sense, since it seems to take the syntax highlighting into account.
IOW, I think it would probably make more sense to have the "skipping" feature only in syntax-highlighted code.
Hmmm - it's a fair point that we want to avoid unexpected behavior. I think that long-term, it might be best to implement some kind of behavior that depends on code cell type. In the short term, I'll set the default behavior to "don't auto-remove any prompts" so that users have to explicitly set it if they want the behavior. I feel like this is more in-line with "explicit is better than implicit". If people bring up that they're having issues because they need some cells to keep the prompt text, while others they want to strip it, then we can put more cycles into a more sophisticated setup
I like the idea of making it opt-in for now!