From 8e5f4e561645d906b9da6845acb991fcf3dd4eac Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 30 Dec 2020 20:36:06 +0900 Subject: [PATCH] Close #8619: html: kbd role generates customizable HTML tags for compound keys --- CHANGES | 1 + sphinx/builders/html/transforms.py | 3 ++- tests/test_markup.py | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 3a9f527ad3d..eb8adbd3d12 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,7 @@ Features added * #8022: autodoc: autodata and autoattribute directives does not show right-hand value of the variable if docstring contains ``:meta hide-value:`` in info-field-list +* #8619: html: kbd role generates customizable HTML tags for compound keys * #8132: Add :confval:`project_copyright` as an alias of :confval:`copyright` Bugs fixed diff --git a/sphinx/builders/html/transforms.py b/sphinx/builders/html/transforms.py index c91da57e993..2094b384802 100644 --- a/sphinx/builders/html/transforms.py +++ b/sphinx/builders/html/transforms.py @@ -28,7 +28,7 @@ class KeyboardTransform(SphinxPostTransform): After:: - + Control - @@ -46,6 +46,7 @@ def run(self, **kwargs: Any) -> None: if len(parts) == 1: continue + node['classes'].append('compound') node.pop() while parts: key = parts.pop(0) diff --git a/tests/test_markup.py b/tests/test_markup.py index a2bcb2dc1fe..7d55dde9fd6 100644 --- a/tests/test_markup.py +++ b/tests/test_markup.py @@ -244,7 +244,7 @@ def get(name): # kbd role 'verify', ':kbd:`Control+X`', - ('

' + ('

' 'Control' '+' 'X' @@ -255,7 +255,7 @@ def get(name): # kbd role 'verify', ':kbd:`M-x M-s`', - ('

' + ('

' 'M' '-' 'x'