nytimes / svg-crowbar

Extracts an SVG node and accompanying styles from an HTML document and allows you to download it all as an SVG file.
https://nytimes.github.io/svg-crowbar/
MIT License
839 stars 153 forks source link

`<defs xmlns="http://www.w3.org/1999/xhtml">` creates invalid svg. #18

Open hugolpz opened 9 years ago

hugolpz commented 9 years ago

Note: with crowbar v.1.

Crowbar create a <defs xmlns="http://www.w3.org/1999/xhtml"><style>...</style></defs> element such as :

<defs xmlns="http://www.w3.org/1999/xhtml"><style type="text/css"><![CDATA[
svg { border: 1px dashed rgb(173, 216, 230); padding: 1em; }]]></style></defs>

And returns the following error :

screenshot from 2015-03-06 11 59 33

In my text editor, removing the xmlns="http://www.w3.org/1999/xhtml" from the <defs> produce a valid svg.

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg id="test" 
    width="200" height="200" 
    version="1.1"
    xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
    <style type="text/css"><![CDATA[svg { border: 1px dashed rgb(173, 216, 230); padding: 1em; }]]></style>
</defs>
<g id="circles" style="fill:red;fill-opacity:.5;stroke:#CCC;stroke-width:2px;">
    <circle cx="186" cy="46" r="7"/>
    <circle cx="157" cy="34" r="6"/>
</g>
</svg>