mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #2176 from xuhdev/graphviz-interactive-svg
sphinx.ext.graphviz: use <object> instead of <img> to embed svg
This commit is contained in:
commit
e568f03e38
@ -111,7 +111,18 @@ There are also these new config values:
|
||||
.. confval:: graphviz_output_format
|
||||
|
||||
The output format for Graphviz when building HTML files. This must be either
|
||||
``'png'`` or ``'svg'``; the default is ``'png'``.
|
||||
``'png'`` or ``'svg'``; the default is ``'png'``. If ``'svg'`` is used, in
|
||||
order to make the URL links work properly, an appropriate ``target``
|
||||
attribute must be set, such as ``"_top"`` and ``"_blank"``. For example, the
|
||||
link in the following graph should work in the svg output: ::
|
||||
|
||||
.. graphviz::
|
||||
|
||||
digraph example {
|
||||
a [label="sphinx", href="http://sphinx-doc.org", target="_top"];
|
||||
b [label="other"];
|
||||
a -> b;
|
||||
}
|
||||
|
||||
.. versionadded:: 1.0
|
||||
Previously, output always was PNG.
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user