escape pango markup for all characters that break it
This commit is contained in:
parent
a037ca8369
commit
d9ff414ac5
|
@ -20,9 +20,17 @@
|
|||
## GNU General Public License for more details.
|
||||
##
|
||||
|
||||
import cgi
|
||||
import xml.sax.saxutils
|
||||
|
||||
def escape_for_pango_markup(string):
|
||||
# escapes chars for pango markup not to break
|
||||
if string is not None:
|
||||
return cgi.escape(string)
|
||||
# escapes < > & \ "
|
||||
# for pango markup not to break
|
||||
if string is None:
|
||||
return
|
||||
if gtk.pygtk_version >= (2, 8, 0) and gtk.gtk_version >= (2, 8, 0):
|
||||
escaped_str = gobject.markup_escape_text(string)
|
||||
else:
|
||||
escaped_str =xml.sax.saxutils.escape(string, {'\\': ''',
|
||||
'"': '"'})
|
||||
|
||||
return escaped_str
|
||||
|
|
Loading…
Reference in New Issue