Skip to content

Commit

Permalink
Use img tag for SVG images
Browse files Browse the repository at this point in the history
This commit changes the HTML tag which is used for SVG images
from <object> to <img>. This fixes scalability of images on websites.

Signed-off-by: Robert Winkler <[email protected]>
  • Loading branch information
rw1nkler committed Sep 17, 2020
1 parent 016885f commit b1f5dd7
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions sphinxcontrib_hdl_diagrams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,18 +465,13 @@ def render_diagram_html(
if alt is None:
alt = node.get('alt', self.encode(code).strip())
imgcss = imgcls and 'class="%s"' % imgcls or ''
if format == 'svg':
svgtag = '''<object data="%s" type="image/svg+xml">
<p class="warning">%s</p></object>\n''' % (fname, alt)
self.body.append(svgtag)
else:
if 'align' in node:
self.body.append('<div align="%s" class="align-%s">' %
(node['align'], node['align']))
self.body.append('<img src="%s" alt="%s" %s/>\n' %
(fname, alt, imgcss))
if 'align' in node:
self.body.append('</div>\n')
if 'align' in node:
self.body.append('<div align="%s" class="align-%s">' %
(node['align'], node['align']))
self.body.append('<img src="%s" alt="%s" %s/>\n' %
(fname, alt, imgcss))
if 'align' in node:
self.body.append('</div>\n')

raise nodes.SkipNode

Expand Down

0 comments on commit b1f5dd7

Please sign in to comment.