From d829a99977111e592d4cad1ddf1f37af69910f80 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 28 Sep 2024 17:54:43 +0200 Subject: [PATCH] Fix kbd tag HTML rendering Commit c921c124e (docs: use canonical key names in :kbd: tags, 2024-04-13) removed the box highlighting from elements like :kbd:`ctrl-c`. This is because Sphinx for some reason converts this into ctrl - c which results in duplicate boxes. (See https://github.com/sphinx-doc/sphinx/issues/7530) Our current style looks a bit ugly (it's definitely worse than github's rendering at https://github.com/fish-shell/fish-shell/blob/master/CHANGELOG.rst). Let's restore the old style but make sure to only apply it only to the outermost kbd element. While at it, use the same monospace font as for inline code. --- doc_src/python_docs_theme/static/pydoctheme.css | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc_src/python_docs_theme/static/pydoctheme.css b/doc_src/python_docs_theme/static/pydoctheme.css index efbfd8294..b6b00ad64 100644 --- a/doc_src/python_docs_theme/static/pydoctheme.css +++ b/doc_src/python_docs_theme/static/pydoctheme.css @@ -439,7 +439,7 @@ code { margin-right: 3px; } -tt, code, pre, dl > dt span ~ em, #synopsis p, #synopsis code, .command, button { +tt, code, kbd, pre, dl > dt span ~ em, #synopsis p, #synopsis code, .command, button { /* Pick a monospace font. ui-monospace is the monospace version of system-ui - the system's monospace font. Unfortunately it's barely supported anywhere (at time of writing only Safari does!), @@ -693,8 +693,12 @@ div.documentwrapper { /* Color based on the Generic.Prompt (.gp) class from pygments.css. */ .prompt { color: #8f7902; } -kbd { +kbd.compound, :not(kbd.compound) > kbd { background-color: var(--td-background); + border: 1px solid; + border-color: var(--sidebar-border-color); + border-radius: .2em; + padding: 0.1em 0.3em; } div.body a { @@ -728,7 +732,7 @@ div.body a { box-shadow: 0 0 5px 1px #000; } - kbd { + kbd.compound, :not(kbd.compound) > kbd { box-shadow: 0.1em 0.1em 0.2em rgba(100,100,100,0.1); color: #FFF; }