Merge pull request #4943 from tk0miya/4913_literal_block_under_bullet_list

Fix #4913: i18n: literal blocks in bullet list are not translated
This commit is contained in:
Takeshi KOMIYA 2018-05-12 23:22:15 +09:00 committed by GitHub
commit 1e631b3fa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 0 deletions

View File

@ -21,6 +21,7 @@ Bugs fixed
module starting with underscore
* #4938, #4939: i18n doesn't handle node.title correctly tat used for contents, topic,
admonition, table and section.
* #4913: i18n: literal blocks in bullet list are not translated
Testing
--------

View File

@ -58,6 +58,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

@ -1063,6 +1063,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>"""
@ -1129,6 +1137,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>"""