diff options
| -rw-r--r-- | imagemap.py | 11 | ||||
| -rw-r--r-- | 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<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__": 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 @@ <area shape=rect coords=25,20,75,30 href=http://example.com/1 alt=A> -<area shape=rect coords=25,45,45,55 href=http://example.com/2 alt=B> -<area shape=rect coords=55,45,75,55 href=http://example.com/2> +<area shape=rect coords=25,45,45,55 href=http://example.com/2> +<area shape=rect coords=55,45,75,55 href=http://example.com/2 alt=B> <area shape=rect coords=25,70,75,80 href=http://example.com/3 alt=C> |
