aboutsummaryrefslogtreecommitdiff
path: root/imagemap.py
diff options
context:
space:
mode:
Diffstat (limited to 'imagemap.py')
-rw-r--r--imagemap.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/imagemap.py b/imagemap.py
index e595f08..22789f0 100644
--- a/imagemap.py
+++ b/imagemap.py
@@ -1,6 +1,7 @@
import inkex
from inkex import bezier
from inkex.command import inkscape_command
+from inkex.localization import inkex_gettext as _
# (X)HTML stuff:
ESCAPE=str.maketrans({'&':'&amp;','<':'&lt;','>':'&gt;'})
@@ -64,6 +65,8 @@ class ImageMap(inkex.OutputExtension):
style=el.effective_style()
style[CSS_LINK_INDEX]=f'" {CSS_LINK_INDEX}-{len(links)} "'
links += [link]
+ if len(links)==0:
+ raise inkex.AbortExtension(_("Image has no hyperlinks.\nAdd a hyperlink to an object with right-click → \"{}\".").format(_("Create Anchor (Hyperlink)")))
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'