Skip to content
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

translation fails when literal block is in a list #4913

Closed
nobodxbodon opened this issue Apr 29, 2018 · 2 comments
Closed

translation fails when literal block is in a list #4913

nobodxbodon opened this issue Apr 29, 2018 · 2 comments

Comments

@nobodxbodon
Copy link

Excuse me if this is a user issue, as I'm new to reStructuredText and Sphinx.
After putting the literal block into a list, this test case fails:
$ tox -e py36 tests/test_intl.py::test_additional_targets_should_be_translated

@tk0miya
Copy link
Member

tk0miya commented May 3, 2018

It seems docutils (reST parser) does not assign source filename to literal_block under bullet list:

from docutils import nodes
from docutils.core import publish_doctree


text = ("::\n"
        "\n"
        "  literal_block on root\n"
        "\n"
        "* ::\n"
        "\n"
        "    literal_block inside bullet_list\n")
doctree = publish_doctree(text, source_path='<string>')

# literal_block on root has correct source
assert isinstance(doctree[0], nodes.literal_block)
assert doctree[0].source == '<string>'
assert doctree[0].line == 3

# bullet_list also has correct source
assert isinstance(doctree[1], nodes.bullet_list)
assert doctree[1].source == '<string>'
assert doctree[1].line == 5

# but literal_block inside bullet_list does not
assert isinstance(doctree[1][0][0], nodes.literal_block)
assert doctree[1][0][0].source == '<string>'
assert doctree[1][0][0].line == 7
$ python test_literal_block.py
Traceback (most recent call last):
  File "test_literal_block.py", line 26, in <module>
    assert doctree[1][0][0].source == '<string>'
AssertionError

@tk0miya tk0miya added this to the 1.7.5 milestone May 6, 2018
tk0miya added a commit to tk0miya/sphinx that referenced this issue May 7, 2018
tk0miya added a commit that referenced this issue May 12, 2018
…_list

Fix #4913: i18n: literal blocks in bullet list are not translated
@tk0miya
Copy link
Member

tk0miya commented May 12, 2018

Fixed by #4943

@tk0miya tk0miya closed this as completed May 12, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants