Re: Tree Iter: Text out of pango markup




On Feb 4, 2005, at 2:51 AM, A. Pagaltzis wrote:

* muppet <scott asofyet org> [2005-02-04 03:45]:
All you really want to do, though, is strip tags, so even
pango_parse_markup() would be overkill for you.  Things like
$markup =~ s/<[^>]*>//g are what perl does best.  :-)

Is that sufficient in the case of Pango markup? Are there no edge
cases like with HTML where this could break? How does Pango deal
with angle brackets that are supposed to be displayed, and aren't
part of markup?

Of course there are edge cases, nothing can ever be truly simple in computing.

To find out how Pango markup gets interpreted i usually just create a dummy project in glade, a window with a label, set the label to "Use Markup", and then type in the Label box and see what shows up.

If there's *anything* that causes the markup to be invalid, e.g. one of ten tags is unknown, or there's a single stray "<", the whole thing is considered to be not markup.

Luckily, the known tag list is small:
http://developer.gnome.org/doc/API/2.0/pango/PangoMarkupFormat.html


I also think that in the general case, if you control the text that goes in, you can ensure that it's valid, so simply stripping tags and converting entities would be a quick and easy solution.

--
If I lived in Teletubby Land, the homicide rate would be four.
  -- elysse




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]