diff options
| author | Viatrix | 2026-03-12 12:15:13 -0700 |
|---|---|---|
| committer | Viatrix | 2026-03-12 12:15:13 -0700 |
| commit | 583220acca483e567553851815d3563bec7468f6 (patch) | |
| tree | 5019db9da5b5c0d0ad46d1423f06fe0f6d227638 /imagemap.py | |
| parent | e8b45cae1841c4ed30013cd3cb85257fce027e7f (diff) | |
Added error message for image with zero hyperlinks
Diffstat (limited to 'imagemap.py')
| -rw-r--r-- | imagemap.py | 3 |
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({'&':'&','<':'<','>':'>'}) @@ -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' |
