mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Define `\menuselection
and
\accelerator
macros to redefine the style of
menuselection` roles.
This commit is contained in:
parent
e8cbd5a750
commit
cea81e7a70
1
CHANGES
1
CHANGES
@ -14,6 +14,7 @@ Features added
|
||||
in early stage of preambles.
|
||||
* PR #2340: Math extension: support alignment of multiple equations for MathJAX.
|
||||
* #2338: Define ``\titlereference`` macro to redefine the style of `title-reference` roles.
|
||||
* Define ``\menuselection`` and ``\accelerator`` macros to redefine the style of `menuselection` roles.
|
||||
|
||||
Bugs fixed
|
||||
----------
|
||||
|
@ -147,6 +147,8 @@
|
||||
\newcommand{\email}[1]{\textsf{#1}}
|
||||
\newcommand{\tablecontinued}[1]{\textsf{#1}}
|
||||
\newcommand{\titlereference}[1]{\emph{#1}}
|
||||
\newcommand{\menuselection}[1]{\emph{#1}}
|
||||
\newcommand{\accelerator}[1]{\underline{#1}}
|
||||
|
||||
% Redefine the Verbatim environment to allow border and background colors.
|
||||
% The original environment is still used for verbatims within tables.
|
||||
|
@ -1925,10 +1925,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
def visit_inline(self, node):
|
||||
classes = node.get('classes', [])
|
||||
if classes in [['menuselection'], ['guilabel']]:
|
||||
self.body.append(r'\emph{')
|
||||
self.body.append(r'\menuselection{')
|
||||
self.context.append('}')
|
||||
elif classes in [['accelerator']]:
|
||||
self.body.append(r'\underline{')
|
||||
self.body.append(r'\accelerator{')
|
||||
self.context.append('}')
|
||||
elif classes and not self.in_title:
|
||||
self.body.append(r'\DUrole{%s}{' % ','.join(classes))
|
||||
|
@ -103,13 +103,13 @@ def test_inline():
|
||||
# interpolation of arrows in menuselection
|
||||
yield (verify, ':menuselection:`a --> b`',
|
||||
u'<p><span class="menuselection">a \N{TRIANGULAR BULLET} b</span></p>',
|
||||
'\\emph{a \\(\\rightarrow\\) b}')
|
||||
'\\menuselection{a \\(\\rightarrow\\) b}')
|
||||
|
||||
# interpolation of ampersands in guilabel/menuselection
|
||||
yield (verify, ':guilabel:`&Foo -&&- &Bar`',
|
||||
u'<p><span class="guilabel"><span class="accelerator">F</span>oo '
|
||||
'-&- <span class="accelerator">B</span>ar</span></p>',
|
||||
r'\emph{\underline{F}oo -\&- \underline{B}ar}')
|
||||
r'\menuselection{\accelerator{F}oo -\&- \accelerator{B}ar}')
|
||||
|
||||
# non-interpolation of dashes in option role
|
||||
yield (verify_re, ':option:`--with-option`',
|
||||
|
Loading…
Reference in New Issue
Block a user