mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
LaTeX, better workaround for a Pygments <= 2.7.4 line spacing issue
Closes: #8874 Relates #4249
This commit is contained in:
parent
62401ef1ec
commit
473718c4d4
2
CHANGES
2
CHANGES
@ -75,6 +75,8 @@ Bugs fixed
|
|||||||
change) with late TeXLive 2019
|
change) with late TeXLive 2019
|
||||||
* #8253: LaTeX: Figures with no size defined get overscaled (compared to images
|
* #8253: LaTeX: Figures with no size defined get overscaled (compared to images
|
||||||
with size explicitly set in pixels) (fixed for ``'pdflatex'/'lualatex'`` only)
|
with size explicitly set in pixels) (fixed for ``'pdflatex'/'lualatex'`` only)
|
||||||
|
* #8874: LaTeX: the fix to two minor Pygments LaTeXFormatter output issues ignore
|
||||||
|
Pygments style
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -8,10 +8,12 @@
|
|||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from distutils.version import LooseVersion
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
from pygments import __version__ as pygmentsversion
|
||||||
from pygments import highlight
|
from pygments import highlight
|
||||||
from pygments.filters import ErrorToken
|
from pygments.filters import ErrorToken
|
||||||
from pygments.formatter import Formatter
|
from pygments.formatter import Formatter
|
||||||
@ -50,6 +52,19 @@ escape_hl_chars = {ord('\\'): '\\PYGZbs{}',
|
|||||||
_LATEX_ADD_STYLES = r'''
|
_LATEX_ADD_STYLES = r'''
|
||||||
\renewcommand\PYGZsq{\textquotesingle}
|
\renewcommand\PYGZsq{\textquotesingle}
|
||||||
'''
|
'''
|
||||||
|
# fix extra space between lines when Pygments highlighting uses \fcolorbox
|
||||||
|
# add a {..} to limit \fboxsep scope, and force \fcolorbox use correct value
|
||||||
|
# cf pygments #1708 which makes this unneeded for Pygments > 2.7.4
|
||||||
|
_LATEX_ADD_STYLES_FIXPYG = r'''
|
||||||
|
\makeatletter
|
||||||
|
\let\spx@original@fcolorbox\fcolorbox
|
||||||
|
\def\spx@fixpyg@fcolorbox{\fboxsep-\fboxrule\spx@original@fcolorbox}
|
||||||
|
\def\PYG#1#2{\PYG@reset\PYG@toks#1+\relax+%
|
||||||
|
{\let\fcolorbox\spx@fixpyg@fcolorbox\PYG@do{#2}}}
|
||||||
|
\makeatother
|
||||||
|
'''
|
||||||
|
if tuple(LooseVersion(pygmentsversion).version) <= (2, 7, 4):
|
||||||
|
_LATEX_ADD_STYLES += _LATEX_ADD_STYLES_FIXPYG
|
||||||
|
|
||||||
|
|
||||||
class PygmentsBridge:
|
class PygmentsBridge:
|
||||||
|
@ -271,17 +271,6 @@
|
|||||||
%% PYGMENTS
|
%% PYGMENTS
|
||||||
% stylesheet for highlighting with pygments
|
% stylesheet for highlighting with pygments
|
||||||
\RequirePackage{sphinxhighlight}
|
\RequirePackage{sphinxhighlight}
|
||||||
% fix baseline increase from Pygments latex formatter in case of error tokens
|
|
||||||
% and keep \fboxsep's scope local via added braces
|
|
||||||
\def\PYG@tok@err{%
|
|
||||||
\def\PYG@bc##1{{\setlength{\fboxsep}{-\fboxrule}%
|
|
||||||
\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}%
|
|
||||||
}
|
|
||||||
\def\PYG@tok@cs{%
|
|
||||||
\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}}}%
|
|
||||||
}%
|
|
||||||
|
|
||||||
|
|
||||||
%% TABLES
|
%% TABLES
|
||||||
|
Loading…
Reference in New Issue
Block a user