fix color

This commit is contained in:
soraefir
2026-06-08 21:09:51 +02:00
parent 94aa518fe7
commit 9f4fc933cf

View File

@@ -139,22 +139,24 @@ let
return None, DEFAULT_PROFILE
def _replace_svg_color(svg, attribute, color):
if attribute in {"fill", "stroke"}:
if attribute not in {"fill", "stroke"}:
return svg
svg = re.sub(
rf'{attribute}="(?!none\\b)[^"]*"',
f'{attribute}="{color}"',
rf'({attribute}\\s*=\\s*")(?!none\\b)[^"]*(")',
rf"\\1{color}\\2",
svg,
flags=re.IGNORECASE,
)
svg = re.sub(
rf"{attribute}='(?!none\\b)[^']*'",
f"{attribute}='{color}'",
rf"({attribute}\\s*=\\s*')(?!none\\b)[^']*(')",
rf"\\1{color}\\2",
svg,
flags=re.IGNORECASE,
)
return re.sub(
rf"{attribute}\\s*:\\s*(?!none\\b)[^;\"\\']+",
f"{attribute}:{color}",
rf"({attribute}\\s*:\\s*)(?!none\\b)[^;\"']+",
rf"\\1{color}",
svg,
flags=re.IGNORECASE,
)