From dfe3e6410b3592744a3041e2d90ce856e1c592c6 Mon Sep 17 00:00:00 2001 From: Viatrix Date: Wed, 18 Mar 2026 16:45:27 -0700 Subject: Alt text works on Lynx (turns out it should go on the last , not first) --- imagemap.py | 11 ++++------- tests/data/refs/imagemap__--maptype__HTML__alt__svg.out | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/imagemap.py b/imagemap.py index a3f6490..9f801b6 100644 --- a/imagemap.py +++ b/imagemap.py @@ -141,6 +141,7 @@ class ImageMap(inkex.OutputExtension): linkindex=int(linkindex[len(CSS_LINK_INDEX)+3:-2]) link=links[linkindex] href=link['href'] + if len(shapes[linkindex])==0: alt=link['alt'] path=el.get_path().transform(el.composed_transform()).to_superpath() bezier.cspsubdiv(path,0.5) for subpath in path: @@ -149,19 +150,15 @@ class ImageMap(inkex.OutputExtension): while i=3: shapes[linkindex].insert(0,{'shape':'poly','coords':coords,'href':href}) + if rectifiable(coords): shapes[linkindex].insert(0,{'shape':'rect','coords':rectify(coords),'href':href,'alt':alt}) + elif len(coords)>=3: shapes[linkindex].insert(0,{'shape':'poly','coords':coords,'href':href,'alt':alt}) href=None # because subsequent subpaths must be enclaves + alt=None for i in range(len(shapes)): - alt=links[i]['alt'] if len(shapes[i])==0: inkex.errormsg(_("The hyperlink \"{}\" could not be added to the output.").format(links[i]['href'])) for j in shapes[i]: attrs=links[i].copy() attrs.update(j) - if attrs['href'] is not None: - attrs['alt']=alt - alt=None - else: attrs['alt']=None stream.write(bytes(shapemarkup(attrs),'utf-8')) if __name__ == "__main__": diff --git a/tests/data/refs/imagemap__--maptype__HTML__alt__svg.out b/tests/data/refs/imagemap__--maptype__HTML__alt__svg.out index d78824d..8c4e7a1 100644 --- a/tests/data/refs/imagemap__--maptype__HTML__alt__svg.out +++ b/tests/data/refs/imagemap__--maptype__HTML__alt__svg.out @@ -1,4 +1,4 @@ A -B - + +B C -- cgit