[pygtk] quoting text for markup

Darren Hart darren at dvhart.com
Fri Apr 17 11:19:24 WST 2009


On Thu, Mar 19, 2009 at 9:01 AM, Neil Muller <drnlmuller+gtk at gmail.com> wrote:
> On Thu, Mar 19, 2009 at 5:28 PM, Darren Hart <darren at dvhart.com> wrote:
>> RIght & < and > - but my question was if there is some python call to
>> do this or if I just have to roll my own.  I recently added this to my
>> code base:
>
>>>> from gobject import markup_escape_text
>>>> markup_escape_text('A & B <C>')

Excellent.  Thanks a million.

> 'A &amp; B &lt;C&gt;'
>
> For completeness, this is reversible via pango's parse_markup
>
>>>> from pango import parse_markup
>>>> parse_markup(markup_escape_text('A & B <C>'))[1] # Since parse_markup returns a (pango.AttrList, text, accel_char) tuple (see docs)
> 'A & B <C>'
>
>
> --
> Neil Muller
> drnlmuller at gmail.com
>
> I've got a gmail account. Why haven't I become cool?
>



-- 
Darren Hart


More information about the pygtk mailing list