escape pango markup for all characters that break it
This commit is contained in:
parent
a037ca8369
commit
d9ff414ac5
1 changed files with 12 additions and 4 deletions
|
@ -20,9 +20,17 @@
|
||||||
## GNU General Public License for more details.
|
## GNU General Public License for more details.
|
||||||
##
|
##
|
||||||
|
|
||||||
import cgi
|
import xml.sax.saxutils
|
||||||
|
|
||||||
def escape_for_pango_markup(string):
|
def escape_for_pango_markup(string):
|
||||||
# escapes chars for pango markup not to break
|
# escapes < > & \ "
|
||||||
if string is not None:
|
# for pango markup not to break
|
||||||
return cgi.escape(string)
|
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…
Add table
Reference in a new issue