summaryrefslogtreecommitdiff
path: root/lib/extensions
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2023-12-29 17:00:41 +0100
committerGitHub <noreply@github.com>2023-12-29 17:00:41 +0100
commitfd01c2e2f1b9bfb972377492c7769b6b62170193 (patch)
treefff515f83c8d5a8f91ac7476224d9cec3d70e76f /lib/extensions
parent3f37c05a7d411412faa521d1c3b9dd59b426725f (diff)
Stitch plan: escape labels (#2644)
Diffstat (limited to 'lib/extensions')
-rw-r--r--lib/extensions/input.py5
-rw-r--r--lib/extensions/letters_to_font.py9
2 files changed, 10 insertions, 4 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):