diff options
| author | Viatrix | 2026-03-18 16:45:27 -0700 |
|---|---|---|
| committer | Viatrix | 2026-03-18 16:45:27 -0700 |
| commit | dfe3e6410b3592744a3041e2d90ce856e1c592c6 (patch) | |
| tree | e0e615547090370fd592e9f1f8210ec82dee61f4 /imagemap.py | |
| parent | 274ad4460f3f4a35e099545a1a8408a9a67614e1 (diff) | |
Alt text works on Lynx
(turns out it should go on the last <area>, not first)
Diffstat (limited to 'imagemap.py')
| -rw-r--r-- | imagemap.py | 11 |
1 files changed, 4 insertions, 7 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<len(coords): if coords[i]==coords[(i+1)%len(coords)]: coords.pop(i) else: i+=1 - if rectifiable(coords): shapes[linkindex].insert(0,{'shape':'rect','coords':rectify(coords),'href':href}) - elif len(coords)>=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__": |
