Unescaping formatted Terminal text
Peter Otten
__peter__ at web.de
Fri Jun 3 11:15:09 EDT 2011
Gnarlodious wrote:
> This may be happening because I am using Python 3.2 which includes
> "curses" to format output. When running:
>
> pydoc.render_doc(sys.modules[__name__])
>
> in Terminal I see FUNCTIONS
>
> when the same output goes to HTTP I see FFUUNNCCTTIIOONNSS
What you are seeing isn't an ANSI escape sequence, it's actually Char-
Backspace-Char (e. g. "F\bF\U\bU...") which is interpreted as a bold Char by
the "less" utility.
> Is there an easy way to strip ANSI escaped characters from output for
> CGI rendering?
pydoc.render_doc(module, renderer=pydoc.plaintext)
or even
pydoc.render_doc(module, renderer=pydoc.html)
More information about the Python-list
mailing list