sphinx-doc / sphinx-doc/sphinx
Regression: :kbd: in Sphinx 8.2
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
For this reStructuredText:
:kbd:`Control-x`
Sphinx < 8.2 produces these doctree elements (pseudoXML):
<literal classes="kbd">
Control-x
Since Sphinx 8.2, the following is produced:
<literal classes="kbd">
Control
-
<literal classes="kbd">
x
The result is that the hyphen cannot be styled properly, as it is not indicated to be related to the keyboard shortcut. Perhaps the entire shortcut could be wrapped in an inline block with a particular class?
How to Reproduce
N/A
Environment Information
Platform: darwin; (macOS-15.6.1-arm64-arm-64bit-Mach-O)
Python version: 3.13.7 (main, Aug 23 2025, 23:13:28) [Clang 17.0.0 (clang-1700.0.13.5)])
Python implementation: CPython
Sphinx version: 8.2.3
Docutils version: 0.20.1
Jinja2 version: 3.1.4
Pygments version: 2.18.0
Sphinx extensions
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided :kbd:Control-x`` input with Sphinx 8.2.3 and inspect the generated pseudoXML for the inline elements. Trace the kbd role handling, then add a regression test showing that the shortcut and its hyphen remain grouped and styled as one keyboard sequence.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100