diff --git a/CHANGES b/CHANGES index 49b0ca941..0ae8cb26d 100644 --- a/CHANGES +++ b/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) ==================================== diff --git a/sphinx/transforms.py b/sphinx/transforms.py index cb4a5779b..3281541c0 100644 --- a/sphinx/transforms.py +++ b/sphinx/transforms.py @@ -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) diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index e4a2fd73b..b3f7efa8e 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -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` diff --git a/tests/roots/test-intl/figure.po b/tests/roots/test-intl/figure.po index cbd9c8837..449b15e3f 100644 --- a/tests/roots/test-intl/figure.po +++ b/tests/roots/test-intl/figure.po @@ -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" + diff --git a/tests/roots/test-intl/figure.txt b/tests/roots/test-intl/figure.txt index b639a4ac1..633e12ee8 100644 --- a/tests/roots/test-intl/figure.txt +++ b/tests/roots/test-intl/figure.txt @@ -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 + diff --git a/tests/test_intl.py b/tests/test_intl.py index b31f1678b..4fac62c21 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -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