Skip to content

Commit

Permalink
LaTeX: apply code cell border style to all code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeier committed Dec 29, 2022
1 parent 936b1b6 commit dc076bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
2 changes: 0 additions & 2 deletions doc/conf.py
Expand Up @@ -140,8 +140,6 @@
%verbatimwithframe=false,
%verbatimwrapslines=false,
%verbatimhintsturnover=false,
VerbatimColor={HTML}{F5F5F5},
VerbatimBorderColor={HTML}{E0E0E0},
noteBorderColor={HTML}{E0E0E0},
noteborder=1.5pt,
warningBorderColor={HTML}{E0E0E0},
Expand Down
25 changes: 11 additions & 14 deletions src/nbsphinx.py
Expand Up @@ -336,16 +336,24 @@
\definecolor{ansi-default-inverse-fg}{HTML}{FFFFFF}
\definecolor{ansi-default-inverse-bg}{HTML}{000000}
% Defaults for all code blocks, including, but not limited to code cells:
\sphinxsetup{VerbatimColor={named}{nbsphinx-code-bg}}
\sphinxsetup{VerbatimBorderColor={named}{nbsphinx-code-border}}
\makeatletter
\@ifpackagelater{sphinx}{2022/06/30}{% Sphinx >= 5.1.0
% Restore settings from Sphinx < 5.1.0:
\sphinxsetup{pre_border-radius=0pt}
\sphinxsetup{pre_box-decoration-break=clone}
}{}
\makeatother
% Define an environment for non-plain-text code cell outputs (e.g. images)
\newbox\nbsphinxpromptbox
\makeatletter
\@ifpackagelater{sphinx}{2022/06/30}{% "later" means here "at least"
% In this branch Sphinx is at least at 5.1.0
\newenvironment{nbsphinxfancyoutput}{%
\sphinxcolorlet{VerbatimColor}{white}%
\sphinxcolorlet{VerbatimBorderColor}{nbsphinx-code-border}%
\sphinxsetup{pre_border-radius=0pt}
\sphinxsetup{pre_box-decoration-break=clone}
\spx@verb@boxes@fcolorbox@setup
% for \sphinxincludegraphics check of maximal height
\spx@image@maxheight \textheight
Expand Down Expand Up @@ -2225,7 +2233,6 @@ def depart_codearea_latex(self, node):
out.append('{') # Start a scope for colors
if 'nbinput' in node.parent['classes']:
promptcolor = 'nbsphinxin'
out.append(r'\sphinxsetup{VerbatimColor={named}{nbsphinx-code-bg}}')
else:
out.append(r"""
\kern-\sphinxverbatimsmallskipamount\kern-\baselineskip
Expand All @@ -2237,16 +2244,6 @@ def depart_codearea_latex(self, node):
out.append(r'\sphinxsetup{VerbatimColor={named}{nbsphinx-stderr}}')
else:
out.append(r'\sphinxsetup{VerbatimColor={named}{white}}')

out.extend([
r'\sphinxsetup{VerbatimBorderColor={named}{nbsphinx-code-border}}',
r'\makeatletter',
r'\@ifpackagelater{sphinx}{2022/06/30}{% Sphinx >= 5.1.0',
r'\sphinxsetup{pre_border-radius=0pt}',
r'\sphinxsetup{pre_box-decoration-break=clone}',
r'}{}',
r'\makeatother',
])
if lines[0].startswith(r'\fvset{'): # Sphinx >= 1.6.6 and < 1.8.3
out.append(lines[0])
del lines[0]
Expand Down

0 comments on commit dc076bd

Please sign in to comment.