Fix #4913: i18n: literal blocks in bullet list are not translated

This commit is contained in:
Takeshi KOMIYA 2018-05-04 02:30:16 +09:00
parent 2d42753acd
commit 5c56c99dfd
5 changed files with 31 additions and 0 deletions

View File

@ -19,6 +19,7 @@ Bugs fixed
* #4924: html search: Upper characters problem in any other languages
* #4932: apidoc: some subpackage is ignored if sibling subpackage contains a
module starting with underscore
* #4913: i18n: literal blocks in bullet list are not translated
Testing
--------

View File

@ -53,6 +53,10 @@ def apply_source_workaround(node):
node.rawsource = re.sub(r'\s*:\s*%s' % re.escape(classifier.astext()),
'', node.rawsource)
# workaround: literal_block under bullet list (#4913)
if isinstance(node, nodes.literal_block) and node.source is None:
node.source = find_source_node(node)
# workaround: recommonmark-0.2.0 doesn't set rawsource attribute
if not node.rawsource:
node.rawsource = node.astext()

View File

@ -72,6 +72,11 @@ msgstr ""
" return 0;\n"
"}"
msgid "literal-block\n"
"in list"
msgstr "LITERAL-BLOCK\n"
"IN LIST"
msgid "doctest blocks"
msgstr "DOCTEST-BLOCKS"

View File

@ -44,6 +44,11 @@ code blocks
}
* ::
literal-block
in list
doctest blocks
==============

View File

@ -1000,6 +1000,14 @@ def test_additional_targets_should_not_be_translated(app):
"""<span class="cpf">&lt;stdio.h&gt;</span>""")
assert_count(expected_expr, result, 1)
# literal block in list item should not be translated
expected_expr = ("""<span class="n">literal</span>"""
"""<span class="o">-</span>"""
"""<span class="n">block</span>\n"""
"""<span class="k">in</span> """
"""<span class="n">list</span>""")
assert_count(expected_expr, result, 1)
# doctest block should not be translated but be highlighted
expected_expr = (
"""<span class="gp">&gt;&gt;&gt; </span>"""
@ -1066,6 +1074,14 @@ def test_additional_targets_should_be_translated(app):
"""<span class="cpf">&lt;STDIO.H&gt;</span>""")
assert_count(expected_expr, result, 1)
# literal block in list item should be translated
expected_expr = ("""<span class="no">LITERAL</span>"""
"""<span class="o">-</span>"""
"""<span class="no">BLOCK</span>\n"""
"""<span class="no">IN</span> """
"""<span class="no">LIST</span>""")
assert_count(expected_expr, result, 1)
# doctest block should not be translated but be highlighted
expected_expr = (
"""<span class="gp">&gt;&gt;&gt; </span>"""