Define `\menuselection and \accelerator macros to redefine the style of menuselection` roles.

This commit is contained in:
Takeshi KOMIYA 2016-02-23 14:38:34 +09:00
parent e8cbd5a750
commit cea81e7a70
4 changed files with 7 additions and 4 deletions

View File

@ -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
----------

View File

@ -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.

View File

@ -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))

View File

@ -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 '
'-&amp;- <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`',