diff options
Diffstat (limited to 'sphinx/builders/html/transforms.py')
-rw-r--r-- | sphinx/builders/html/transforms.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sphinx/builders/html/transforms.py b/sphinx/builders/html/transforms.py index ea596cb4b..7f96c4e60 100644 --- a/sphinx/builders/html/transforms.py +++ b/sphinx/builders/html/transforms.py @@ -40,7 +40,10 @@ class KeyboardTransform(SphinxPostTransform): def run(self, **kwargs: Any) -> None: matcher = NodeMatcher(nodes.literal, classes=["kbd"]) - for node in self.document.findall(matcher): # type: nodes.literal + # this list must be pre-created as during iteration new nodes + # are added which match the condition in the NodeMatcher. + nodes_to_expand = list(self.document.findall(matcher)) + for node in nodes_to_expand: # type: nodes.literal parts = self.pattern.split(node[-1].astext()) if len(parts) == 1 or self.is_multiwords_key(parts): continue @@ -61,6 +64,7 @@ class KeyboardTransform(SphinxPostTransform): node += nodes.Text(sep) except IndexError: pass + _a = 1 def is_multiwords_key(self, parts: List[str]) -> bool: if len(parts) >= 3 and parts[1].strip() == '': |