Eliminate prompt characters in examples from copyable text

Michael Hoffman avatarMichael Hoffman created an issue

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.

Comments (8)

  1. Georg Brandl

    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.

  2. tpowers

    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.

  3. Ram Rachum

    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?

  4. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.