summaryrefslogtreecommitdiff
path: root/sphinx/highlighting.py
diff options
context:
space:
mode:
authorJean-François B <2589111+jfbu@users.noreply.github.com>2022-06-30 14:26:11 +0200
committerJean-François B <2589111+jfbu@users.noreply.github.com>2022-06-30 15:00:16 +0200
commit80198e82aa9174802cb1eb30d69ce7fe98e24399 (patch)
treeaa85c68296bd662543ccbcb17cc55e367e85c3c3 /sphinx/highlighting.py
parentac0fc4b7817389fb8b860d82537f69d9060aabae (diff)
parentb9736f23484b16feef86208ab00dd947c54446ba (diff)
downloadsphinx-git-80198e82aa9174802cb1eb30d69ce7fe98e24399.tar.gz
Merge branch '5.x' into master
Resolved merge conflicts: sphinx/ext/extlinks.py sphinx/ext/napoleon/docstring.py (and removed from the latter a now unused import for flake8 F401 compliance)
Diffstat (limited to 'sphinx/highlighting.py')
-rw-r--r--sphinx/highlighting.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py
index a7e5e4940..b86c31f5e 100644
--- a/sphinx/highlighting.py
+++ b/sphinx/highlighting.py
@@ -40,9 +40,14 @@ escape_hl_chars = {ord('\\'): '\\PYGZbs{}',
ord('}'): '\\PYGZcb{}'}
# used if Pygments is available
-# use textcomp quote to get a true single quote
_LATEX_ADD_STYLES = r'''
+% Sphinx additions
+% use textcomp quote to get a true single quote
\renewcommand\PYGZsq{\textquotesingle}
+\makeatletter
+% use \protected to allow \PYG in \caption
+\protected\def\PYG#1#2{\PYG@reset\PYG@toks#1+\relax+{\PYG@do{#2}}}
+\makeatother
'''
# fix extra space between lines when Pygments highlighting uses \fcolorbox
# add a {..} to limit \fboxsep scope, and force \fcolorbox use correct value
@@ -52,7 +57,7 @@ _LATEX_ADD_STYLES_FIXPYG = r'''
% fix for Pygments <= 2.7.4
\let\spx@original@fcolorbox\fcolorbox
\def\spx@fixpyg@fcolorbox{\fboxsep-\fboxrule\spx@original@fcolorbox}
-\def\PYG#1#2{\PYG@reset\PYG@toks#1+\relax+%
+\protected\def\PYG#1#2{\PYG@reset\PYG@toks#1+\relax+%
{\let\fcolorbox\spx@fixpyg@fcolorbox\PYG@do{#2}}}
\makeatother
'''