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


Groups > comp.lang.python > #6951

Re: Unescaping formatted Terminal text

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'escape': 0.04; '3.2': 0.05; 'char': 0.07; 'python': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'output': 0.11; 'wrote:': 0.14; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'running:': 0.16; 'sequence,': 0.16; 'happening': 0.19; 'interpreted': 0.23; 'seeing': 0.28; 'skip:p 30': 0.28; 'ansi': 0.30; 'from:addr:web.de': 0.30; 'header:X-Complaints-To:1': 0.32; 'to:addr:python-list': 0.33; 'actually': 0.33; "isn't": 0.33; 'characters': 0.34; 'there': 0.35; 'skip:" 10': 0.35; 'using': 0.35; 'subject:text': 0.36; 'http': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'header:Mime-Version:1': 0.39; 'goes': 0.39; 'to:addr:python.org': 0.39; 'format': 0.40; 'bold': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Unescaping formatted Terminal text
Date Fri, 03 Jun 2011 17:15:09 +0200
Organization None
References <1d3cc5b2-39c1-4bb8-a692-ff166533dbca@y12g2000yqh.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p50849488.dip.t-dialin.net
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2432.1307114122.9059.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 82.94.164.166
X-Trace 1307114122 news.xs4all.nl 49174 [::ffff:82.94.164.166]:49003
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6951

Show key headers only | 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