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

Copy blanklines on matches(?) #84

Closed
chrisjsewell opened this issue Jun 17, 2020 · 9 comments · Fixed by #127
Closed

Copy blanklines on matches(?) #84

chrisjsewell opened this issue Jun 17, 2020 · 9 comments · Fixed by #127

Comments

@chrisjsewell
Copy link
Member

Following #83 blanklines are not captured, e.g.

In [1]: import something
   ...:
   ...: print(something.__version__)

If the regex is set, will copy:

import something
print(something.__version__)
@chrisjsewell chrisjsewell changed the title Copy blanklines on matches Copy blanklines on matches(?) Jun 17, 2020
@choldgraf
Copy link
Member

My intuition is that yes, we should copy them because the user is going to expect the output to look almost just like the copied code (minus prompts)

@chrisjsewell
Copy link
Member Author

Also I can't figure this out, but in this repository I used:

copybutton_prompt_text = ">>> |\\\\$ |\\[\\d*\\]: |\\.\\.\\.: "

which appears to work fine.
but in aiida I've had to use:

copybutton_prompt_text = '>>> |\\\\$ |In \\\\[\\\\d\\\\]: |\\\\s+\\.\\.\\.: '

with the tonnes of backslashes, but this is what works

@chrisjsewell
Copy link
Member Author

@choldgraf
Copy link
Member

god I hate regexes 😆

@amotl
Copy link
Contributor

amotl commented May 27, 2021

Dear Chris,

first things first: Thanks for your excellent work on this Sphinx addon, it really saves us.

We want to report back about what @chrisjsewell originally reported here. Apparently, we are getting tripped by this as well. For example, the code block at [1] will not get copied "as-is", all empty lines are missing. The config entries within conf.py we are currently using can be reviewed at [2].

Are we missing any respective configuration option here? Otherwise, do you see an easy way to make sphinx-copybutton pass through empty lines?

With kind regards,
Andreas.

[1] https://crate.io/docs/python/en/latest/sqlalchemy.html#tables
[2] https://github.com/crate/crate-docs-theme/blob/0.15.1/src/crate/theme/rtd/conf/__init__.py#L112-L115

@choldgraf
Copy link
Member

choldgraf commented May 27, 2021

I'm not quite sure where the fix needs to be for this unfortunately, and haven't had time to dig into the code to figure it out. If you or anybody else wants to take a look I am happy to review PRs! (maybe @sappelhoff has run into this issue too?)

@amotl
Copy link
Contributor

amotl commented May 27, 2021

Thank you for the quick response. I tried to find the spot and handed in a corresponding patch with #127, and, optionally #128.

@sappelhoff
Copy link
Contributor

(maybe @sappelhoff has run into this issue too?)

I haven't (yet), but I am glad that @amotl prepared a patch (and I would vote for making copying empty lines the default)

@amotl
Copy link
Contributor

amotl commented May 31, 2021

Thank you Stefan, appreciate it. Both bringing in the feature as well as making copying empty lines the default behavior have now been folded into #127.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants