summaryrefslogtreecommitdiff
path: root/sphinx/writers/html.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-02-18 00:52:12 +0100
committerGeorg Brandl <georg@python.org>2009-02-18 00:52:12 +0100
commit27e20dc5f5ea2f53ead870283aa39ce6bb525b11 (patch)
treefa935820938ccc85feeb77da08515ec570aa7ea5 /sphinx/writers/html.py
parent1d6c00ff74ea59c674918d47940c8ec3602f2fe8 (diff)
downloadsphinx-27e20dc5f5ea2f53ead870283aa39ce6bb525b11.tar.gz
SVG images are now supported in HTML (via ``<object>`` and ``<embed>`` tags).
Diffstat (limited to 'sphinx/writers/html.py')
-rw-r--r--sphinx/writers/html.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py
index 44a7c879..0859bae6 100644
--- a/sphinx/writers/html.py
+++ b/sphinx/writers/html.py
@@ -283,6 +283,26 @@ class HTMLTranslator(BaseTranslator):
node['uri'] = posixpath.join(self.builder.imgpath,
self.builder.images[olduri])
+ if node['uri'].lower().endswith('svg') or \
+ node['uri'].lower().endswith('svgz'):
+ atts = {'data': node['uri'], 'type': 'image/svg+xml'}
+ if 'width' in node:
+ atts['width'] = node['width']
+ if 'height' in node:
+ atts['height'] = node['height']
+ if 'align' in node:
+ self.body.append('<div align="%s" class="align-%s">' %
+ (node['align'], node['align']))
+ self.context.append('</div>\n')
+ else:
+ self.context.append('')
+ embatts = atts.copy()
+ embatts['src'] = embatts.pop('data')
+ self.body.append(self.starttag(node, 'object', '', **atts))
+ self.body.append(self.emptytag(node, 'embed', '', **embatts))
+ self.body.append('</object>\n')
+ return
+
if node.has_key('scale'):
if Image and not (node.has_key('width')
and node.has_key('height')):