From 27e20dc5f5ea2f53ead870283aa39ce6bb525b11 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 18 Feb 2009 00:52:12 +0100 Subject: SVG images are now supported in HTML (via ```` and ```` tags). --- sphinx/writers/html.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sphinx') 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('
' % + (node['align'], node['align'])) + self.context.append('
\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('
\n') + return + if node.has_key('scale'): if Image and not (node.has_key('width') and node.has_key('height')): -- cgit v1.2.1