View | Details | Raw Unified | Return to bug 221116 | Differences between
and this patch

Collapse All | Expand All

(-)textproc/py-sphinx/files/patch-sphinx_writers_html.py (+27 lines)
Line 0 Link Here
1
--- sphinx/writers/html.py.orig	2016-10-01 15:14:37 UTC
2
+++ sphinx/writers/html.py
3
@@ -16,6 +16,7 @@ import copy
4
 import warnings
5
 
6
 from six import string_types
7
+import docutils
8
 from docutils import nodes
9
 from docutils.writers.html4css1 import Writer, HTMLTranslator as BaseTranslator
10
 
11
@@ -497,6 +498,16 @@ class HTMLTranslator(BaseTranslator):
12
                     if 'height' not in node:
13
                         node['height'] = str(size[1])
14
         BaseTranslator.visit_image(self, node)
15
+
16
+    # overwritten
17
+    def depart_image(self, node):
18
+        if docutils.__version__ >= "0.13":
19
+            # since docutils-0.13, HTMLWriter does not push context data on visit_image()
20
+            if node['uri'].lower().endswith(('svg', 'svgz')):
21
+                self.body.append(self.context.pop())
22
+        else:
23
+            # docutils-0.12 or below, HTML Writer always push context data on visit_image()
24
+            self.body.append(self.context.pop())
25
 
26
     def visit_toctree(self, node):
27
         # this only happens when formatting a toc from env.tocs -- in this

Return to bug 221116