Skip to content

Commit

Permalink
Fix rendering for parsed-literals
Browse files Browse the repository at this point in the history
  • Loading branch information
n-peugnet committed Apr 15, 2024
1 parent 94b9b9d commit 17455d6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sphinx/transforms/i18n.py
Expand Up @@ -442,8 +442,10 @@ def apply(self, **kwargs: Any) -> None:
node['uri'] = msgstr
continue

# literalblock do not need to be parsed as they do not contain inline syntax
if isinstance(node, LITERAL_TYPE_NODES):
# literalblock do not need to be parsed as they do not contain inline syntax,
# except for parsed-literals, but they use the same node type, so we differentiate
# them based on their number of children.
if isinstance(node, LITERAL_TYPE_NODES) and len(node.children) <= 1:
node.children = [nodes.Text(msgstr)]
# for highlighting that expects .rawsource and .astext() are same.
node.rawsource = node.astext()
Expand Down

0 comments on commit 17455d6

Please sign in to comment.