Skip to content

Commit

Permalink
sphinx.ext.graphviz: use <object> instead of <img> to embed svg
Browse files Browse the repository at this point in the history
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 sphinx-doc#967
  • Loading branch information
xuhdev committed Dec 16, 2015
1 parent 8b47cc5 commit 1a1f735
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sphinx/ext/graphviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 1a1f735

Please sign in to comment.