-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #3212: HTML Builders crashes with docutils-0.13 #3217
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
import warnings | ||
|
||
from six import string_types | ||
import docutils | ||
from docutils import nodes | ||
from docutils.writers.html4css1 import Writer, HTMLTranslator as BaseTranslator | ||
|
||
|
@@ -500,7 +501,7 @@ def visit_image(self, node): | |
self.builder.images[olduri]) | ||
|
||
uri = node['uri'] | ||
if uri.lower().endswith('svg') or uri.lower().endswith('svgz'): | ||
if uri.lower().endswith(('svg', 'svgz')): | ||
atts = {'src': uri} | ||
if 'width' in node: | ||
atts['width'] = node['width'] | ||
|
@@ -532,6 +533,16 @@ def visit_image(self, node): | |
node['height'] = str(size[1]) | ||
BaseTranslator.visit_image(self, node) | ||
|
||
# overwritten | ||
def depart_image(self, node): | ||
if docutils.__version__ >= "0.13": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comparison doesn't always work: >>> '0.9' >= '0.13'
True There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I post a new PR for this: #3225. |
||
# 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): | ||
# this only happens when formatting a toc from env.tocs -- in this | ||
# case we don't want to include the subtree | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this PR, I removed docutils-0.11 from test matrix to prevent to increase test time.
@shimizukawa what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's OK to me.
IMO, it is sufficient to keep only the last two versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!