diff options
| -rw-r--r-- | lib/extensions/input.py | 5 | ||||
| -rw-r--r-- | lib/extensions/letters_to_font.py | 9 | ||||
| -rw-r--r-- | lib/stitch_plan/generate_stitch_plan.py | 3 |
3 files changed, 12 insertions, 5 deletions
diff --git a/lib/extensions/input.py b/lib/extensions/input.py index 4240be0e..3bcbb5a2 100644 --- a/lib/extensions/input.py +++ b/lib/extensions/input.py @@ -3,9 +3,10 @@ # Copyright (c) 2010 Authors # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. -from lxml import etree +from html import unescape from inkex import errormsg +from lxml import etree from ..i18n import _ from ..stitch_plan import generate_stitch_plan @@ -20,4 +21,4 @@ class Input(object): errormsg(msg) exit(0) stitch_plan = generate_stitch_plan(embroidery_file) - print(etree.tostring(stitch_plan).decode('utf-8')) + print(unescape(etree.tostring(stitch_plan).decode('utf-8'))) diff --git a/lib/extensions/letters_to_font.py b/lib/extensions/letters_to_font.py index d4d9e60a..e779b5d1 100644 --- a/lib/extensions/letters_to_font.py +++ b/lib/extensions/letters_to_font.py @@ -4,6 +4,7 @@ # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. import os +from html import escape, unescape from pathlib import Path import inkex @@ -42,7 +43,8 @@ class LettersToFont(InkstitchExtension): group = None for glyph in glyphs: letter = self.get_glyph_element(glyph) - label = "GlyphLayer-%s" % letter.get(INKSCAPE_LABEL, ' ').split('.')[0][-1] + label = unescape(letter.get(INKSCAPE_LABEL, ' ')).split('.')[0][-1] + label = f"GlyphLayer-{ label }" group = inkex.Group(attrib={ INKSCAPE_LABEL: label, INKSCAPE_GROUPMODE: "layer", @@ -79,8 +81,11 @@ class LettersToFont(InkstitchExtension): stitch_plan = generate_stitch_plan(str(glyph), self.options.import_commands) # we received a stitch plan wrapped in an svg document, we only need the stitch_plan group # this group carries the name of the file, so we can search for it. - stitch_plan = stitch_plan.xpath('.//*[@inkscape:label="%s"]' % os.path.basename(glyph), namespaces=inkex.NSS)[0] + label = os.path.basename(glyph) + search_string = f'.//*[@inkscape:label="{ escape(label) }"]' + stitch_plan = stitch_plan.xpath(search_string, namespaces=inkex.NSS)[0] stitch_plan.attrib.pop(INKSCAPE_GROUPMODE) + stitch_plan.label = label return stitch_plan def insert_baseline(self): diff --git a/lib/stitch_plan/generate_stitch_plan.py b/lib/stitch_plan/generate_stitch_plan.py index 53458815..cdd66d9e 100644 --- a/lib/stitch_plan/generate_stitch_plan.py +++ b/lib/stitch_plan/generate_stitch_plan.py @@ -5,6 +5,7 @@ import os import sys +from html import escape import inkex @@ -59,7 +60,7 @@ def generate_stitch_plan(embroidery_file, import_commands="symbols"): # noqa: C # rename the Stitch Plan layer so that it doesn't get overwritten by Embroider layer = svg.find(".//*[@id='__inkstitch_stitch_plan__']") - layer.set(INKSCAPE_LABEL, os.path.basename(embroidery_file)) + layer.set(INKSCAPE_LABEL, escape(os.path.basename(embroidery_file))) layer.attrib.pop('id') # Shift the design so that its origin is at the center of the canvas |
