mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Merge pull request #3217 from tk0miya/3212_docutils_0.13
Fix #3212: HTML Builders crashes with docutils-0.13
This commit is contained in:
+1
-1
@@ -15,8 +15,8 @@ env:
|
|||||||
- PYTHONFAULTHANDLER=x
|
- PYTHONFAULTHANDLER=x
|
||||||
- PYTHONWARNINGS=all
|
- PYTHONWARNINGS=all
|
||||||
matrix:
|
matrix:
|
||||||
- DOCUTILS=0.11
|
|
||||||
- DOCUTILS=0.12
|
- DOCUTILS=0.12
|
||||||
|
- DOCUTILS=0.13.1
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ Bugs fixed
|
|||||||
* #3198: AttributeError is raised when toctree has 'self'
|
* #3198: AttributeError is raised when toctree has 'self'
|
||||||
* #3211: Remove untranslated sphinx locale catalogs (it was covered by
|
* #3211: Remove untranslated sphinx locale catalogs (it was covered by
|
||||||
untranslated it_IT)
|
untranslated it_IT)
|
||||||
|
* #3212: HTML Builders crashes with docutils-0.13
|
||||||
|
|
||||||
|
|
||||||
Release 1.5 (released Dec 5, 2016)
|
Release 1.5 (released Dec 5, 2016)
|
||||||
|
|||||||
+12
-1
@@ -16,6 +16,7 @@ import copy
|
|||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from six import string_types
|
from six import string_types
|
||||||
|
import docutils
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
from docutils.writers.html4css1 import Writer, HTMLTranslator as BaseTranslator
|
from docutils.writers.html4css1 import Writer, HTMLTranslator as BaseTranslator
|
||||||
|
|
||||||
@@ -500,7 +501,7 @@ class HTMLTranslator(BaseTranslator):
|
|||||||
self.builder.images[olduri])
|
self.builder.images[olduri])
|
||||||
|
|
||||||
uri = node['uri']
|
uri = node['uri']
|
||||||
if uri.lower().endswith('svg') or uri.lower().endswith('svgz'):
|
if uri.lower().endswith(('svg', 'svgz')):
|
||||||
atts = {'src': uri}
|
atts = {'src': uri}
|
||||||
if 'width' in node:
|
if 'width' in node:
|
||||||
atts['width'] = node['width']
|
atts['width'] = node['width']
|
||||||
@@ -532,6 +533,16 @@ class HTMLTranslator(BaseTranslator):
|
|||||||
node['height'] = str(size[1])
|
node['height'] = str(size[1])
|
||||||
BaseTranslator.visit_image(self, node)
|
BaseTranslator.visit_image(self, node)
|
||||||
|
|
||||||
|
# overwritten
|
||||||
|
def depart_image(self, node):
|
||||||
|
if docutils.__version__ >= "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()
|
||||||
|
self.body.append(self.context.pop())
|
||||||
|
|
||||||
def visit_toctree(self, node):
|
def visit_toctree(self, node):
|
||||||
# this only happens when formatting a toc from env.tocs -- in this
|
# this only happens when formatting a toc from env.tocs -- in this
|
||||||
# case we don't want to include the subtree
|
# case we don't want to include the subtree
|
||||||
|
|||||||
Reference in New Issue
Block a user