fnando / svg_optimizer

Some SVG optimization based on Node's SVGO
MIT License
19 stars 6 forks source link

Undefined namespace prefix: //i:* #8

Closed adampope closed 2 years ago

adampope commented 6 years ago

I have an SVG file created by Illustrator (attached). I can optimise it fine with svgo, but when I run it through SvgOptimizer I get Nokogiri::XML::XPath::SyntaxError: Undefined namespace prefix: //i:*.

The problem seems to be the <!ENTITY definitions in the <!DOCTYPE tag. If I remove the ENTITY tags or the whole DOCTYPE then the optimiser runs, but it breaks the file as it doesn't remove all the namespaced attributes.

broken.svg.txt

fnando commented 2 years ago

Hey @adampope!

Sorry for taking only 4 years, 2 months, 16 days to take a look at this. 😳😬

I have no clue how to optimize a file like this, so the best I could do for now is just not raising exceptions when "optimizing" complex files like this. The end result may or may not work, but at least there's no exception.

If anyone is willing to deep dive and see how files like this can be optimize, pull requests are more than welcome.