diff options
author | Michael Goerz <goerz@stanford.edu> | 2018-04-21 00:59:27 -0400 |
---|---|---|
committer | Michael Goerz <goerz@stanford.edu> | 2018-04-21 00:59:27 -0400 |
commit | 4a2b22737660ad1a933a7da5149725b3918e8c57 (patch) | |
tree | 8251dcd9716198a307abca93de095d35aa729dcb /sphinx/ext/graphviz.py | |
parent | b689fb1c12252984a3fa0ed90e7b0276919cf22b (diff) | |
download | sphinx-git-4a2b22737660ad1a933a7da5149725b3918e8c57.tar.gz |
Allow imgcls as class for SVG Graphviz <object>
For consistency, the `<object>` tag for the SVG output of a
inheritance-diagram should have the same `class="inheritance"` attribute
that the corresponding `<img>` tag for the PNG format has. This allows
to define the CSS attribute
object.inheritance {
max-width: 100%;
}
which for SVG (unlike PNG) actually works and makes sense.
Added a test for inheritance-diagrams in SVG.
Diffstat (limited to 'sphinx/ext/graphviz.py')
-rw-r--r-- | sphinx/ext/graphviz.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sphinx/ext/graphviz.py b/sphinx/ext/graphviz.py index f0b321378..127146f94 100644 --- a/sphinx/ext/graphviz.py +++ b/sphinx/ext/graphviz.py @@ -290,9 +290,11 @@ def render_dot_html(self, node, code, options, prefix='graphviz', self.body.append('<div align="%s" class="align-%s">' % (node['align'], node['align'])) if format == 'svg': - svgtag = '''<div class="graphviz"><object data="%s" type="image/svg+xml"> - <p class="warning">%s</p></object></div>\n''' % (fname, alt) - self.body.append(svgtag) + self.body.append('<div class="graphviz">') + self.body.append('<object data="%s" type="image/svg+xml" %s>\n' % + (fname, imgcss)) + self.body.append('<p class="warning">%s</p>' % alt) + self.body.append('</object></div>\n') else: with codecs.open(outfn + '.map', 'r', encoding='utf-8') as mapfile: # type: ignore imgmap = ClickableMapDefinition(outfn + '.map', mapfile.read(), dot=code) |