Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6951

Re: Unescaping formatted Terminal text

From Peter Otten <__peter__@web.de>
Subject Re: Unescaping formatted Terminal text
Date 2011-06-03 17:15 +0200
Organization None
References <1d3cc5b2-39c1-4bb8-a692-ff166533dbca@y12g2000yqh.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.2432.1307114122.9059.python-list@python.org> (permalink)

Show all headers | View raw


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)

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Unescaping formatted Terminal text Gnarlodious <gnarlodious@gmail.com> - 2011-06-03 07:21 -0700
  Re: Unescaping formatted Terminal text Peter Otten <__peter__@web.de> - 2011-06-03 17:15 +0200
    Re: Unescaping formatted Terminal text Gnarlodious <gnarlodious@gmail.com> - 2011-06-03 15:16 -0700

csiph-web