mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #3165 from sphinx-doc/gettext-image-fix
refs #3093: gettext build broken on substituted images, under note directive
This commit is contained in:
commit
36ca4ae393
2
CHANGES
2
CHANGES
@ -11,6 +11,8 @@ Bugs fixed
|
||||
* #3074: ``add_source_parser()`` crashes in debug mode
|
||||
* #3135: ``sphinx.ext.autodoc`` crashes with plain Callable
|
||||
* #3150: Fix query word splitter in JavaScript. It behaves as same as Python's regular expression.
|
||||
* #3093: gettext build broken on substituted images.
|
||||
* #3093: gettext build broken on image node under ``note`` directive.
|
||||
|
||||
Release 1.4.8 (released Oct 1, 2016)
|
||||
====================================
|
||||
|
@ -166,7 +166,7 @@ class ApplySourceWorkaround(Transform):
|
||||
|
||||
def apply(self):
|
||||
for n in self.document.traverse():
|
||||
if isinstance(n, nodes.TextElement):
|
||||
if isinstance(n, (nodes.TextElement, nodes.image)):
|
||||
apply_source_workaround(n)
|
||||
|
||||
|
||||
|
@ -46,6 +46,8 @@ def apply_source_workaround(node):
|
||||
node.source = definition_list_item.source
|
||||
node.line = definition_list_item.line - 1
|
||||
node.rawsource = node.astext() # set 'classifier1' (or 'classifier2')
|
||||
if isinstance(node, nodes.image) and node.source is None:
|
||||
node.source, node.line = node.parent.source, node.parent.line
|
||||
if isinstance(node, nodes.term):
|
||||
# strip classifier from rawsource of term
|
||||
for classifier in reversed(node.parent.traverse(nodes.classifier)):
|
||||
@ -69,6 +71,7 @@ def apply_source_workaround(node):
|
||||
nodes.title,
|
||||
nodes.rubric,
|
||||
nodes.line,
|
||||
nodes.image,
|
||||
))):
|
||||
node.source = find_source_node(node)
|
||||
node.line = 0 # need fix docutils to get `node.line`
|
||||
|
@ -50,3 +50,10 @@ msgid ""
|
||||
msgstr ""
|
||||
".. image:: img.png\n"
|
||||
" :alt: I18N -> IMG"
|
||||
|
||||
msgid "image on substitution"
|
||||
msgstr "IMAGE ON SUBSTITUTION"
|
||||
|
||||
msgid "image under note"
|
||||
msgstr "IMAGE UNDER NOTE"
|
||||
|
||||
|
@ -34,3 +34,20 @@ image url and alt
|
||||
.. figure:: img.png
|
||||
:alt: img
|
||||
|
||||
|
||||
image on substitution
|
||||
---------------------
|
||||
|
||||
.. |sub image| image:: i18n.png
|
||||
|
||||
image under note
|
||||
-----------------
|
||||
|
||||
.. note::
|
||||
|
||||
.. image:: i18n.png
|
||||
:alt: i18n under note
|
||||
|
||||
.. figure:: img.png
|
||||
:alt: img under note
|
||||
|
||||
|
@ -261,6 +261,18 @@ def test_text_builder(app, status, warning):
|
||||
u"[image: i18n][image]\n"
|
||||
u"\n"
|
||||
u" [image: img][image]\n"
|
||||
u"\n"
|
||||
u"\n"
|
||||
u"IMAGE ON SUBSTITUTION\n"
|
||||
u"=====================\n"
|
||||
u"\n"
|
||||
u"\n"
|
||||
u"IMAGE UNDER NOTE\n"
|
||||
u"================\n"
|
||||
u"\n"
|
||||
u"Note: [image: i18n under note][image]\n"
|
||||
u"\n"
|
||||
u" [image: img under note][image]\n"
|
||||
)
|
||||
yield assert_equal, result, expect
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user