Skip to content

Commit

Permalink
Stringify SVG as ASCII with entity encoding
Browse files Browse the repository at this point in the history
It seems that when processing a SVG file passed via a pipe, Inkscape emits
errors/warnings about an XML parser error if the SVG file is UTF-8
encoded. It still does seem to successfully process the SVG file and
generates the expected output, however, these messages are at least
confusing. Not passing the encoding parameter to etree.tostring() makes
it output ASCII with non-ASCII characters encoded as XML entities, so this
can then be correctly parsed again, and this does not seem to 'confuse'
Inkscape.
  • Loading branch information
mstock committed Aug 27, 2022
1 parent 7dd51d0 commit edf8624
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion svgtemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def transform(self, frame):
# if '$subtitle' in task.parameters and task.parameters['$subtitle'] == '':
# child = svg.findall(".//*[@id='subtitle']")[0]
# child.getparent().remove(child)
self.svgstr = etree.tostring(svg, encoding='unicode')
self.svgstr = etree.tostring(svg).decode('UTF-8')

def __exit__(self, exception_type, exception_value, traceback):
pass

0 comments on commit edf8624

Please sign in to comment.