mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5811 from jfbu/latex_fix_sphinxVerbatim_requires_hllines_markup
LaTeX: allow sphinxVerbatim usage without explicit "hllines" extra setup
This commit is contained in:
commit
e2431d80bd
2
CHANGES
2
CHANGES
@ -22,6 +22,8 @@ Bugs fixed
|
||||
* #5627: qthelp: index.html missing in QtHelp
|
||||
* #5659: linkcheck: crashes for a hyperlink containing multibyte character
|
||||
* #5754: DOC: Fix some mistakes in :doc:`/latex`
|
||||
* #5810: LaTeX: sphinxVerbatim requires explicit "hllines" set-up since 1.6.6
|
||||
(refs: #1238)
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -6,7 +6,7 @@
|
||||
%
|
||||
|
||||
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
|
||||
\ProvidesPackage{sphinx}[2018/11/18 v1.8.3 LaTeX package (Sphinx markup)]
|
||||
\ProvidesPackage{sphinx}[2018/12/16 v1.8.3 LaTeX package (Sphinx markup)]
|
||||
|
||||
% provides \ltx@ifundefined
|
||||
% (many packages load ltxcmds: graphicx does for pdftex and lualatex but
|
||||
@ -208,6 +208,9 @@
|
||||
% For highlighted code.
|
||||
\RequirePackage{fancyvrb}
|
||||
\define@key{FV}{hllines}{\def\sphinx@verbatim@checkifhl##1{\in@{, ##1,}{#1}}}
|
||||
% sphinxVerbatim must be usable by third party without requiring hllines set-up
|
||||
\def\sphinxresetverbatimhllines{\def\sphinx@verbatim@checkifhl##1{\in@false}}
|
||||
\sphinxresetverbatimhllines
|
||||
% For hyperlinked footnotes in tables; also for gathering footnotes from
|
||||
% topic and warning blocks. Also to allow code-blocks in footnotes.
|
||||
\RequirePackage{footnotehyper-sphinx}
|
||||
|
@ -2260,9 +2260,12 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
else:
|
||||
hlcode += '\\end{sphinxVerbatim}'
|
||||
|
||||
hllines = '\\fvset{hllines={, %s,}}%%' %\
|
||||
str(highlight_args.get('hl_lines', []))[1:-1]
|
||||
self.body.append('\n' + hllines + '\n' + hlcode + '\n')
|
||||
hllines = str(highlight_args.get('hl_lines', []))[1:-1]
|
||||
if hllines:
|
||||
self.body.append('\n\\fvset{hllines={, %s,}}%%' % hllines)
|
||||
self.body.append('\n' + hlcode + '\n')
|
||||
if hllines:
|
||||
self.body.append('\\sphinxresetverbatimhllines\n')
|
||||
raise nodes.SkipNode
|
||||
|
||||
def depart_literal_block(self, node):
|
||||
|
@ -27,7 +27,6 @@ header2
|
||||
|
||||
\endlastfoot
|
||||
|
||||
\fvset{hllines={, ,}}%
|
||||
\begin{sphinxVerbatimintable}[commandchars=\\\{\}]
|
||||
\PYG{n}{hello} \PYG{n}{world}
|
||||
\end{sphinxVerbatimintable}
|
||||
|
@ -10,7 +10,6 @@ header1
|
||||
header2
|
||||
\\
|
||||
\hline
|
||||
\fvset{hllines={, ,}}%
|
||||
\begin{sphinxVerbatimintable}[commandchars=\\\{\}]
|
||||
\PYG{n}{hello} \PYG{n}{world}
|
||||
\end{sphinxVerbatimintable}
|
||||
|
@ -356,6 +356,8 @@ def test_code_block_emphasize_latex(app, status, warning):
|
||||
latex = (app.outdir / 'Python.tex').text(encoding='utf-8').replace('\r\n', '\n')
|
||||
includes = '\\fvset{hllines={, 5, 6, 13, 14, 15, 24, 25, 26, 27,}}%\n'
|
||||
assert includes in latex
|
||||
includes = '\\end{sphinxVerbatim}\n\sphinxresetverbatimhllines\n'
|
||||
assert includes in latex
|
||||
|
||||
|
||||
@pytest.mark.sphinx('xml', testroot='directive-code')
|
||||
|
@ -219,8 +219,7 @@ def get_verifier(verify, verify_re):
|
||||
'verify',
|
||||
u'::\n\n @Γ\\∞${}',
|
||||
None,
|
||||
(u'\\fvset{hllines={, ,}}%\n'
|
||||
u'\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]\n'
|
||||
(u'\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]\n'
|
||||
u'@\\(\\Gamma\\)\\PYGZbs{}\\(\\infty\\)\\PYGZdl{}\\PYGZob{}\\PYGZcb{}\n'
|
||||
u'\\end{sphinxVerbatim}'),
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user