diff options
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__": |
