Issues

Issue #267 open

Eliminate prompt characters in examples from copyable text

Michael 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 (9)

  1. Georg Brandl repo owner

    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