Skip to content
Snippets Groups Projects
Commit d9ff414a authored by nkour's avatar nkour
Browse files

escape pango markup for all characters that break it

parent a037ca83
No related branches found
No related tags found
No related merge requests found
......@@ -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, {'\\': '&apos;',
'"': '&quot;'})
return escaped_str
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment