From 4b482334a28d0706ba4bd68d51be9c041c135798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20B?= <2589111+jfbu@users.noreply.github.com> Date: Sat, 25 Jun 2022 21:10:34 +0200 Subject: [PATCH 1/3] Fix duplicated field term colons for Docutils 0.18+ (#10595) Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- CHANGES | 2 ++ sphinx/themes/basic/static/basic.css_t | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGES b/CHANGES index 4afa807b6..547533a9b 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,8 @@ Features added Bugs fixed ---------- +* #10594: HTML Theme: field term colons are doubled if using Docutils 0.18+ + Testing -------- diff --git a/sphinx/themes/basic/static/basic.css_t b/sphinx/themes/basic/static/basic.css_t index d8f3fe746..47f802dc4 100644 --- a/sphinx/themes/basic/static/basic.css_t +++ b/sphinx/themes/basic/static/basic.css_t @@ -686,9 +686,11 @@ dl.field-list > dt { padding-right: 5px; } +{%- if docutils_version_info[:2] < (0, 18) %} dl.field-list > dt:after { content: ":"; } +{% endif %} dl.field-list > dd { padding-left: 0.5em; From 5a24fec8de10323de7b46f4d3606765ffc246dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20B?= <2589111+jfbu@users.noreply.github.com> Date: Sat, 25 Jun 2022 22:15:04 +0200 Subject: [PATCH 2/3] Fix build failure for Docutils 0.18.0 (#10597) --- CHANGES | 2 ++ sphinx/util/docutils.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 547533a9b..99a2ab9bf 100644 --- a/CHANGES +++ b/CHANGES @@ -17,6 +17,8 @@ Bugs fixed ---------- * #10594: HTML Theme: field term colons are doubled if using Docutils 0.18+ +* #10596: Build failure if Docutils version is 0.18 (not 0.18.1) due + to missing ``Node.findall()`` Testing -------- diff --git a/sphinx/util/docutils.py b/sphinx/util/docutils.py index e1fd78096..b2944ec28 100644 --- a/sphinx/util/docutils.py +++ b/sphinx/util/docutils.py @@ -550,9 +550,9 @@ class SphinxTranslator(nodes.NodeVisitor): # Node.findall() is a new interface to traverse a doctree since docutils-0.18. -# This applies a patch docutils-0.17 or older to be available Node.findall() +# This applies a patch to docutils up to 0.18 inclusive to provide Node.findall() # method to use it from our codebase. -if docutils.__version_info__ < (0, 18): +if docutils.__version_info__ <= (0, 18): def findall(self, *args, **kwargs): return iter(self.traverse(*args, **kwargs)) From a7ef63a1fd462b72638c7887faa07dbe1d7a02a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20B?= <2589111+jfbu@users.noreply.github.com> Date: Thu, 30 Jun 2022 12:01:36 +0200 Subject: [PATCH 3/3] LaTeX: fix #10506 (make Pygments \PYG macro \protected) --- CHANGES | 2 ++ sphinx/builders/latex/__init__.py | 2 +- sphinx/highlighting.py | 9 +++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 99a2ab9bf..d52b5e70b 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,8 @@ Bugs fixed * #10594: HTML Theme: field term colons are doubled if using Docutils 0.18+ * #10596: Build failure if Docutils version is 0.18 (not 0.18.1) due to missing ``Node.findall()`` +* #10506: LaTeX: build error when using ``:cpp:stuff`` syntax highlighting in + figure caption Testing -------- diff --git a/sphinx/builders/latex/__init__.py b/sphinx/builders/latex/__init__.py index 47aa59344..32f9d32ef 100644 --- a/sphinx/builders/latex/__init__.py +++ b/sphinx/builders/latex/__init__.py @@ -245,7 +245,7 @@ class LaTeXBuilder(Builder): with open(stylesheet, 'w', encoding="utf-8") as f: f.write('\\NeedsTeXFormat{LaTeX2e}[1995/12/01]\n') f.write('\\ProvidesPackage{sphinxhighlight}' - '[2016/05/29 stylesheet for highlighting with pygments]\n') + '[2022/06/30 stylesheet for highlighting with pygments]\n') f.write('% Its contents depend on pygments_style configuration variable.\n\n') f.write(highlighter.get_stylesheet()) 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 '''