sphinx-copybutton
sphinx-copybutton copied to clipboard
Example Not Functional
Describe the bug
context You can configure. The can should be demonstrated.
expectation Install should produce 3rd example. Requires a Minimal Working Example.
bug Default install strips nothing
problem Example is non-functional
Reproduce the bug
- Default install
- Select Copy button
- Paste does not strip prompts and output
List your environment
Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] on win32 Running Sphinx v6.2.1
Example at https://sphinx-copybutton.readthedocs.io/:
>>> a = 2
>>> print(a)
2
>>>
>>> b = 'wow'
>>> print(b)
wow
copy/paste gives:
a = 2
print(a)
b = 'wow'
print(b)
Blank lines are an important part of code and should not be stripped or require Using regexp prompt identifiers.
These two parts as documented don't work together:
https://sphinx-copybutton.readthedocs.io/en/latest/use.html#automatic-exclusion-of-prompts-from-the-copies
... To make sphinx-copybutton skip all prompt characters generated by pygments, use the following setting:
copybutton_exclude = '.linenos, .gp'To skip all console outputs, add .go to the string above.
https://sphinx-copybutton.readthedocs.io/en/latest/use.html#keep-empty-lines
By default, sphinx-copybutton will also copy / pass through empty lines, determined by line.trim() === ''.
blank lines are retained with conf.py using >>> ?:
# copybutton_exclude = '.linenos, .gp, .go'
copybutton_prompt_text = r">>> ?|\.\.\. ?|\$ |In \[\d*\]: | {2,5}\.\.\.: | {5,8}: "
copybutton_prompt_is_regexp = True
gives:
a = 2
print(a)
b = 'wow'
print(b)
Also fails with ...:
>>> for i in (1,2):
... print(i)
...
>>> # Loop finished
>>>
>>> # Blank line above