diff --git a/sphinx/ext/graphviz.py b/sphinx/ext/graphviz.py
index bc348f4e1..f0b321378 100644
--- a/sphinx/ext/graphviz.py
+++ b/sphinx/ext/graphviz.py
@@ -290,21 +290,25 @@ def render_dot_html(self, node, code, options, prefix='graphviz',
self.body.append('
' %
(node['align'], node['align']))
if format == 'svg':
- svgtag = '''
\n''' % (fname, alt)
+ svgtag = '''
\n''' % (fname, alt)
self.body.append(svgtag)
else:
with codecs.open(outfn + '.map', 'r', encoding='utf-8') as mapfile: # type: ignore
imgmap = ClickableMapDefinition(outfn + '.map', mapfile.read(), dot=code)
if imgmap.clickable:
# has a map
- self.body.append('

\n' %
+ self.body.append('
')
+ self.body.append('

' %
(fname, alt, imgmap.id, imgcss))
+ self.body.append('
\n')
self.body.append(imgmap.generate_clickable_map())
else:
# nothing in image map
- self.body.append('

\n' %
+ self.body.append('
')
+ self.body.append('

' %
(fname, alt, imgcss))
+ self.body.append('
\n')
if 'align' in node:
self.body.append('
\n')
diff --git a/tests/test_ext_graphviz.py b/tests/test_ext_graphviz.py
index 3efab6b56..df096ce62 100644
--- a/tests/test_ext_graphviz.py
+++ b/tests/test_ext_graphviz.py
@@ -22,24 +22,26 @@ def test_graphviz_png_html(app, status, warning):
app.builder.build_all()
content = (app.outdir / 'index.html').text()
- html = (r'')
assert re.search(html, content, re.S)
@@ -52,34 +54,34 @@ def test_graphviz_svg_html(app, status, warning):
content = (app.outdir / 'index.html').text()
html = (r'')
assert re.search(html, content, re.S)
- html = (r'Hello \n'
- r'\s+graph
\n'
+ html = (r'Hello \n'
r' graphviz world')
assert re.search(html, content, re.S)
html = (r'')
assert re.search(html, content, re.S)
html = (r''
- r'
')
assert re.search(html, content, re.S)
diff --git a/tests/test_ext_inheritance_diagram.py b/tests/test_ext_inheritance_diagram.py
index ad106e6c6..dfee015e0 100644
--- a/tests/test_ext_inheritance_diagram.py
+++ b/tests/test_ext_inheritance_diagram.py
@@ -25,8 +25,9 @@ def test_inheritance_diagram_html(app, status, warning):
content = (app.outdir / 'index.html').text()
pattern = ('