From 318a84508163ad786f12ee72d01b1b15d3295f73 Mon Sep 17 00:00:00 2001 From: Viatrix Date: Thu, 12 Mar 2026 12:57:41 -0700 Subject: Added image test case and adjusted code to pass it. Removed rect test case since it was getting redundant. --- imagemap.py | 2 ++ tests/data/refs/imagemap__--maptype__HTML__image__svg.out | 1 + tests/data/refs/imagemap__--maptype__HTML__rect__svg.out | 1 - tests/data/svg/image.svg | 6 ++++++ tests/data/svg/rect.svg | 5 ----- tests/test_imagemap_comparison.py | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 tests/data/refs/imagemap__--maptype__HTML__image__svg.out delete mode 100644 tests/data/refs/imagemap__--maptype__HTML__rect__svg.out create mode 100644 tests/data/svg/image.svg delete mode 100644 tests/data/svg/rect.svg diff --git a/imagemap.py b/imagemap.py index 22789f0..89452be 100644 --- a/imagemap.py +++ b/imagemap.py @@ -62,6 +62,8 @@ class ImageMap(inkex.OutputExtension): link={attr:AREA_ATTRS[attr](a) for attr in AREA_ATTRS.keys()} for el in a.iterdescendants(): # CSS is preserved when flattening (for paths) if not isinstance(el,inkex.ShapeElement): continue + if el.tag=='{http://www.w3.org/2000/svg}image': + el.tag='{http://www.w3.org/2000/svg}rect' # because flattening an image creates a clip-path style=el.effective_style() style[CSS_LINK_INDEX]=f'" {CSS_LINK_INDEX}-{len(links)} "' links += [link] diff --git a/tests/data/refs/imagemap__--maptype__HTML__image__svg.out b/tests/data/refs/imagemap__--maptype__HTML__image__svg.out new file mode 100644 index 0000000..9399c1c --- /dev/null +++ b/tests/data/refs/imagemap__--maptype__HTML__image__svg.out @@ -0,0 +1 @@ + diff --git a/tests/data/refs/imagemap__--maptype__HTML__rect__svg.out b/tests/data/refs/imagemap__--maptype__HTML__rect__svg.out deleted file mode 100644 index 9399c1c..0000000 --- a/tests/data/refs/imagemap__--maptype__HTML__rect__svg.out +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tests/data/svg/image.svg b/tests/data/svg/image.svg new file mode 100644 index 0000000..e0d62d4 --- /dev/null +++ b/tests/data/svg/image.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/data/svg/rect.svg b/tests/data/svg/rect.svg deleted file mode 100644 index 445e6e0..0000000 --- a/tests/data/svg/rect.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/tests/test_imagemap_comparison.py b/tests/test_imagemap_comparison.py index 959e98e..a703b5e 100644 --- a/tests/test_imagemap_comparison.py +++ b/tests/test_imagemap_comparison.py @@ -5,9 +5,9 @@ class ImageMapComparisonTest(ComparisonMixin, TestCase): effect_class = ImageMap compare_file = ( 'svg/enclave.svg', + 'svg/image.svg', 'svg/intersect.svg', 'svg/overlap.svg', - 'svg/rect.svg', 'svg/rounding.svg', 'svg/text.svg', 'svg/transform.svg', -- cgit