mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-05 05:47:04 +08:00
fix workflow embedding w/ unicode characters
This commit is contained in:
parent
c854ba17ed
commit
8602052fdb
@ -266,14 +266,18 @@ class SaveSVGNode:
|
|||||||
if metadata_json:
|
if metadata_json:
|
||||||
# Create metadata element with CDATA section
|
# Create metadata element with CDATA section
|
||||||
metadata_element = f""" <metadata>
|
metadata_element = f""" <metadata>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{metadata_json}
|
{metadata_json}
|
||||||
]]>
|
]]>
|
||||||
</metadata>
|
</metadata>
|
||||||
"""
|
"""
|
||||||
# Insert metadata after opening svg tag using regex
|
# Insert metadata after opening svg tag using regex with a replacement function
|
||||||
# import re # Already imported at the top
|
def replacement(match):
|
||||||
svg_content = re.sub(r'(<svg[^>]*>)', r'\1\n' + metadata_element, svg_content)
|
# match.group(1) contains the captured <svg> tag
|
||||||
|
return match.group(1) + '\n' + metadata_element
|
||||||
|
|
||||||
|
# Apply the substitution
|
||||||
|
svg_content = re.sub(r'(<svg[^>]*>)', replacement, svg_content, flags=re.UNICODE)
|
||||||
|
|
||||||
# Write the modified SVG to file
|
# Write the modified SVG to file
|
||||||
with open(os.path.join(full_output_folder, file), 'wb') as svg_file:
|
with open(os.path.join(full_output_folder, file), 'wb') as svg_file:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user