Browse Source
Fix fill matching in helper.py
Previously, helper.py's colour-matching regex would match greedily any
non-whitespace (\S), which caused styles written out by Inkscape to fail
to be parsed correctly.
Instead, match for whitespace with \s.
As an example, in a REPL:
import re
style = "font-variation-settings:normal;opacity:1;fill:#ff00ff;fill-opacity:1;stop-color:#000000;stop-opacity:1"
color_match = re.search(r'fill:\s*(#[0-9a-fA-F]{6})',style)
print (color_match.group(1))
(Prints #ff00ff - correct)
vs.
import re
style = "font-variation-settings:normal;opacity:1;fill:#ff00ff;fill-opacity:1;stop-color:#000000;stop-opacity:1"
color_match = re.search(r'fill:\S*(#[0-9a-fA-F]{6})',style)
print (color_match.group(1))
(Prints #000000 - incorrect)
pull/1935/head