Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions devel-common/src/sphinx_exts/substitution_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def condition(node):
return isinstance(node, (nodes.literal_block, nodes.literal))

for node in self.document.traverse(condition):
if _SUBSTITUTION_OPTION_NAME not in node:
if not node.get(_SUBSTITUTION_OPTION_NAME):
continue

# Some nodes don't have a direct document property, so walk up until we find it
Expand All @@ -76,11 +76,13 @@ def condition(node):
old_child = child
for name, value in substitution_defs.items():
replacement = value.astext()
child = nodes.Text(child.replace(f"|{name}|", replacement))
node.replace(old_child, child)
if isinstance(child, nodes.Text):
child = nodes.Text(child.replace(f"|{name}|", replacement))
if isinstance(node, nodes.Element):
node.replace(old_child, child)

# The highlighter checks this -- without this, it will refuse to apply highlighting
node.rawsource = node.astext()
node.rawsource = node.astext() # type: ignore[attr-defined]


def substitution_code_role(*args, **kwargs) -> tuple[list, list[Any]]:
Expand Down
Loading