summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES3
-rw-r--r--sphinx/domains/cpp.py13
-rw-r--r--sphinx/texinputs/sphinx.sty5
-rw-r--r--sphinx/writers/latex.py9
-rw-r--r--tests/roots/test-latex-table/expects/longtable_having_verbatim.tex1
-rw-r--r--tests/roots/test-latex-table/expects/table_having_verbatim.tex1
-rw-r--r--tests/test_directive_code.py2
-rw-r--r--tests/test_domain_cpp.py16
-rw-r--r--tests/test_markup.py3
9 files changed, 42 insertions, 11 deletions
diff --git a/CHANGES b/CHANGES
index aaf3ed2ea..5ae30ab92 100644
--- a/CHANGES
+++ b/CHANGES
@@ -144,6 +144,9 @@ 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)
+* #5636: C++, fix parsing of floating point literals.
Testing
--------
diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py
index 40dfd5df9..380a9e98a 100644
--- a/sphinx/domains/cpp.py
+++ b/sphinx/domains/cpp.py
@@ -293,7 +293,18 @@ _octal_literal_re = re.compile(r'0[0-7]*')
_hex_literal_re = re.compile(r'0[xX][0-7a-fA-F][0-7a-fA-F]*')
_binary_literal_re = re.compile(r'0[bB][01][01]*')
_integer_suffix_re = re.compile(r'')
-_float_literal_re = re.compile(r'[+-]?[0-9]*\.[0-9]+')
+_float_literal_re = re.compile(r'''(?x)
+ [+-]?(
+ # decimal
+ ([0-9]+[eE][+-]?[0-9]+)
+ | ([0-9]*\.[0-9]+([eE][+-]?[0-9]+)?)
+ | ([0-9]+\.([eE][+-]?[0-9]+)?)
+ # hex
+ | (0[xX][0-9a-fA-F]+[pP][+-]?[0-9a-fA-F]+)
+ | (0[xX][0-9a-fA-F]*\.[0-9a-fA-F]+([pP][+-]?[0-9a-fA-F]+)?)
+ | (0[xX][0-9a-fA-F]+\.([pP][+-]?[0-9a-fA-F]+)?)
+ )
+''')
_char_literal_re = re.compile(r'''(?x)
((?:u8)|u|U|L)?
'(
diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty
index ab9c442d8..b44f23063 100644
--- a/sphinx/texinputs/sphinx.sty
+++ b/sphinx/texinputs/sphinx.sty
@@ -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}
diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py
index 318639ac8..5cbebf486 100644
--- a/sphinx/writers/latex.py
+++ b/sphinx/writers/latex.py
@@ -2257,9 +2257,12 @@ class LaTeXTranslator(SphinxTranslator):
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):
diff --git a/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex b/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex
index e1628a9bd..097449cd9 100644
--- a/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex
+++ b/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex
@@ -27,7 +27,6 @@ header2
\endlastfoot
-\fvset{hllines={, ,}}%
\begin{sphinxVerbatimintable}[commandchars=\\\{\}]
\PYG{n}{hello} \PYG{n}{world}
\end{sphinxVerbatimintable}
diff --git a/tests/roots/test-latex-table/expects/table_having_verbatim.tex b/tests/roots/test-latex-table/expects/table_having_verbatim.tex
index 40d2f424c..2e2b1dc9a 100644
--- a/tests/roots/test-latex-table/expects/table_having_verbatim.tex
+++ b/tests/roots/test-latex-table/expects/table_having_verbatim.tex
@@ -10,7 +10,6 @@ header1
header2
\\
\hline
-\fvset{hllines={, ,}}%
\begin{sphinxVerbatimintable}[commandchars=\\\{\}]
\PYG{n}{hello} \PYG{n}{world}
\end{sphinxVerbatimintable}
diff --git a/tests/test_directive_code.py b/tests/test_directive_code.py
index 3fa180e78..34e3e525c 100644
--- a/tests/test_directive_code.py
+++ b/tests/test_directive_code.py
@@ -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')
diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py
index 0d47f69b2..3e19efbbf 100644
--- a/tests/test_domain_cpp.py
+++ b/tests/test_domain_cpp.py
@@ -124,8 +124,20 @@ def test_expressions():
expr = i + l + u
exprCheck(expr, 'L' + expr + 'E')
for suffix in ['', 'f', 'F', 'l', 'L']:
- expr = '5.0' + suffix
- exprCheck(expr, 'L' + expr + 'E')
+ for e in [
+ '5e42', '5e+42', '5e-42',
+ '5.', '5.e42', '5.e+42', '5.e-42',
+ '.5', '.5e42', '.5e+42', '.5e-42',
+ '5.0', '5.0e42','5.0e+42', '5.0e-42']:
+ expr = e + suffix
+ exprCheck(expr, 'L' + expr + 'E')
+ for e in [
+ 'ApF', 'Ap+F', 'Ap-F',
+ 'A.', 'A.pF', 'A.p+F', 'A.p-F',
+ '.A', '.ApF', '.Ap+F', '.Ap-F',
+ 'A.B', 'A.BpF','A.Bp+F', 'A.Bp-F']:
+ expr = "0x" + e + suffix
+ exprCheck(expr, 'L' + expr + 'E')
exprCheck('"abc\\"cba"', 'LA8_KcE') # string
exprCheck('this', 'fpT')
# character literals
diff --git a/tests/test_markup.py b/tests/test_markup.py
index 98823d665..af119e029 100644
--- a/tests/test_markup.py
+++ b/tests/test_markup.py
@@ -224,8 +224,7 @@ def get_verifier(verify, verify_re):
'verify',
'::\n\n @Γ\\∞${}',
None,
- ('\\fvset{hllines={, ,}}%\n'
- '\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]\n'
+ ('\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]\n'
'@Γ\\PYGZbs{}\\(\\infty\\)\\PYGZdl{}\\PYGZob{}\\PYGZcb{}\n'
'\\end{sphinxVerbatim}'),
),