mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #10504 from AA-Turner/fix-kbd-findall
Fix `findall` usage in `KeyboardTransform`
This commit is contained in:
commit
8aacb338aa
@ -40,7 +40,9 @@ 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.
|
||||
for node in list(self.document.findall(matcher)): # type: nodes.literal
|
||||
parts = self.pattern.split(node[-1].astext())
|
||||
if len(parts) == 1 or self.is_multiwords_key(parts):
|
||||
continue
|
||||
|
@ -0,0 +1,4 @@
|
||||
Regression test for issue 10495
|
||||
===============================
|
||||
|
||||
:kbd:`spanish - inquisition`
|
@ -48,3 +48,12 @@ def test_missing_reference_conditional_pending_xref(app, status, warning):
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<span class="n"><span class="pre">Age</span></span>' in content
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='transforms-post_transforms-keyboard',
|
||||
freshenv=True)
|
||||
def test_keyboard_hyphen_spaces(app):
|
||||
"""Regression test for issue 10495, we want no crash."""
|
||||
app.build()
|
||||
assert "spanish" in (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert "inquisition" in (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
Loading…
Reference in New Issue
Block a user