sphinx.ext.graphviz: use <object> instead of <img> to embed svg

If svg files are embedded in <img> in html, all interactive features are
lost, which graphviz is able to produce. This commit replace <img> with
<object> for svg files.

Close #967
This commit is contained in:
Hong Xu
2015-12-16 02:55:40 -08:00
parent 8b47cc52b1
commit 1a1f735478
+2 -1
View File
@@ -223,7 +223,8 @@ def render_dot_html(self, node, code, options, prefix='graphviz',
alt = node.get('alt', self.encode(code).strip())
imgcss = imgcls and 'class="%s"' % imgcls or ''
if format == 'svg':
svgtag = '<img src="%s" alt="%s" %s/>\n' % (fname, alt, imgcss)
svgtag = '''<object data="%s" type="image/svg+xml">
<p class="warning">%s</p></object>\n''' % (fname, alt)
self.body.append(svgtag)
else:
mapfile = open(outfn + '.map', 'rb')