aboutsummaryrefslogtreecommitdiff
path: root/imagemap.py
diff options
context:
space:
mode:
Diffstat (limited to 'imagemap.py')
-rw-r--r--imagemap.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/imagemap.py b/imagemap.py
index 4c4c931..a1bd093 100644
--- a/imagemap.py
+++ b/imagemap.py
@@ -59,13 +59,15 @@ class ImageMap(inkex.OutputExtension):
for a in self.svg.iterdescendants('{http://www.w3.org/2000/svg}a'):
# save link attributes because they get removed when flattening
link={attr:AREA_ATTRS[attr](a) for attr in AREA_ATTRS.keys()}
- for el in a.iterdescendants(): # CSS is preserved when flattening BUT NOT IN TEXT SO WE GOTTA FIGURE OUT HOW TODO TEXT
+ for el in a.iterdescendants(): # CSS is preserved when flattening (for paths)
if not isinstance(el,inkex.ShapeElement): continue
style=el.effective_style()
style[CSS_LINK_INDEX]=f'" {CSS_LINK_INDEX}-{len(links)} "'
links += [link]
- command='select-all;path-flatten;'+ \
- ';'.join(f'select-clear;select-by-selector:[style~="{CSS_LINK_INDEX}-{i}"];path-union;path-split' for i in range(len(links)))
+ command=\
+ ';'.join(f'select-clear;select-by-selector:[style~="{CSS_LINK_INDEX}-{i}"];object-stroke-to-path;path-union;object-set-attribute:style,{CSS_LINK_INDEX}:" {CSS_LINK_INDEX}-{i} "' for i in range(len(links))) \
+ +';select-all;path-flatten;path-split'
+ # (we re-set the existing style attribute in case it got unset on non-paths)
newbytes=inkscape_command(self.svg,actions=command)
self.svg=self.load(newbytes).getroot()