summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES6
-rw-r--r--doc/config.rst15
-rw-r--r--sphinx/config.py1
-rw-r--r--sphinx/quickstart.py6
-rw-r--r--sphinx/texinputs/sphinx.sty265
-rw-r--r--sphinx/writers/latex.py52
-rw-r--r--tests/test_build_latex.py31
-rw-r--r--tests/test_directive_code.py24
-rw-r--r--tests/test_markup.py14
9 files changed, 236 insertions, 178 deletions
diff --git a/CHANGES b/CHANGES
index 890d9bd59..20d49c00d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,10 +1,16 @@
Release 1.4.5 (in development)
==============================
+Features added
+--------------
+
+* new config option ``latex_keep_old_macro_names``, defaults to True. If False, let macros (for text styling) be defined only with ``\sphinx``-prefixed names.
+
Bugs fixed
----------
* #2676: (latex) Error with verbatim text in captions since Sphinx 1.4.4
+* #2629: memoir class crashes LaTeX. Fixed ``by latex_keep_old_macro_names=False`` (ref 2675)
Release 1.4.4 (released Jun 12, 2016)
diff --git a/doc/config.rst b/doc/config.rst
index b45f9df7c..b579d7e2b 100644
--- a/doc/config.rst
+++ b/doc/config.rst
@@ -1565,6 +1565,21 @@ These options influence LaTeX output.
value selected the ``'inline'`` display. For backwards compatibility,
``True`` is still accepted.
+.. confval:: latex_keep_old_macro_names
+
+ If ``True`` (default) the ``\strong``, ``\code``, ``\bfcode``, ``\email``,
+ ``\tablecontinued``, ``\titleref``, ``\menuselection``, ``\accelerator``,
+ ``\crossref``, ``\termref``, and ``\optional`` text styling macros are
+ pre-defined by Sphinx and may be user-customized by some
+ ``\renewcommand``'s inserted either via ``'preamble'`` key or :dudir:`raw
+ <raw-data-pass-through>` directive. If ``False``, only ``\sphinxstrong``,
+ etc... macros are defined (and may be redefined by user). Setting to
+ ``False`` may help solve macro name conflicts caused by user-added latex
+ packages.
+
+ .. versionadded:: 1.4.5
+
+
.. confval:: latex_elements
.. versionadded:: 0.5
diff --git a/sphinx/config.py b/sphinx/config.py
index 9cbf655f8..9527d9a8d 100644
--- a/sphinx/config.py
+++ b/sphinx/config.py
@@ -209,6 +209,7 @@ class Config(object):
None),
latex_logo = (None, None, string_classes),
latex_appendices = ([], None),
+ latex_keep_old_macro_names = (True, None),
# now deprecated - use latex_toplevel_sectioning
latex_use_parts = (False, None),
latex_toplevel_sectioning = (None, None, [str]),
diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py
index 1f14c0d09..4680fecd4 100644
--- a/sphinx/quickstart.py
+++ b/sphinx/quickstart.py
@@ -359,6 +359,12 @@ latex_documents = [
#
# latex_appendices = []
+# It false, will not define \strong, \code, \titleref, \crossref ... but only
+# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added
+# packages.
+#
+# latex_keep_old_macro_names = True
+
# If false, no module index is generated.
#
# latex_domain_indices = True
diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty
index 1c98654b3..1cec7481e 100644
--- a/sphinx/texinputs/sphinx.sty
+++ b/sphinx/texinputs/sphinx.sty
@@ -20,7 +20,7 @@
\RequirePackage{makeidx}
% For framing code-blocks and warning type notices, and shadowing topics
\RequirePackage{framed}
-\newif\ifSphinx@inframed % flag set if we are in a framed environment
+\newif\ifspx@inframed % flag set if we are in a framed environment
% ifthen not used anymore and will be removed at Sphinx-1.5
\RequirePackage{ifthen}
% The xcolor package draws better fcolorboxes around verbatim code
@@ -69,7 +69,7 @@
\RequirePackage{graphicx}
% for PDF output, use colors and maximal compression
-\newif\ifsphinxpdfoutput\sphinxpdfoutputfalse
+\newif\ifsphinxpdfoutput % used in \maketitle
\ifx\pdfoutput\undefined\else\ifcase\pdfoutput
\let\py@NormalColor\relax
\let\py@TitleColor\relax
@@ -114,6 +114,7 @@
% Use this to set the font family for headers and other decor:
\newcommand{\py@HeaderFamily}{\sffamily\bfseries}
+\newcommand{\sphinxSetHeaderFamily}[1]{\renewcommand{\py@HeaderFamily}{#1}}
% Redefine the 'normal' header/footer style when using "fancyhdr" package:
\@ifundefined{fancyhf}{}{
@@ -143,23 +144,23 @@
}
% Some custom font markup commands.
-%
-\newcommand{\strong}[1]{{\textbf{#1}}}
-% let \code and \bfcode use straight quotes. \@noligs patched by upquote,
+% *** the macros without \sphinx prefix are still defined at bottom of file ***
+\newcommand{\sphinxstrong}[1]{{\textbf{#1}}}
+% let \sphinxcode and \sphinxbfcode use straight quotes. \@noligs patched by upquote,
% but needs protection in "moving arguments" such as for captions.
-\newcommand{\code}{}% raise error if exists already
-\DeclareRobustCommand{\code}[1]{{\@noligs\scantokens{\texttt{#1}}}}
-\newcommand{\bfcode}[1]{\code{\bfseries#1}}
-\newcommand{\email}[1]{\textsf{#1}}
-\newcommand{\tablecontinued}[1]{\textsf{#1}}
-\newcommand{\titleref}[1]{\emph{#1}}
-\newcommand{\menuselection}[1]{\emph{#1}}
-\newcommand{\accelerator}[1]{\underline{#1}}
-\newcommand{\crossref}[1]{\emph{#1}}
-\newcommand{\termref}[1]{\emph{#1}}
-
+% Use \scantokens to handle e.g. \item[{\sphinxcode{'fontenc'}}]
+\DeclareRobustCommand{\sphinxcode}[1]{{\@noligs\scantokens{\texttt{#1}}}}
+\newcommand{\sphinxbfcode}[1]{\sphinxcode{\bfseries#1}}
+\newcommand{\sphinxemail}[1]{\textsf{#1}}
+\newcommand{\sphinxtablecontinued}[1]{\textsf{#1}}
+\newcommand{\sphinxtitleref}[1]{\emph{#1}}
+\newcommand{\sphinxmenuselection}[1]{\emph{#1}}
+\newcommand{\sphinxaccelerator}[1]{\underline{#1}}
+\newcommand{\sphinxcrossref}[1]{\emph{#1}}
+\newcommand{\sphinxtermref}[1]{\emph{#1}}
+
+% miscellaneous related to footnotes
\newcommand*{\sphinxAtStartFootnote}{\mbox{ }}
-
% Support large numbered footnotes in minipage (cf. admonitions)
\def\thempfootnote{\arabic{mpfootnote}}
@@ -169,8 +170,8 @@
\let\OriginalVerbatim=\Verbatim
\let\endOriginalVerbatim=\endVerbatim
-\newcommand\Sphinx@colorbox [2]{%
-% #1 will be \fcolorbox or, for first part of frame: \Sphinx@fcolorbox
+\newcommand\spx@colorbox [2]{%
+% #1 will be \fcolorbox or, for first part of frame: \spx@fcolorbox
% let the framing obey the current indentation (adapted from framed.sty's code).
\hskip\@totalleftmargin
\hskip-\fboxsep\hskip-\fboxrule
@@ -179,47 +180,46 @@
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth
}
% use of \color@b@x here is compatible with both xcolor.sty and color.sty
-\def\Sphinx@fcolorbox #1#2%
- {\color@b@x {\fboxsep\z@\color{#1}\Sphinx@VerbatimFBox}{\color{#2}}}%
+\def\spx@fcolorbox #1#2%
+ {\color@b@x {\fboxsep\z@\color{#1}\spx@VerbatimFBox}{\color{#2}}}%
-% The title is specified from outside as macro \SphinxVerbatimTitle.
-% \SphinxVerbatimTitle is reset to empty after each use of Verbatim.
-\newcommand*\SphinxVerbatimTitle {}
+% The title is specified from outside as macro \sphinxVerbatimTitle.
+% \sphinxVerbatimTitle is reset to empty after each use of Verbatim.
+\newcommand*\sphinxVerbatimTitle {}
% Holder macro for labels of literal blocks. Set-up by LaTeX writer.
-\newcommand*\SphinxLiteralBlockLabel {}
-\newcommand*\SphinxSetupCaptionForVerbatim [2]
+\newcommand*\sphinxLiteralBlockLabel {}
+\newcommand*\sphinxSetupCaptionForVerbatim [2]
{%
- \needspace{\literalblockneedspace}%
-% insert a \label via \SphinxLiteralBlockLabel
+ \needspace{\sphinxliteralblockneedspace}%
+% insert a \label via \sphinxLiteralBlockLabel
% reset to normal the color for the literal block caption
% the caption inserts \abovecaptionskip whitespace above itself (usually 10pt)
% there is also \belowcaptionskip but it is usually zero, hence the \smallskip
- \def\SphinxVerbatimTitle
- {\py@NormalColor\captionof{#1}{\SphinxLiteralBlockLabel #2}\smallskip }%
+ \def\sphinxVerbatimTitle
+ {\py@NormalColor\captionof{#1}{\sphinxLiteralBlockLabel #2}\smallskip }%
}
% Inspired and adapted from framed.sty's \CustomFBox with extra handling
% of a non separable by pagebreak caption, and controlled counter stepping.
-\newif\ifSphinx@myfirstframedpass
-
-\long\def\Sphinx@VerbatimFBox#1{%
+\newif\ifspx@myfirstframedpass
+\long\def\spx@VerbatimFBox#1{%
\leavevmode
\begingroup
% framed.sty does some measuring but this macro adds possibly a caption
% use amsmath conditional to inhibit the caption counter stepping after
% first pass
- \ifSphinx@myfirstframedpass\else\firstchoice@false\fi
+ \ifspx@myfirstframedpass\else\firstchoice@false\fi
\setbox\@tempboxa\hbox{\kern\fboxsep{#1}\kern\fboxsep}%
\hbox
{\lower\dimexpr\fboxrule+\fboxsep+\dp\@tempboxa
\hbox{%
- \vbox{\ifx\SphinxVerbatimTitle\empty\else
+ \vbox{\ifx\sphinxVerbatimTitle\empty\else
% add the caption in a centered way above possibly indented frame
% hide its width from framed.sty's measuring step
% note that the caption brings \abovecaptionskip top vertical space
\moveright\dimexpr\fboxrule+.5\wd\@tempboxa
\hb@xt@\z@{\hss\begin{minipage}{\wd\@tempboxa}%
- \SphinxVerbatimTitle
+ \sphinxVerbatimTitle
\end{minipage}\hss}\fi
% draw frame border _latest_ to avoid pdf viewer issue
\kern\fboxrule
@@ -236,51 +236,51 @@
\hrule\@height\fboxrule}%
}}%
\endgroup
- \global\Sphinx@myfirstframedpassfalse
+ \global\spx@myfirstframedpassfalse
}
% For linebreaks inside Verbatim environment from package fancyvrb.
-\newbox\Sphinxcontinuationbox
-\newbox\Sphinxvisiblespacebox
+\newbox\sphinxcontinuationbox
+\newbox\sphinxvisiblespacebox
% These are user customizable e.g. from latex_elements's preamble key.
% Use of \textvisiblespace for compatibility with XeTeX/LuaTeX/fontspec.
-\newcommand*\Sphinxvisiblespace {\textcolor{red}{\textvisiblespace}}
-\newcommand*\Sphinxcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}}
-\newcommand*\Sphinxcontinuationindent {3ex }
-\newcommand*\Sphinxafterbreak {\kern\Sphinxcontinuationindent\copy\Sphinxcontinuationbox}
+\newcommand*\sphinxvisiblespace {\textcolor{red}{\textvisiblespace}}
+\newcommand*\sphinxcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}}
+\newcommand*\sphinxcontinuationindent {3ex }
+\newcommand*\sphinxafterbreak {\kern\sphinxcontinuationindent\copy\sphinxcontinuationbox}
% Take advantage of the already applied Pygments mark-up to insert
% potential linebreaks for TeX processing.
% {, <, #, %, $, ' and ": go to next line.
% _, }, ^, &, >, - and ~: stay at end of broken line.
% Use of \textquotesingle for straight quote.
-\newcommand*\Sphinxbreaksatspecials {%
- \def\PYGZus{\discretionary{\char`\_}{\Sphinxafterbreak}{\char`\_}}%
- \def\PYGZob{\discretionary{}{\Sphinxafterbreak\char`\{}{\char`\{}}%
- \def\PYGZcb{\discretionary{\char`\}}{\Sphinxafterbreak}{\char`\}}}%
- \def\PYGZca{\discretionary{\char`\^}{\Sphinxafterbreak}{\char`\^}}%
- \def\PYGZam{\discretionary{\char`\&}{\Sphinxafterbreak}{\char`\&}}%
- \def\PYGZlt{\discretionary{}{\Sphinxafterbreak\char`\<}{\char`\<}}%
- \def\PYGZgt{\discretionary{\char`\>}{\Sphinxafterbreak}{\char`\>}}%
- \def\PYGZsh{\discretionary{}{\Sphinxafterbreak\char`\#}{\char`\#}}%
- \def\PYGZpc{\discretionary{}{\Sphinxafterbreak\char`\%}{\char`\%}}%
- \def\PYGZdl{\discretionary{}{\Sphinxafterbreak\char`\$}{\char`\$}}%
- \def\PYGZhy{\discretionary{\char`\-}{\Sphinxafterbreak}{\char`\-}}%
- \def\PYGZsq{\discretionary{}{\Sphinxafterbreak\textquotesingle}{\textquotesingle}}%
- \def\PYGZdq{\discretionary{}{\Sphinxafterbreak\char`\"}{\char`\"}}%
- \def\PYGZti{\discretionary{\char`\~}{\Sphinxafterbreak}{\char`\~}}%
+\newcommand*\sphinxbreaksatspecials {%
+ \def\PYGZus{\discretionary{\char`\_}{\sphinxafterbreak}{\char`\_}}%
+ \def\PYGZob{\discretionary{}{\sphinxafterbreak\char`\{}{\char`\{}}%
+ \def\PYGZcb{\discretionary{\char`\}}{\sphinxafterbreak}{\char`\}}}%
+ \def\PYGZca{\discretionary{\char`\^}{\sphinxafterbreak}{\char`\^}}%
+ \def\PYGZam{\discretionary{\char`\&}{\sphinxafterbreak}{\char`\&}}%
+ \def\PYGZlt{\discretionary{}{\sphinxafterbreak\char`\<}{\char`\<}}%
+ \def\PYGZgt{\discretionary{\char`\>}{\sphinxafterbreak}{\char`\>}}%
+ \def\PYGZsh{\discretionary{}{\sphinxafterbreak\char`\#}{\char`\#}}%
+ \def\PYGZpc{\discretionary{}{\sphinxafterbreak\char`\%}{\char`\%}}%
+ \def\PYGZdl{\discretionary{}{\sphinxafterbreak\char`\$}{\char`\$}}%
+ \def\PYGZhy{\discretionary{\char`\-}{\sphinxafterbreak}{\char`\-}}%
+ \def\PYGZsq{\discretionary{}{\sphinxafterbreak\textquotesingle}{\textquotesingle}}%
+ \def\PYGZdq{\discretionary{}{\sphinxafterbreak\char`\"}{\char`\"}}%
+ \def\PYGZti{\discretionary{\char`\~}{\sphinxafterbreak}{\char`\~}}%
}
% Some characters . , ; ? ! / are not pygmentized.
% This macro makes them "active" and they will insert potential linebreaks
-\newcommand*\Sphinxbreaksatpunct {%
- \lccode`\~`\.\lowercase{\def~}{\discretionary{\char`\.}{\Sphinxafterbreak}{\char`\.}}%
- \lccode`\~`\,\lowercase{\def~}{\discretionary{\char`\,}{\Sphinxafterbreak}{\char`\,}}%
- \lccode`\~`\;\lowercase{\def~}{\discretionary{\char`\;}{\Sphinxafterbreak}{\char`\;}}%
- \lccode`\~`\:\lowercase{\def~}{\discretionary{\char`\:}{\Sphinxafterbreak}{\char`\:}}%
- \lccode`\~`\?\lowercase{\def~}{\discretionary{\char`\?}{\Sphinxafterbreak}{\char`\?}}%
- \lccode`\~`\!\lowercase{\def~}{\discretionary{\char`\!}{\Sphinxafterbreak}{\char`\!}}%
- \lccode`\~`\/\lowercase{\def~}{\discretionary{\char`\/}{\Sphinxafterbreak}{\char`\/}}%
+\newcommand*\sphinxbreaksatpunct {%
+ \lccode`\~`\.\lowercase{\def~}{\discretionary{\char`\.}{\sphinxafterbreak}{\char`\.}}%
+ \lccode`\~`\,\lowercase{\def~}{\discretionary{\char`\,}{\sphinxafterbreak}{\char`\,}}%
+ \lccode`\~`\;\lowercase{\def~}{\discretionary{\char`\;}{\sphinxafterbreak}{\char`\;}}%
+ \lccode`\~`\:\lowercase{\def~}{\discretionary{\char`\:}{\sphinxafterbreak}{\char`\:}}%
+ \lccode`\~`\?\lowercase{\def~}{\discretionary{\char`\?}{\sphinxafterbreak}{\char`\?}}%
+ \lccode`\~`\!\lowercase{\def~}{\discretionary{\char`\!}{\sphinxafterbreak}{\char`\!}}%
+ \lccode`\~`\/\lowercase{\def~}{\discretionary{\char`\/}{\sphinxafterbreak}{\char`\/}}%
\catcode`\.\active
\catcode`\,\active
\catcode`\;\active
@@ -297,25 +297,25 @@
% list starts new par, but we don't want it to be set apart vertically
\parskip\z@skip
% first, let's check if there is a caption
- \ifx\SphinxVerbatimTitle\empty
+ \ifx\sphinxVerbatimTitle\empty
\addvspace\z@% counteract possible previous negative skip (French lists!)
\smallskip
% there was no caption. Check if nevertheless a label was set.
- \ifx\SphinxLiteralBlockLabel\empty\else
+ \ifx\sphinxLiteralBlockLabel\empty\else
% we require some space to be sure hyperlink target from \phantomsection
% will not be separated from upcoming verbatim by a page break
- \needspace{\literalblockwithoutcaptionneedspace}%
- \phantomsection\SphinxLiteralBlockLabel
+ \needspace{\sphinxliteralblockwithoutcaptionneedspace}%
+ \phantomsection\sphinxLiteralBlockLabel
\fi
\fi
- % non-empty \SphinxVerbatimTitle has label inside it (in case there is one)
+ % non-empty \sphinxVerbatimTitle has label inside it (in case there is one)
% Customize framed.sty \MakeFramed to glue caption to literal block
- \global\Sphinx@myfirstframedpasstrue
- % via \Sphinx@fcolorbox, will use \Sphinx@VerbatimFBox which inserts title
- \def\FrameCommand {\Sphinx@colorbox\Sphinx@fcolorbox }%
+ \global\spx@myfirstframedpasstrue
+ % via \spx@fcolorbox, will use \spx@VerbatimFBox which inserts title
+ \def\FrameCommand {\spx@colorbox\spx@fcolorbox }%
\let\FirstFrameCommand\FrameCommand
% for mid pages and last page portion of (long) split frame:
- \def\MidFrameCommand{\Sphinx@colorbox\fcolorbox }%
+ \def\MidFrameCommand{\spx@colorbox\fcolorbox }%
\let\LastFrameCommand\MidFrameCommand
% fancyvrb's Verbatim puts each input line in (unbreakable) horizontal boxes.
% This customization wraps each line from the input in a \vtop, thus
@@ -323,10 +323,10 @@
% - The codeline counter will be increased only once.
% - The wrapped material will not break across pages, it is impossible
% to achieve this without extensive rewrite of fancyvrb.
- % - The (not used in Sphinx) obeytabs option to Verbatim is
+ % - The (not used in sphinx) obeytabs option to Verbatim is
% broken by this change (showtabs and tabspace work).
- \sbox\Sphinxcontinuationbox {\Sphinxcontinuationsymbol}%
- \sbox\Sphinxvisiblespacebox {\FV@SetupFont\Sphinxvisiblespace}%
+ \sbox\sphinxcontinuationbox {\sphinxcontinuationsymbol}%
+ \sbox\sphinxvisiblespacebox {\FV@SetupFont\sphinxvisiblespace}%
\def\FancyVerbFormatLine ##1{\hsize\linewidth
\vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
\doublehyphendemerits\z@\finalhyphendemerits\z@
@@ -337,7 +337,7 @@
% Stretch/shrink are however usually zero for typewriter font.
\def\FV@Space {%
\nobreak\hskip\z@ plus\fontdimen3\font minus\fontdimen4\font
- \discretionary{\copy\Sphinxvisiblespacebox}{\Sphinxafterbreak}
+ \discretionary{\copy\sphinxvisiblespacebox}{\sphinxafterbreak}
{\kern\fontdimen2\font}%
}%
% go around fancyvrb's check of @currenvir (for case of minipage below)
@@ -345,7 +345,7 @@
% go around fancyvrb's check of current list depth
\def\@toodeep {\advance\@listdepth\@ne}%
% Allow breaks at special characters using \PYG... macros.
- \Sphinxbreaksatspecials
+ \sphinxbreaksatspecials
% The list environment is needed to control perfectly the vertical space.
% Note: \OuterFrameSep used by framed.sty is later set to \topsep hence 0pt.
% - if caption: vertical space above caption = (\abovecaptionskip + D) with
@@ -360,7 +360,7 @@
\parindent \z@% becomes \itemindent. Default zero, but perhaps overwritten.
\trivlist\item\relax
% use a minipage if we are already inside a framed environment
- \ifSphinx@inframed\noindent\begin{minipage}{\linewidth}\fi
+ \ifspx@inframed\noindent\begin{minipage}{\linewidth}\fi
\MakeFramed {% adapted over from framed.sty's snugshade environment
\advance\hsize-\width\@totalleftmargin\z@\linewidth\hsize
\@setminipage }%
@@ -368,45 +368,45 @@
% For grid placement from \strut's in \FancyVerbFormatLine
\lineskip\z@skip
% Breaks at punctuation characters . , ; ? ! and / need catcode=\active
- \OriginalVerbatim[#1,codes*=\Sphinxbreaksatpunct]%
+ \OriginalVerbatim[#1,codes*=\sphinxbreaksatpunct]%
}
\renewcommand{\endVerbatim}{%
\endOriginalVerbatim
\par\unskip\@minipagefalse\endMakeFramed
- \ifSphinx@inframed\end{minipage}\fi
+ \ifspx@inframed\end{minipage}\fi
\endtrivlist
}
% define macro to frame contents and add shadow on right and bottom
-\def\Sphinx@shadowsep {5\p@} % \p@ means "pt "
-\def\Sphinx@shadowsize {4\p@}
-\def\Sphinx@shadowrule {\fboxrule}
-\long\def\Sphinx@ShadowFBox#1{%
+\def\spx@shadowsep {5\p@} % \p@ means "pt "
+\def\spx@shadowsize {4\p@}
+\def\spx@shadowrule {\fboxrule}
+\long\def\spx@ShadowFBox#1{%
\leavevmode\begingroup
% first we frame the box #1
\setbox\@tempboxa
- \hbox{\vrule\@width\Sphinx@shadowrule
- \vbox{\hrule\@height\Sphinx@shadowrule
- \kern\Sphinx@shadowsep
- \hbox{\kern\Sphinx@shadowsep #1\kern\Sphinx@shadowsep}%
- \kern\Sphinx@shadowsep
- \hrule\@height\Sphinx@shadowrule}%
- \vrule\@width\Sphinx@shadowrule}%
+ \hbox{\vrule\@width\spx@shadowrule
+ \vbox{\hrule\@height\spx@shadowrule
+ \kern\spx@shadowsep
+ \hbox{\kern\spx@shadowsep #1\kern\spx@shadowsep}%
+ \kern\spx@shadowsep
+ \hrule\@height\spx@shadowrule}%
+ \vrule\@width\spx@shadowrule}%
% Now we add the shadow, like \shadowbox from fancybox.sty would do
- \dimen@\dimexpr.5\Sphinx@shadowrule+\Sphinx@shadowsize\relax
+ \dimen@\dimexpr.5\spx@shadowrule+\spx@shadowsize\relax
\hbox{\vbox{\offinterlineskip
- \hbox{\copy\@tempboxa\kern-.5\Sphinx@shadowrule
+ \hbox{\copy\@tempboxa\kern-.5\spx@shadowrule
% add shadow on right side
- \lower\Sphinx@shadowsize
+ \lower\spx@shadowsize
\hbox{\vrule\@height\ht\@tempboxa \@width\dimen@}%
}%
\kern-\dimen@ % shift back vertically to bottom of frame
% and add shadow at bottom
- \moveright\Sphinx@shadowsize
+ \moveright\spx@shadowsize
\vbox{\hrule\@width\wd\@tempboxa \@height\dimen@}%
}%
% move left by the size of right shadow so shadow adds no width
- \kern-\Sphinx@shadowsize
+ \kern-\spx@shadowsize
}%
\endgroup
}
@@ -415,8 +415,8 @@
% works well inside Lists and Quote-like environments
% produced by ``topic'' directive (or local contents)
% could nest if LaTeX writer authorized it
-\newenvironment{SphinxShadowBox}
- {\def\FrameCommand {\Sphinx@ShadowFBox }%
+\newenvironment{sphinxShadowBox}
+ {\def\FrameCommand {\spx@ShadowFBox }%
% configure framed.sty not to add extra vertical spacing
\ifdefined\OuterFrameSep \OuterFrameSep\z@skip \fi
% the \trivlist will add the vertical spacing on top and bottom which is
@@ -427,8 +427,8 @@
\def\FrameHeightAdjust {\baselineskip}%
\trivlist\item\noindent
% use a minipage if we are already inside a framed environment
- \ifSphinx@inframed\begin{minipage}{\linewidth}\fi
- \MakeFramed {\Sphinx@inframedtrue
+ \ifspx@inframed\begin{minipage}{\linewidth}\fi
+ \MakeFramed {\spx@inframedtrue
% framed.sty puts into "\width" the added width (=2shadowsep+2shadowrule)
% adjust \hsize to what the contents must use
\advance\hsize-\width
@@ -454,7 +454,7 @@
\fi
\@minipagefalse
\endMakeFramed
- \ifSphinx@inframed\end{minipage}\fi
+ \ifspx@inframed\end{minipage}\fi
\endtrivlist
}
@@ -495,25 +495,25 @@
}{\end{list}}
% \optional is used for ``[, arg]``, i.e. desc_optional nodes.
-\newcommand{\optional}[1]{%
+\newcommand{\sphinxoptional}[1]{%
{\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
\newlength{\py@argswidth}
\newcommand{\py@sigparams}[2]{%
- \parbox[t]{\py@argswidth}{#1\code{)}#2}}
+ \parbox[t]{\py@argswidth}{#1\sphinxcode{)}#2}}
\newcommand{\pysigline}[1]{\item[#1]\nopagebreak}
\newcommand{\pysiglinewithargsret}[3]{%
- \settowidth{\py@argswidth}{#1\code{(}}%
+ \settowidth{\py@argswidth}{#1\sphinxcode{(}}%
\addtolength{\py@argswidth}{-2\py@argswidth}%
\addtolength{\py@argswidth}{\linewidth}%
- \item[#1\code{(}\py@sigparams{#2}{#3}]}
+ \item[#1\sphinxcode{(}\py@sigparams{#2}{#3}]}
% Production lists
%
\newenvironment{productionlist}{
-% \def\optional##1{{\Large[}##1{\Large]}}
- \def\production##1##2{\\\code{##1}&::=&\code{##2}}
- \def\productioncont##1{\\& &\code{##1}}
+% \def\sphinxoptional##1{{\Large[}##1{\Large]}}
+ \def\production##1##2{\\\sphinxcode{##1}&::=&\sphinxcode{##2}}
+ \def\productioncont##1{\\& &\sphinxcode{##1}}
\parindent=2em
\indent
\setlength{\LTpre}{0pt}
@@ -541,7 +541,7 @@
\fboxsep\FrameSep \fboxrule\FrameRule\fbox{##1}%
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
% use a minipage if we are already inside a framed environment
- \ifSphinx@inframed
+ \ifspx@inframed
\noindent\begin{minipage}{\linewidth}
\else
% handle case where notice is first thing in a list item (or is quoted)
@@ -551,7 +551,7 @@
\vspace{\parskip}
\fi
\fi
- \MakeFramed {\Sphinx@inframedtrue
+ \MakeFramed {\spx@inframedtrue
\advance\hsize-\width \@totalleftmargin\z@ \linewidth\hsize
% minipage initialization copied from LaTeX source code.
\@pboxswfalse
@@ -570,7 +570,7 @@
\fi
\@minipagefalse
\endMakeFramed
- \ifSphinx@inframed\end{minipage}\fi
+ \ifspx@inframed\end{minipage}\fi
% arrange for similar spacing below frame as for "light" boxes.
\vskip .4\baselineskip
}
@@ -614,7 +614,7 @@
\newenvironment{notice}[2]{
\def\py@noticetype{#1}
\csname py@noticestart@#1\endcsname
- \strong{#2}
+ \sphinxstrong{#2} % <- legacy code creates a space after {#2}
}{\csname py@noticeend@\py@noticetype\endcsname}
% Allow the release number to be specified independently of the
@@ -684,7 +684,7 @@
% The following is stuff copied from docutils' latex writer.
%
-\newcommand{\optionlistlabel}[1]{\bf #1 \hfill}
+\newcommand{\optionlistlabel}[1]{\normalfont\bfseries #1 \hfill}% \bf deprecated
\newenvironment{optionlist}[1]
{\begin{list}{}
{\setlength{\labelwidth}{#1}
@@ -853,17 +853,38 @@
\RequirePackage{capt-of}
\RequirePackage{needspace}
% if the left page space is less than \literalblockneedspace, insert page-break
-\newcommand{\literalblockneedspace}{5\baselineskip}
-\newcommand{\literalblockwithoutcaptionneedspace}{1.5\baselineskip}
+\newcommand{\sphinxliteralblockneedspace}{5\baselineskip}
+\newcommand{\sphinxliteralblockwithoutcaptionneedspace}{1.5\baselineskip}
% figure in table
-\newenvironment{figure-in-table}[1][\linewidth]{%
+\newenvironment{sphinxfigure-in-table}[1][\linewidth]{%
\def\@captype{figure}%
\begin{minipage}{#1}%
}{\end{minipage}}
% store original \caption macro for use with figures in longtable and tabulary
-\AtBeginDocument{\let\Sphinx@originalcaption\caption}
-\newcommand*\figcaption
+\AtBeginDocument{\let\spx@originalcaption\caption}
+\newcommand*\sphinxfigcaption
{\ifx\equation$%$% this is trick to identify tabulary first pass
\firstchoice@false\else\firstchoice@true\fi
- \Sphinx@originalcaption }
+ \spx@originalcaption }
+
+% by default, also define macros with the no-prefix names
+\ifsphinxKeepOldNames
+ \typeout{** (sphinx) defining (legacy) text style macros without \string\sphinx\space prefix}
+ \typeout{** if clashes with packages, set latex_keep_old_macro_names=False in conf.py}
+ \@for\@tempa:=strong,bfcode,email,tablecontinued,titleref,%
+ menuselection,accelerator,crossref,termref,optional\do
+{% first, check if command with no prefix already exists
+ \expandafter\newcommand\csname\@tempa\endcsname{}%
+ % if no error give it the meaning defined so far with \sphinx prefix
+ \expandafter\let\csname\@tempa\expandafter\endcsname
+ \csname sphinx\@tempa\endcsname
+ % redefine the \sphinx prefixed macro to expand to non-prefixed one
+ \expandafter\def\csname sphinx\@tempa\expandafter\endcsname
+ \expandafter{\csname\@tempa\endcsname}%
+}
+ % robustified case needs special treatment
+ \newcommand\code{}\let\code\relax
+ \DeclareRobustCommand{\code}[1]{{\@noligs\scantokens{\texttt{#1}}}}
+ \def\sphinxcode{\code}%
+\fi
diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py
index 5bd668572..524e035a7 100644
--- a/sphinx/writers/latex.py
+++ b/sphinx/writers/latex.py
@@ -33,6 +33,7 @@ from sphinx.util.smartypants import educate_quotes_latex
HEADER = r'''%% Generated by Sphinx.
\def\sphinxdocclass{%(docclass)s}
+\newif\ifsphinxKeepOldNames %(keepoldnames)s
\documentclass[%(papersize)s,%(pointsize)s%(classoptions)s]{%(wrapperclass)s}
\usepackage{iftex}
%(passoptionstopackages)s
@@ -391,6 +392,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
'preamble': builder.config.latex_preamble,
'indexname': _('Index'),
})
+ # set-up boolean for sphinx.sty
+ if builder.config.latex_keep_old_macro_names:
+ self.elements['keepoldnames'] = '\\sphinxKeepOldNamestrue'
+ else:
+ self.elements['keepoldnames'] = '\\sphinxKeepOldNamesfalse'
if document.settings.docclass == 'howto':
docclass = builder.config.latex_docclass.get('howto', 'article')
else:
@@ -732,11 +738,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_topic(self, node):
self.in_minipage = 1
- self.body.append('\n\\begin{SphinxShadowBox}\n')
+ self.body.append('\n\\begin{sphinxShadowBox}\n')
def depart_topic(self, node):
self.in_minipage = 0
- self.body.append('\\end{SphinxShadowBox}\n')
+ self.body.append('\\end{sphinxShadowBox}\n')
visit_sidebar = visit_topic
depart_sidebar = depart_topic
@@ -867,7 +873,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append('}')
def visit_desc_addname(self, node):
- self.body.append(r'\code{')
+ self.body.append(r'\sphinxcode{')
self.literal_whitespace += 1
def depart_desc_addname(self, node):
@@ -887,7 +893,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append(r'}')
def visit_desc_name(self, node):
- self.body.append(r'\bfcode{')
+ self.body.append(r'\sphinxbfcode{')
self.no_contractions += 1
self.literal_whitespace += 1
@@ -918,13 +924,13 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append('}')
def visit_desc_optional(self, node):
- self.body.append(r'\optional{')
+ self.body.append(r'\sphinxoptional{')
def depart_desc_optional(self, node):
self.body.append('}')
def visit_desc_annotation(self, node):
- self.body.append(r'\strong{')
+ self.body.append(r'\sphinxstrong{')
def depart_desc_annotation(self, node):
self.body.append('}')
@@ -938,7 +944,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
pass
def visit_seealso(self, node):
- self.body.append(u'\n\n\\strong{%s:}\n\n' % admonitionlabels['seealso'])
+ self.body.append(u'\n\n\\sphinxstrong{%s:}\n\n' % admonitionlabels['seealso'])
def depart_seealso(self, node):
self.body.append("\n\n")
@@ -1440,12 +1446,12 @@ class LaTeXTranslator(nodes.NodeVisitor):
# TODO: support align option
if 'width' in node:
length = width_to_latex_length(node['width'])
- self.body.append('\\begin{figure-in-table}[%s]\n\\centering\n' % length)
+ self.body.append('\\begin{sphinxfigure-in-table}[%s]\n\\centering\n' % length)
else:
- self.body.append('\\begin{figure-in-table}\n\\centering\n')
+ self.body.append('\\begin{sphinxfigure-in-table}\n\\centering\n')
if any(isinstance(child, nodes.caption) for child in node):
self.body.append('\\capstart')
- self.context.append(ids + '\\end{figure-in-table}\n')
+ self.context.append(ids + '\\end{sphinxfigure-in-table}\n')
elif node.get('align', '') in ('left', 'right'):
if 'width' in node:
length = width_to_latex_length(node['width'])
@@ -1487,11 +1493,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_caption(self, node):
self.in_caption += 1
if self.in_container_literal_block:
- self.body.append('\\SphinxSetupCaptionForVerbatim{literal-block}{')
+ self.body.append('\\sphinxSetupCaptionForVerbatim{literal-block}{')
elif self.in_minipage and isinstance(node.parent, nodes.figure):
self.body.append('\\captionof{figure}{')
elif self.table and node.parent.tagname == 'figure':
- self.body.append('\\figcaption{')
+ self.body.append('\\sphinxfigcaption{')
else:
self.body.append('\\caption{')
@@ -1689,9 +1695,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
# don't add a pageref for glossary terms
self.context.append('}}}')
# mark up as termreference
- self.body.append(r'\termref{')
+ self.body.append(r'\sphinxtermref{')
else:
- self.body.append(r'\crossref{')
+ self.body.append(r'\sphinxcrossref{')
if self.builder.config.latex_show_pagerefs and not \
self.in_production_list:
self.context.append('}}} (%s)' % self.hyperpageref(id))
@@ -1779,7 +1785,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
return self.depart_literal_emphasis(node)
def visit_title_reference(self, node):
- self.body.append(r'\titleref{')
+ self.body.append(r'\sphinxtitleref{')
def depart_title_reference(self, node):
self.body.append('}')
@@ -1807,7 +1813,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
if self.in_title:
self.body.append(r'\texttt{')
else:
- self.body.append(r'\code{')
+ self.body.append(r'\sphinxcode{')
def depart_literal(self, node):
self.no_contractions -= 1
@@ -1855,7 +1861,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
ids += self.hypertarget(node['ids'][0], anchor=False)
# LaTeX code will insert \phantomsection prior to \label
if ids:
- self.body.append('\n\\def\\SphinxLiteralBlockLabel{' + ids + '}')
+ self.body.append('\n\\def\\sphinxLiteralBlockLabel{' + ids + '}')
code = node.astext()
lang = self.hlsettingstack[-1][0]
linenos = code.count('\n') >= self.hlsettingstack[-1][1] - 1
@@ -1890,7 +1896,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append('\n' + hlcode + '\\end{%sVerbatim}\n' %
(self.table and 'Original' or ''))
if ids:
- self.body.append('\\let\\SphinxLiteralBlockLabel\empty\n')
+ self.body.append('\\let\\sphinxLiteralBlockLabel\empty\n')
raise nodes.SkipNode
def depart_literal_block(self, node):
@@ -2016,10 +2022,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_inline(self, node):
classes = node.get('classes', [])
if classes in [['menuselection'], ['guilabel']]:
- self.body.append(r'\menuselection{')
+ self.body.append(r'\sphinxmenuselection{')
self.context.append('}')
elif classes in [['accelerator']]:
- self.body.append(r'\accelerator{')
+ self.body.append(r'\sphinxaccelerator{')
self.context.append('}')
elif classes and not self.in_title:
self.body.append(r'\DUrole{%s}{' % ','.join(classes))
@@ -2053,13 +2059,13 @@ class LaTeXTranslator(nodes.NodeVisitor):
ids += self.hypertarget(node['ids'][0], anchor=False)
# define label for use in caption.
if ids:
- self.body.append('\n\\def\\SphinxLiteralBlockLabel{' + ids + '}\n')
+ self.body.append('\n\\def\\sphinxLiteralBlockLabel{' + ids + '}\n')
def depart_container(self, node):
if node.get('literal_block'):
self.in_container_literal_block -= 1
- self.body.append('\\let\\SphinxVerbatimTitle\\empty\n')
- self.body.append('\\let\\SphinxLiteralBlockLabel\\empty\n')
+ self.body.append('\\let\\sphinxVerbatimTitle\\empty\n')
+ self.body.append('\\let\\sphinxLiteralBlockLabel\\empty\n')
def visit_decoration(self, node):
pass
diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py
index fdc594d09..503f41ef1 100644
--- a/tests/test_build_latex.py
+++ b/tests/test_build_latex.py
@@ -112,9 +112,9 @@ def test_writer(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
- assert ('\\begin{figure-in-table}\n\\centering\n\\capstart\n'
- '\\includegraphics{{img}.png}\n'
- '\\figcaption{figure in table}\\label{markup:id7}\\end{figure-in-table}' in result)
+ assert ('\\begin{sphinxfigure-in-table}\n\\centering\n\\capstart\n'
+ '\\includegraphics{{img}.png}\n\\sphinxfigcaption'
+ '{figure in table}\\label{markup:id7}\\end{sphinxfigure-in-table}' in result)
assert ('\\begin{wrapfigure}{r}{0pt}\n\\centering\n'
'\\includegraphics{{rimg}.png}\n\\caption{figure with align option}'
@@ -409,7 +409,7 @@ def test_footnote(app, status, warning):
assert '\\footnote[1]{\sphinxAtStartFootnote%\nnumbered\n}' in result
assert '\\footnote[2]{\sphinxAtStartFootnote%\nauto numbered\n}' in result
assert '\\footnote[3]{\sphinxAtStartFootnote%\nnamed\n}' in result
- assert '{\\hyperref[footnote:bar]{\\crossref{{[}bar{]}}}}' in result
+ assert '{\\hyperref[footnote:bar]{\\sphinxcrossref{{[}bar{]}}}}' in result
assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} ' in result
assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} \ncite' in result
assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} \ncite\n}' in result
@@ -428,7 +428,7 @@ def test_reference_in_caption(app, status, warning):
print(status.getvalue())
print(warning.getvalue())
assert ('\\caption{This is the figure caption with a reference to \\label{index:id2}'
- '{\\hyperref[index:authoryear]{\\crossref{{[}AuthorYear{]}}}}.}' in result)
+ '{\\hyperref[index:authoryear]{\\sphinxcrossref{{[}AuthorYear{]}}}}.}' in result)
assert '\\chapter{The section with a reference to {[}AuthorYear{]}}' in result
assert '\\caption{The table title with a reference to {[}AuthorYear{]}}' in result
assert '\\paragraph{The rubric title with a reference to {[}AuthorYear{]}}' in result
@@ -462,11 +462,12 @@ def test_latex_show_urls_is_inline(app, status, warning):
'footnote in baz\n} in baz.rst' in result)
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
- '{\\crossref{The section with a reference to \\phantomsection\\label{index:id1}'
- '{\\hyperref[index:authoryear]{\\crossref{{[}AuthorYear{]}}}}}}}' in result)
+ '{\\sphinxcrossref{The section with a reference to '
+ '\\phantomsection\\label{index:id1}'
+ '{\\hyperref[index:authoryear]{\\sphinxcrossref{{[}AuthorYear{]}}}}}}}' in result)
assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section'
'\\string-with\\string-a\\string-reference\\string-to]'
- '{\\crossref{The section with a reference to }}}' in result)
+ '{\\sphinxcrossref{The section with a reference to }}}' in result)
assert 'First footnote: \\footnote[2]{\sphinxAtStartFootnote%\nFirst\n}' in result
assert 'Second footnote: \\footnote[1]{\sphinxAtStartFootnote%\nSecond\n}' in result
assert '\\href{http://sphinx-doc.org/}{Sphinx} (http://sphinx-doc.org/)' in result
@@ -499,11 +500,12 @@ def test_latex_show_urls_is_footnote(app, status, warning):
'footnote in baz\n} in baz.rst' in result)
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
- '{\\crossref{The section with a reference to \\phantomsection\\label{index:id1}'
- '{\\hyperref[index:authoryear]{\\crossref{{[}AuthorYear{]}}}}}}}' in result)
+ '{\\sphinxcrossref{The section with a reference '
+ 'to \\phantomsection\\label{index:id1}'
+ '{\\hyperref[index:authoryear]{\\sphinxcrossref{{[}AuthorYear{]}}}}}}}' in result)
assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section'
'\\string-with\\string-a\\string-reference\\string-to]'
- '{\\crossref{The section with a reference to }}}' in result)
+ '{\\sphinxcrossref{The section with a reference to }}}' in result)
assert 'First footnote: \\footnote[3]{\sphinxAtStartFootnote%\nFirst\n}' in result
assert 'Second footnote: \\footnote[1]{\sphinxAtStartFootnote%\nSecond\n}' in result
assert ('\\href{http://sphinx-doc.org/}{Sphinx}'
@@ -542,11 +544,12 @@ def test_latex_show_urls_is_no(app, status, warning):
'footnote in baz\n} in baz.rst' in result)
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
- '{\\crossref{The section with a reference to \\phantomsection\\label{index:id1}'
- '{\\hyperref[index:authoryear]{\\crossref{{[}AuthorYear{]}}}}}}}' in result)
+ '{\\sphinxcrossref{The section with a reference '
+ 'to \\phantomsection\\label{index:id1}'
+ '{\\hyperref[index:authoryear]{\\sphinxcrossref{{[}AuthorYear{]}}}}}}}' in result)
assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section'
'\\string-with\\string-a\\string-reference\\string-to]'
- '{\\crossref{The section with a reference to }}}' in result)
+ '{\\sphinxcrossref{The section with a reference to }}}' in result)
assert 'First footnote: \\footnote[2]{\sphinxAtStartFootnote%\nFirst\n}' in result
assert 'Second footnote: \\footnote[1]{\sphinxAtStartFootnote%\nSecond\n}' in result
assert '\\href{http://sphinx-doc.org/}{Sphinx}' in result
diff --git a/tests/test_directive_code.py b/tests/test_directive_code.py
index 4adb04cfb..5871f0321 100644
--- a/tests/test_directive_code.py
+++ b/tests/test_directive_code.py
@@ -65,8 +65,8 @@ def test_code_block_caption_html(app, status, warning):
def test_code_block_caption_latex(app, status, warning):
app.builder.build_all()
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
- caption = '\\SphinxSetupCaptionForVerbatim{literal-block}{caption \\emph{test} rb}'
- label = '\\def\\SphinxLiteralBlockLabel{\\label{caption:caption-test-rb}}'
+ caption = '\\sphinxSetupCaptionForVerbatim{literal-block}{caption \\emph{test} rb}'
+ label = '\\def\\sphinxLiteralBlockLabel{\\label{caption:caption-test-rb}}'
link = '\hyperref[caption:caption-test-rb]' \
'{Listing \\ref{caption:caption-test-rb}}'
assert caption in latex
@@ -78,12 +78,12 @@ def test_code_block_caption_latex(app, status, warning):
def test_code_block_namedlink_latex(app, status, warning):
app.builder.build_all()
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
- label1 = '\def\SphinxLiteralBlockLabel{\label{caption:name-test-rb}}'
+ label1 = '\def\sphinxLiteralBlockLabel{\label{caption:name-test-rb}}'
link1 = '\\hyperref[caption:name\\string-test\\string-rb]'\
- '{\\crossref{\\DUrole{std,std-ref}{Ruby}}'
- label2 = '\def\SphinxLiteralBlockLabel{\label{namedblocks:some-ruby-code}}'
+ '{\\sphinxcrossref{\\DUrole{std,std-ref}{Ruby}}'
+ label2 = '\def\sphinxLiteralBlockLabel{\label{namedblocks:some-ruby-code}}'
link2 = '\\hyperref[namedblocks:some\\string-ruby\\string-code]'\
- '{\\crossref{\\DUrole{std,std-ref}{the ruby code}}}'
+ '{\\sphinxcrossref{\\DUrole{std,std-ref}{the ruby code}}}'
assert label1 in latex
assert link1 in latex
assert label2 in latex
@@ -252,8 +252,8 @@ def test_literalinclude_caption_html(app, status, warning):
def test_literalinclude_caption_latex(app, status, warning):
app.builder.build('index')
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
- caption = '\\SphinxSetupCaptionForVerbatim{literal-block}{caption \\textbf{test} py}'
- label = '\\def\\SphinxLiteralBlockLabel{\\label{caption:caption-test-py}}'
+ caption = '\\sphinxSetupCaptionForVerbatim{literal-block}{caption \\textbf{test} py}'
+ label = '\\def\\sphinxLiteralBlockLabel{\\label{caption:caption-test-py}}'
link = '\hyperref[caption:caption-test-py]' \
'{Listing \\ref{caption:caption-test-py}}'
assert caption in latex
@@ -265,12 +265,12 @@ def test_literalinclude_caption_latex(app, status, warning):
def test_literalinclude_namedlink_latex(app, status, warning):
app.builder.build('index')
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
- label1 = '\def\SphinxLiteralBlockLabel{\label{caption:name-test-py}}'
+ label1 = '\def\sphinxLiteralBlockLabel{\label{caption:name-test-py}}'
link1 = '\\hyperref[caption:name\\string-test\\string-py]'\
- '{\\crossref{\\DUrole{std,std-ref}{Python}}'
- label2 = '\def\SphinxLiteralBlockLabel{\label{namedblocks:some-python-code}}'
+ '{\\sphinxcrossref{\\DUrole{std,std-ref}{Python}}'
+ label2 = '\def\sphinxLiteralBlockLabel{\label{namedblocks:some-python-code}}'
link2 = '\\hyperref[namedblocks:some\\string-python\\string-code]'\
- '{\\crossref{\\DUrole{std,std-ref}{the python code}}}'
+ '{\\sphinxcrossref{\\DUrole{std,std-ref}{the python code}}}'
assert label1 in latex
assert link1 in latex
assert label2 in latex
diff --git a/tests/test_markup.py b/tests/test_markup.py
index e7e343e6b..f7f639491 100644
--- a/tests/test_markup.py
+++ b/tests/test_markup.py
@@ -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)`',