Skip to content
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

Example Not Functional #207

Open
flywire opened this issue May 21, 2023 · 2 comments
Open

Example Not Functional #207

flywire opened this issue May 21, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@flywire
Copy link
Contributor

flywire commented May 21, 2023

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

  1. Default install
  2. Select Copy button
  3. 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

@flywire flywire added the bug Something isn't working label May 21, 2023
@flywire
Copy link
Contributor Author

flywire commented May 22, 2023

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)

@flywire
Copy link
Contributor Author

flywire commented May 23, 2023

Also fails with ...:

>>> for i in (1,2):
...   print(i)
...
>>> # Loop finished
>>>
>>> # Blank line above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant