Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

svg double hyphen in plot title -- #1967

Merged
merged 1 commit into from May 3, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/matplotlib/backends/backend_svg.py
@@ -1,6 +1,6 @@
from __future__ import division

import os, base64, tempfile, urllib, gzip, io, sys, codecs
import os, base64, tempfile, urllib, gzip, io, sys, codecs, re

import numpy as np

Expand Down Expand Up @@ -71,6 +71,11 @@ def escape_cdata(s):
s = s.replace(u">", u">")
return s

_escape_xml_comment = re.compile(r'-(?=-)')
def escape_comment(s):
s = escape_cdata(s)
return _escape_xml_comment.sub('- ', s)

def escape_attrib(s):
s = s.replace(u"&", u"&")
s = s.replace(u"'", u"'")
Expand Down Expand Up @@ -146,7 +151,7 @@ def start(self, tag, attrib={}, **extra):
def comment(self, comment):
self.__flush()
self.__write(self.__indentation[:len(self.__tags)])
self.__write(u"<!-- %s -->\n" % escape_cdata(comment))
self.__write(u"<!-- %s -->\n" % escape_comment(comment))

##
# Adds character data to the output stream.
Expand Down