Fixed #3400 introduced in dda16c8

This commit is contained in:
Andrej730
2023-07-11 14:54:05 +05:00
parent ef0ccfd48f
commit e5c5c18d8d
@@ -310,10 +310,13 @@ class SheetBuilder:
brackets_level -= 1 brackets_level -= 1
text += l text += l
# replace urls url(#marker) with url(#prefix-marker) def replace_urls(text):
# since url(#marker.prefix) doesn't seem to work """replace urls `url(#marker)` with `url(#prefix-marker)`
text = re.sub(r"url\(#([^\)]+)\)", rf"url(#{prefix}-\1)", text) since `url(#marker.prefix)` doesn't seem to work
style.text = text """
return re.sub(r"url\(#([^\)]+)\)", rf"url(#{prefix}-\1)", text)
style.text = replace_urls(text)
for svg_element in svg.findall(f".//*"): for svg_element in svg.findall(f".//*"):
if svg_element.tag in (f"{SVG}style", f"{SVG}svg"): if svg_element.tag in (f"{SVG}style", f"{SVG}svg"):
@@ -325,6 +328,9 @@ class SheetBuilder:
# add class "prefix" to all classes # add class "prefix" to all classes
if "class" in attrib: if "class" in attrib:
attrib["class"] += f" {prefix}" attrib["class"] += f" {prefix}"
if "filter" in attrib:
# example use "#fill-background" filter
attrib["filter"] = replace_urls(attrib["filter"])
if svg_element.tag == f"{SVG}use": if svg_element.tag == f"{SVG}use":
href_attrib = f"{XLINK}href" href_attrib = f"{XLINK}href"
if href_attrib in attrib: if href_attrib in attrib: