Merge pull request #7255 from tk0miya/7005_kbd_for_latex

Add LaTeX styling hook for :kbd: role
This commit is contained in:
Takeshi KOMIYA 2020-03-06 00:49:28 +09:00 committed by GitHub
commit 39a191294e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 0 deletions

View File

@ -68,6 +68,7 @@ Features added
``no-scaled-link`` class ``no-scaled-link`` class
* #7144: Add CSS class indicating its domain for each desc node * #7144: Add CSS class indicating its domain for each desc node
* #7211: latex: Use babel for Chinese document when using XeLaTeX * #7211: latex: Use babel for Chinese document when using XeLaTeX
* #7005: LaTeX: Add LaTeX styling macro for :rst:role:`kbd` role
* #7220: genindex: Show "main" index entries at first * #7220: genindex: Show "main" index entries at first
* #7103: linkcheck: writes all links to ``output.json`` * #7103: linkcheck: writes all links to ``output.json``
* #7025: html search: full text search can be disabled for individual document * #7025: html search: full text search can be disabled for individual document

View File

@ -817,6 +817,8 @@ Macros
multiple paragraphs in header cells of tables. multiple paragraphs in header cells of tables.
.. versionadded:: 1.6.3 .. versionadded:: 1.6.3
``\sphinxstylecodecontinued`` and ``\sphinxstylecodecontinues``. ``\sphinxstylecodecontinued`` and ``\sphinxstylecodecontinues``.
.. versionadded:: 3.0
``\sphinxkeyboard``
- ``\sphinxtableofcontents``: it is a - ``\sphinxtableofcontents``: it is a
wrapper (defined differently in :file:`sphinxhowto.cls` and in wrapper (defined differently in :file:`sphinxhowto.cls` and in
:file:`sphinxmanual.cls`) of standard ``\tableofcontents``. The macro :file:`sphinxmanual.cls`) of standard ``\tableofcontents``. The macro

View File

@ -1837,6 +1837,7 @@
\protected\def\sphinxtitleref#1{\emph{#1}} \protected\def\sphinxtitleref#1{\emph{#1}}
\protected\def\sphinxmenuselection#1{\emph{#1}} \protected\def\sphinxmenuselection#1{\emph{#1}}
\protected\def\sphinxguilabel#1{\emph{#1}} \protected\def\sphinxguilabel#1{\emph{#1}}
\protected\def\sphinxkeyboard#1{\sphinxcode{#1}}
\protected\def\sphinxaccelerator#1{\underline{#1}} \protected\def\sphinxaccelerator#1{\underline{#1}}
\protected\def\sphinxcrossref#1{\emph{#1}} \protected\def\sphinxcrossref#1{\emph{#1}}
\protected\def\sphinxtermref#1{\emph{#1}} \protected\def\sphinxtermref#1{\emph{#1}}

View File

@ -1720,6 +1720,8 @@ class LaTeXTranslator(SphinxTranslator):
def visit_literal(self, node: Element) -> None: def visit_literal(self, node: Element) -> None:
if self.in_title: if self.in_title:
self.body.append(r'\sphinxstyleliteralintitle{\sphinxupquote{') self.body.append(r'\sphinxstyleliteralintitle{\sphinxupquote{')
elif 'kbd' in node['classes']:
self.body.append(r'\sphinxkeyboard{\sphinxupquote{')
else: else:
self.body.append(r'\sphinxcode{\sphinxupquote{') self.body.append(r'\sphinxcode{\sphinxupquote{')

View File

@ -230,6 +230,13 @@ def get_verifier(verify, verify_re):
'<p><span class="guilabel">Foo</span></p>', '<p><span class="guilabel">Foo</span></p>',
r'\sphinxguilabel{Foo}', r'\sphinxguilabel{Foo}',
), ),
(
# kbd role
'verify',
':kbd:`space`',
'<p><kbd class="kbd docutils literal notranslate">space</kbd></p>',
'\\sphinxkeyboard{\\sphinxupquote{space}}',
),
( (
# non-interpolation of dashes in option role # non-interpolation of dashes in option role
'verify_re', 'verify_re',