Split out fancy LaTeX macros from `\sphinxcode into \sphinxupquote`

Since #2627 (1.4.4), `\code`, and then again at #3116 (1.5)
`\sphinxcode` which is the new name has become more complicated than the
original `\texttt{#1}`. This was to obtain straight quotes in PDF output,
and to allow long inline literals to break across lines.

This means though that users who want to customize `\sphinxcode`, for
example to not only do `\texttt` but to use some colour, have to copy
about 10 lines of complicated LaTeX macros which should be not modified
in any way. This commit moves all the code out of `\sphinxcode` into a
separate macro `\sphinxupquote`.

The LaTeX writer will output `\sphinxcode{\sphinxupquote{foo}}` in place
of former `\sphinxcode{foo}`. Moving the `\texttt` from innermost to
outermost level is with no consequence.
This commit is contained in:
jfbu
2018-01-02 23:11:19 +01:00
parent d4728d0cb8
commit 309f38a91f
3 changed files with 27 additions and 26 deletions

View File

@@ -135,7 +135,7 @@ def get_verifier(verify, verify_re):
'``code sample``',
('<p><code class="(samp )?docutils literal"><span class="pre">'
'code</span>&#160;&#160; <span class="pre">sample</span></code></p>'),
r'\\sphinxcode{code sample}',
r'\\sphinxcode{\\sphinxupquote{code sample}}',
),
(
# correct interpretation of code with whitespace
@@ -143,7 +143,7 @@ def get_verifier(verify, verify_re):
':samp:`code sample`',
('<p><code class="(samp )?docutils literal"><span class="pre">'
'code</span>&#160;&#160; <span class="pre">sample</span></code></p>'),
r'\\sphinxcode{code sample}',
r'\\sphinxcode{\\sphinxupquote{code sample}}',
),
(
# interpolation of braces in samp and file roles (HTML only)
@@ -152,7 +152,7 @@ def get_verifier(verify, verify_re):
('<p><code class="samp docutils literal"><span class="pre">a</span>'
'<em><span class="pre">b</span></em>'
'<span class="pre">c</span></code></p>'),
'\\sphinxcode{a\\sphinxstyleemphasis{b}c}',
'\\sphinxcode{\\sphinxupquote{a\\sphinxstyleemphasis{b}c}}',
),
(
# interpolation of arrows in menuselection
@@ -175,7 +175,7 @@ def get_verifier(verify, verify_re):
':option:`--with-option`',
('<p><code( class="xref std std-option docutils literal")?>'
'<span class="pre">--with-option</span></code></p>$'),
r'\\sphinxcode{-{-}with-option}$',
r'\\sphinxcode{\\sphinxupquote{-{-}with-option}}$',
),
(
# verify smarty-pants quotes
@@ -190,14 +190,14 @@ def get_verifier(verify, verify_re):
'``"John"``',
('<p><code class="docutils literal"><span class="pre">'
'&quot;John&quot;</span></code></p>'),
'\\sphinxcode{"John"}',
'\\sphinxcode{\\sphinxupquote{"John"}}',
),
(
# verify classes for inline roles
'verify',
':manpage:`mp(1)`',
'<p><em class="manpage">mp(1)</em></p>',
'\\sphinxstyleliteralemphasis{mp(1)}',
'\\sphinxstyleliteralemphasis{\\sphinxupquote{mp(1)}}',
),
(
# correct escaping in normal mode