Refactor depart_image()

This commit is contained in:
Takeshi KOMIYA 2016-12-13 11:38:23 +09:00
parent 4054b0b3a5
commit b98e2e39bb

View File

@ -535,13 +535,10 @@ class HTMLTranslator(BaseTranslator):
# overwritten
def depart_image(self, node):
if sphinx.util.docutils.__version_info__ >= (0, 13):
# since docutils-0.13, HTMLWriter does not push context data on visit_image()
if node['uri'].lower().endswith(('svg', 'svgz')):
self.body.append(self.context.pop())
else:
# docutils-0.12 or below, HTML Writer always push context data on visit_image()
if node['uri'].lower().endswith(('svg', 'svgz')):
self.body.append(self.context.pop())
else:
BaseTranslator.depart_image(self, node)
def visit_toctree(self, node):
# this only happens when formatting a toc from env.tocs -- in this