When displaying this SVG file in the htmlnotebook:
import IPython.core.display as d
The output is "]>" + image.
The issue probably comes from the fact that the DOCTYPE header stuff is (I think) file-wide, whereas in the notebook SVGs are inlined, so it's probably ignored. Looking at the file itself, even my browser's syntax highlighter sees the ]> as text, and not part of the markup. That said, the browser does still draw it correctly when viewed on its own.
This is another tic for using separate URLs for images, rather than inlining everything. Not all SVGs are going to be able to be inlined, and the code available for inlining is a subset of the code available to separate requests.
Yes, the svg format has to be raw svg without all the document heading stuff.
That's not clear enough, since there's no indication that we don't actually support regular SVG files.
When loading from a file, it should be easy to extract the svg tag, rather than the full xhtml document. Should we do that?
A simple example that works with the given file, at least:
from xml.dom import minidom
# parse full file into dom object
x = minidom.parseString(svg_src)
# get svg tag (should be 1)
found_svg = x.getElementsByTagName('svg')
real_svg = found_svg.toxml()
# there wasn't an svg in the file
Alternatively, the append_svg method could extract the actual svg tag:
Either of these changes allows the example file to display properly
extract svg tag from svg files
We expect svg *tags*, not svg *documents*, which have headers, etc.
This lets the SVG DisplayObject extract the svg tag from a document,
so it works with regular svgs from a URL or file.