From 17455d643ffb17cdf85d542b481fab94a2a93be9 Mon Sep 17 00:00:00 2001 From: Nicolas Peugnet Date: Mon, 15 Apr 2024 23:13:47 +0200 Subject: [PATCH] Fix rendering for parsed-literals Fixes #12287 --- sphinx/transforms/i18n.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sphinx/transforms/i18n.py b/sphinx/transforms/i18n.py index 1c0cf809b40..80c6e050135 100644 --- a/sphinx/transforms/i18n.py +++ b/sphinx/transforms/i18n.py @@ -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()