From fd01c2e2f1b9bfb972377492c7769b6b62170193 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Fri, 29 Dec 2023 17:00:41 +0100 Subject: Stitch plan: escape labels (#2644) --- lib/extensions/letters_to_font.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/extensions/letters_to_font.py') 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): -- cgit v1.2.3