Skip to content

Commit

Permalink
sphinxbox_wip [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
jfbu committed Mar 7, 2023
1 parent f8a5183 commit 8dca35d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
18 changes: 14 additions & 4 deletions sphinx/texinputs/sphinx.sty
Expand Up @@ -311,8 +311,6 @@ will be set to white}%
% Except that \sphinxbox is for boxing inline elements (no linebreak, no
% pagebreak).
%
% (this addition happens in a descendant commit of this one)
%
% MEMO: the 6.2.0 refactoring induced a change that the default \fboxrule used
% by verbatimborder and shadowrule is now not expanded to its value immediately in
% preamble (no assignment to a \dimen register is done, only storage in a
Expand Down Expand Up @@ -361,6 +359,8 @@ will be set to white}%
\spx@tempa{spx@attention@}{div.attention_}{attentionborder}{1pt}
\spx@tempa{spx@danger@} {div.danger_} {dangerborder} {1pt}
\spx@tempa{spx@error@} {div.error_} {errorborder} {1pt}
% this one new at 6.2.0:
\spx@tempa{spx@box@} {box_} {boxborder} \fboxrule
% Set default box-decoration-break style for codeblocks to slice
\spx@pre@border@opentrue % new default at 6.0.0: slice, not clone

Expand Down Expand Up @@ -401,12 +401,11 @@ will be set to white}%
\spx@tempa{spx@attention@}{div.attention_} {\dimexpr.6\baselineskip-\spx@attention@border\relax}
\spx@tempa{spx@danger@} {div.danger_} {\dimexpr.6\baselineskip-\spx@danger@border\relax}
\spx@tempa{spx@error@} {div.error_} {\dimexpr.6\baselineskip-\spx@error@border\relax}
\spx@tempa{spx@box@} {box_} \fboxsep % new at 6.2.0
% define legacy verbatimsep key as alias of pre_padding key
\expandafter\let\expandafter\KV@sphinx@verbatimsep\csname KV@sphinx@pre_padding\endcsname
% define legacy shadowsep key as alias of div.topic_padding key
\expandafter\let\expandafter\KV@sphinx@shadowsep\csname KV@sphinx@div.topic_padding\endcsname
% (temporary explanation: this next comment and code line belong to a descendant
% commit down the line for \sphinxbox support, left-overs from a rebase)
% also define a boxsep key as alias of box_padding key, because we defined boxborder
% boxborder was defined only as collateral of batch definitions so some hesitation
% we do keep these boxborder and boxsep as they configure the probably two most
Expand Down Expand Up @@ -438,6 +437,7 @@ will be set to white}%
\spx@tempa{spx@attention@}{div.attention_} \z@
\spx@tempa{spx@danger@} {div.danger_} \z@
\spx@tempa{spx@error@} {div.error_} \z@
\spx@tempa{spx@box@} {box_} {3pt}% new and tentative at 6.2.0

% Shadow keys
%
Expand All @@ -455,6 +455,7 @@ will be set to white}%
\spx@tempa{spx@attention@}
\spx@tempa{spx@danger@}
\spx@tempa{spx@error@}
\spx@tempa{spx@box@}% new at 6.2.0
%
\def\spx@tempa#1{% #1 = macro prefix
\expandafter\spx@tempb
Expand Down Expand Up @@ -495,6 +496,7 @@ will be set to white}%
\spx@tempa{spx@attention@}{div.attention_}
\spx@tempa{spx@danger@} {div.danger_}
\spx@tempa{spx@error@} {div.error_}
\spx@tempa{spx@box@} {box_}% new at 6.2.0

% Support for legacy shadowsize
% This definition was broken at 5.1.0 and fixed at 6.1.2
Expand Down Expand Up @@ -567,6 +569,7 @@ will be set to white}%
\spx@tempa{spx@attention@}{div.attention_} {sphinxattention}
\spx@tempa{spx@danger@} {div.danger_} {sphinxdanger}
\spx@tempa{spx@error@} {div.error_} {sphinxerror}
\spx@tempa{spx@box@} {box_} {sphinxbox}% new at 6.2.0
% Keep legacy sphinxsetup interface for warning type notices
\def\spx@tempa#1#2{% #1 = option prefix, #2 = legacy option prefix
\expandafter\let\csname KV@sphinx@#2BorderColor\expandafter\endcsname
Expand Down Expand Up @@ -680,6 +683,13 @@ will be set to white}%

%% FRAMED ENVIRONMENTS
%
% \sphinxbox added at 6.2.0, support code in sphinxpackageboxes
% some of these defaults are already set, we repeat here via \sphinxsetup
\sphinxsetup{boxborder=\fboxrule,
boxsep=\fboxsep,
box_border-radius=3pt,
% border left without specific color, i.e. uses a priori black
box_background-TeXcolor=VerbatimColor}%
\RequirePackage{sphinxpackageboxes}
\def\spx@RequirePackage@PictIIe{%
\IfFileExists{pict2e.sty}
Expand Down
18 changes: 18 additions & 0 deletions sphinx/texinputs/sphinxpackageboxes.sty
Expand Up @@ -135,6 +135,24 @@
\fi
}

%%%%%%%%%%%%%%%%
% \sphinxbox (added at 6.2.0)
%
% For an inline box, possibly rounded.
\newcommand\sphinxbox[1][]{% #1 stands for the options, they are... optional!
\begingroup
\sphinxsetup{#1}% supposedly only "box" related options used here,
% setting other options is possible but will have a priori no effect
\spx@boxes@fcolorbox@setup
{box}
{sphinxboxBorderColor}
{sphinxboxBgColor}
{sphinxboxShadowColor}%
\setbox0\hbox\bgroup\aftergroup\spx@boxes@sphinxbox@a
\let\next=%
}
\def\spx@boxes@sphinxbox@a{\spx@boxes@fcolorbox{\box\z@}\endgroup}

%%%%%%%%%%%%%%%%
% MACROS
%
Expand Down

0 comments on commit 8dca35d

Please sign in to comment.