mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix findall
usage in KeyboardTransform
This commit is contained in:
parent
113e1d8759
commit
04b84e82a0
@ -40,7 +40,10 @@ class KeyboardTransform(SphinxPostTransform):
|
|||||||
|
|
||||||
def run(self, **kwargs: Any) -> None:
|
def run(self, **kwargs: Any) -> None:
|
||||||
matcher = NodeMatcher(nodes.literal, classes=["kbd"])
|
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())
|
parts = self.pattern.split(node[-1].astext())
|
||||||
if len(parts) == 1 or self.is_multiwords_key(parts):
|
if len(parts) == 1 or self.is_multiwords_key(parts):
|
||||||
continue
|
continue
|
||||||
@ -61,6 +64,7 @@ class KeyboardTransform(SphinxPostTransform):
|
|||||||
node += nodes.Text(sep)
|
node += nodes.Text(sep)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
|
_a = 1
|
||||||
|
|
||||||
def is_multiwords_key(self, parts: List[str]) -> bool:
|
def is_multiwords_key(self, parts: List[str]) -> bool:
|
||||||
if len(parts) >= 3 and parts[1].strip() == '':
|
if len(parts) >= 3 and parts[1].strip() == '':
|
||||||
|
Loading…
Reference in New Issue
Block a user