Repository navigation
Description
Procedure to reproduce the problem
Apply following patch to silence Pygments exception on lexer error token:
diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py
index eb309d82a..acaca89ad 100644
--- a/sphinx/highlighting.py
+++ b/sphinx/highlighting.py
@@ -44,8 +44,8 @@ lexers = dict(
rest = RstLexer(stripnl=False),
c = CLexer(stripnl=False),
) # type: Dict[unicode, Lexer]
-for _lexer in lexers.values():
- _lexer.add_filter('raiseonerror')
+# for _lexer in lexers.values():
+# _lexer.add_filter('raiseonerror')
escape_hl_chars = {ord(u'\\'): u'\\PYGZbs{}',
@@ -136,7 +136,8 @@ class PygmentsBridge(object):
location=location)
lexer = lexers['none']
else:
- lexer.add_filter('raiseonerror')
+ pass
+ # lexer.add_filter('raiseonerror')
# trim doctest options if wanted
if isinstance(lexer, PythonConsoleLexer) and self.trim_doctest_flags:Then do make latexpdf with index.rst being
Welcome to FOO's documentation!
===============================
.. highlight:: coq
.. raw:: latex
\begin{multicols}2
::
Definition logeq_both_false {X Y : UU} : ¬X -> ¬Y -> (X <-> Y).
Definition logeq_both_false {X Y : UU} : ¬X -> ¬Y -> (X <-> Y).
Definition logeq_both_false {X Y : UU} : ¬X -> ¬Y -> (X <-> Y).
Definition logeq_both_false {X Y : UU} : ¬X -> ¬Y -> (X <-> Y).
Definition logeq_both_false {X Y : UU} : ¬X -> ¬Y -> (X <-> Y).
Definition logeq_both_false {X Y : UU} : ¬X -> ¬Y -> (X <-> Y).
.. raw:: latex
\makeatletter
\def\PYG@tok@err {\def\PYG@bc##1{\strut ##1}}
\makeatother
::
Definition logeq_both_false {X Y : UU} : ¬X -> ¬Y -> (X <-> Y).
Definition logeq_both_false {X Y : UU} : ¬X -> ¬Y -> (X <-> Y).
Definition logeq_both_false {X Y : UU} : ¬X -> ¬Y -> (X <-> Y).
Definition logeq_both_false {X Y : UU} : ¬X -> ¬Y -> (X <-> Y).
Definition logeq_both_false {X Y : UU} : ¬X -> ¬Y -> (X <-> Y).
Definition logeq_both_false {X Y : UU} : ¬X -> ¬Y -> (X <-> Y).
.. raw:: latex
\end{multicols}and conf.py containing
latex_elements = {
'preamble': r'\usepackage{multicol}',
}
Error logs / results
This produces this
Expected results
The two sides have the same height.
The problem is in the produced sphinxhighlight.sty file in the latex build repertory which contains
\expandafter\def\csname PYG@tok@err\endcsname{\def\PYG@bc##1{\setlength{\fboxsep}{0pt}\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}It should be \setlength\fboxsep{-\fboxrule}.
Besides there is another bug, which is that braces should be used else the \fboxsep settting is not local. This does not show easily because each line in code-block is in its own TeX box, so the change does not propagate to other lines, and besides a priori, nothing uses again \fboxsep setting. But it is a bug nevertheless.
There is also
\expandafter\def\csname PYG@tok@cs\endcsname{\def\PYG@tc##1{\textcolor[rgb]{0.25,0.50,0.56}{##1}}\def\PYG@bc##1{\setlength{\fboxsep}{0pt}\colorbox[rgb]{1.00,0.94,0.94}{\strut ##1}}}which has same unbraced \setlength{\fboxsep}{0pt} issue. (here 0pt is correct choice, though).
Environment info
- OS: Mac
- Python version: 3.5.4
- Sphinx version: stable at 0c98d04
- TeXLive 2017

Activity
jfbu commentedon Nov 20, 2017
This appears to a be a bug (or feature) of the Pygments latex formatter, because as far as I understand the
sphinxhighlight.styis generated (fromsphinx/builders/latex.py) via a call to Pygments via a PygmentsBridge object (the class is defined inhighlighting.py).Fix sphinx-doc#4249 by overriding Pygments latex formatter error high…
Fix sphinx-doc#4249 by overriding Pygments latex formatter error high…
Fix sphinx-doc#4249 by overriding Pygments latex formatter error high…
Merge pull request #4250 from jfbu/4249_errhighlight
jfbu commentedon Dec 10, 2017
Fixed at 0febbc5
LaTeX, better workaround for a Pygments <= 2.7.4 line spacing issue