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

Eliminate prompt characters in examples from copyable text #267

Closed
shimizukawa opened this issue Jan 2, 2015 · 12 comments
Closed

Eliminate prompt characters in examples from copyable text #267

shimizukawa opened this issue Jan 2, 2015 · 12 comments
Labels
builder:html type:enhancement enhance or introduce a new feature
Milestone

Comments

@shimizukawa
Copy link
Member

It would be nice if the prompt characters in examples were easily copyable and pasteable somehow. For example, if this showed up on the document:

>>> for i in xrange(32)
...     print i

And you selected it, only these bits were selected.

for i in xrange(32)
    print i

This would make it easier to actually paste the examples into an interpreter.


@shimizukawa shimizukawa added this to the some future version milestone Jan 2, 2015
@shimizukawa shimizukawa added type:enhancement enhance or introduce a new feature builder:html labels Jan 2, 2015
@shimizukawa
Copy link
Member Author

From Georg Brandl on 2009-11-08 17:24:12+00:00

I assume this would require a piece of JavaScript that removes the prompts before copying.

The only question is what to do with output between prompts -- remove it as well? Many doctest-style examples are meant to be executed one after the other in a shell; larger samples should not have doctest markup.

Anyway, let's keep this open as a nice-to-have.

@shimizukawa
Copy link
Member Author

From Gregg Lind on 2010-04-02 20:56:44+00:00

After some discussion with Taggnoster, we wrote some code to handle this.

see: 1800:bfc9819c802f

@shimizukawa
Copy link
Member Author

From tpowers on 2010-04-27 04:11:08+00:00

When I need to do this sort of thing (rarely), the easiest thing to do is to fire up wxPython's pycrust or pyshell and just use the Paste or Paste Plus commands.

@shimizukawa
Copy link
Member Author

From Georg Brandl on 2010-08-05 17:46:33+00:00

Issue #389 was marked as a duplicate of this issue.

@shimizukawa
Copy link
Member Author

From Ram Rachum on 2011-01-14 08:22:44+00:00

Issue #604 was marked as a duplicate of this issue.

@shimizukawa
Copy link
Member Author

From Ram Rachum on 2011-01-14 08:25:47+00:00

The annoying thing about having JS copy-paste trickery is that the user doesn't know that it's there. The user might avoid copy-pasting shell sessions completely after he sees that the prompts get selected together with the code, without even trying to paste so he won't see that the ">>> " parts disappear.

Do you think it's possible to automatically generate tables so that the prompts are in a separate cell than the code?

@shimizukawa
Copy link
Member Author

From Georg Brandl on 2011-01-15 08:51:49+00:00

Tables might work but for interleaved output, which needs to be skipped as well.

shimizukawa added a commit that referenced this issue Mar 11, 2015
add 'diff' parameter to literalinclude.
@stefan-balke
Copy link

Has this been addressed already?

@ankostis
Copy link

ankostis commented Oct 9, 2019

This issue is hard to find, and hence so many duplicates.
In particular, the title is missing the words

  • clipboard
  • copy
  • doctest

Can someone with enough privileges amend the title?

@ankostis
Copy link

ankostis commented Oct 9, 2019

Could this CSS trick is releveant, relying on data-pseudo-content--before, work?

@tk0miya
Copy link
Member

tk0miya commented Oct 10, 2019

I use user-select style for this. see #6727 .

tk0miya added a commit that referenced this issue Oct 13, 2019
Close #267: html: Eliminate prompt characters of doctest block from c…
@tk0miya
Copy link
Member

tk0miya commented Oct 13, 2019

Fixed by #6727 . (It's 10yrs after posted!)
Thanks,

@tk0miya tk0miya closed this as completed Oct 13, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
builder:html type:enhancement enhance or introduce a new feature
Projects
None yet
Development

No branches or pull requests

4 participants