#162 [Python] Copy/Paste with highlighted code doesn't work



first of all, thank you for your php code highlighter.

My problem is the following :

As you should already know, python code depends on a proper indentation to be executed correctly. The problem is, when I highlight a working python code with geshi, then copy the highlighted code and paste it into the interpreter, I got plenty errors.

Common errors obtained are syntax error (maybe a wrong character inserted by geshi) or indentation error. The more flagrant way to reproduce this bug is to go to wikipedia for example, and to try to copy paste some highlighted python code into your interpreter.
Try with this example for example :

It should be really appreciated if you could correct geshi in a way which preservers the space numbers and permit copy paste for indentation dependant languages.

Many thanks,



  • BenBE

    BenBE - 2010-07-16
    • assigned_to: nobody --> benbe
    • priority: 5 --> 3
    • milestone: --> Next_Release_(Stable)
    • labels: 655353 --> Highlighting Errors
  • BenBE

    BenBE - 2010-07-16

    Depending on the way the source is generated when highlighting GeSHi uses a number of different methods to preserve the indentation. This is necessary since normal whitespace is folded in HTML and thus would be ignored. To cope with this, GeSHi uses alternating patterns of non-breaking spaces and spaces to force the display of those spaces and at the same time compress HTML a bit.

    If one of the various PRE-container modes is used no such transformation is needed and the source should copy properly.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks