Fix #2629. Add new config option `latex_keep_old_macro_names`

The cause of the issue was a clash about ``\titleref`` macro being already
defined in memoir class context. To avoid similar problems, this makes
the text styling macros

  ``\strong``, ``\code``, ``\bfcode``, ``\email``, ``\tablecontinued``,
  ``\titleref``, ``\menuselection``, ``\accelerator``, ``\crossref``,
  ``\termref``, ``\optional``,

also available with ``\sphinx`` prefix, with a conf.py boolean option to
let sphinx.sty only define ``\sphinx``-prefixed macros. As default value
is False, backwards compatibility is maintained.

On this occasion, some internal non-public macros have been renamed with
prefix ``\spx@``. The command

    find . -name '*.sty' -exec grep -l \\\\spx@ {} \;

has been executed in TeXLive 2015 and 2016 installations to check no
package defines macros starting with ``\spx@``.

Some internal macros having public names (because they are written by
latex.py into the body of the latex document) have been renamed to have
``\sphinx`` prefix. The macros in sphinx.sty starting with \py@, or \DU,
or \PYG have not been modified. Similarly ``\release``, ``\version``,
``\releasename``, etc... have not been renamed.
This commit is contained in:
jfbu
2016-06-12 19:35:47 +02:00
parent 8608387585
commit 5510653d6e
9 changed files with 235 additions and 177 deletions

View File

@@ -93,32 +93,32 @@ def test_inline():
# correct interpretation of code with whitespace
_html = ('<p><code class="(samp )?docutils literal"><span class="pre">'
'code</span>&nbsp;&nbsp; <span class="pre">sample</span></code></p>')
yield verify_re, '``code sample``', _html, r'\\code{code sample}'
yield verify_re, ':samp:`code sample`', _html, r'\\code{code sample}'
yield verify_re, '``code sample``', _html, r'\\sphinxcode{code sample}'
yield verify_re, ':samp:`code sample`', _html, r'\\sphinxcode{code sample}'
# interpolation of braces in samp and file roles (HTML only)
yield (verify, ':samp:`a{b}c`',
'<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>',
'\\code{a\\emph{b}c}')
'\\sphinxcode{a\\emph{b}c}')
# interpolation of arrows in menuselection
yield (verify, ':menuselection:`a --> b`',
u'<p><span class="menuselection">a \N{TRIANGULAR BULLET} b</span></p>',
'\\menuselection{a \\(\\rightarrow\\) b}')
'\\sphinxmenuselection{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'\menuselection{\accelerator{F}oo -\&- \accelerator{B}ar}')
r'\sphinxmenuselection{\sphinxaccelerator{F}oo -\&- \sphinxaccelerator{B}ar}')
# non-interpolation of dashes in option role
yield (verify_re, ':option:`--with-option`',
'<p><code( class="xref std std-option docutils literal")?>'
'<span class="pre">--with-option</span></code></p>$',
r'\\code{-{-}with-option}$')
r'\\sphinxcode{-{-}with-option}$')
# verify smarty-pants quotes
yield verify, '"John"', '<p>&#8220;John&#8221;</p>', "``John''"
@@ -126,7 +126,7 @@ def test_inline():
yield (verify, '``"John"``',
'<p><code class="docutils literal"><span class="pre">'
'&quot;John&quot;</span></code></p>',
'\\code{"John"}')
'\\sphinxcode{"John"}')
# verify classes for inline roles
yield (verify, ':manpage:`mp(1)`',