Breaks file by removing clip even when child is referenced by a clone (`<use>`)
Created by: nathanal
Downstream report: https://gitlab.com/inkscape/extensions/-/issues/468
Steps to Replicate
- Run min_example_lost_clone through scour
scour -i min_example_lost_clone
What happened?
- The object the
<use>
element links to is deleted (because it is in a unused clone)
What should have happened?
- Object is not deleted.
- Ideally the clone is removed but relevant children preserved; however, keeping the clip is better than current behavior.
Input
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<clipPath id="unusedclip">
<rect id="the_path" width="100" height="100"/>
</clipPath>
</defs>
<use fill="red" width="100%" height="100%" xlink:href="#the_path"/>
</svg>
Output
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<use width="100%" height="100%" fill="red" xlink:href="#the_path"/>
</svg>
Version info
- Testing by cloning this repository and
pip3 install .
(I edited the scour version to make sure I could see it was properly installed) (0609c596) - Also happens with python3-scour from repos (0.37) and 0.38.2 from pip3
- Python 3.8.10, Linux Mint 20