|
1 | 1 | %% LITERAL BLOCKS |
2 | 2 | % |
3 | 3 | % change this info string if making any custom modification |
4 | | -\ProvidesFile{sphinxlatexliterals.sty}[2022/06/18 code-blocks and parsed literals] |
| 4 | +\ProvidesFile{sphinxlatexliterals.sty}[2022/06/29 code-blocks and parsed literals] |
5 | 5 |
|
6 | 6 | % Provides support for this output mark-up from Sphinx latex writer: |
7 | 7 | % |
|
99 | 99 | % - frame is \fboxsep separated from the contents, |
100 | 100 | % - the contents use the full available text width, |
101 | 101 | % - #1 = color of frame, #2 = color of background, |
102 | | -% - #3 = above frame, #4 = below frame, #5 = within frame, |
103 | | -% - #3 and #4 must be already typeset boxes; they must issue \normalcolor |
104 | | -% or similar, else, they are under scope of color #1 |
| 102 | +% - #3 = will be typeset above frame, |
| 103 | +% - #4 = will be typeset below frame, |
| 104 | +% - #5 = will be typeset within frame, |
| 105 | +% #3 and #4 must be already typeset boxes. |
| 106 | +% #5 are the contents, and in the context of usage of fancyvrb+framed by |
| 107 | +% Sphinx, it will arrive here already transformed into horizontal |
| 108 | +% boxes. The \normalcolor is a preventive measure to some color issues |
| 109 | +% when a pagebreak occurs in the middle of a wrapped long code line. |
105 | 110 | \long\def\spx@fcolorbox #1#2#3#4#5{% |
106 | 111 | \hskip\@totalleftmargin |
107 | 112 | \hskip-\fboxsep\hskip-\fboxrule |
108 | 113 | % MEMO: \color@b@x from xcolor.sty is identical with the one from color.sty |
109 | | - \color@b@x {\color{#1}\spx@CustomFBox{#3}{#4}}{\color{#2}}{#5}% |
| 114 | + \color@b@x {\spx@CustomFBox{#1}{#3}{#4}}{\color{#2}}{{\normalcolor#5}}% |
110 | 115 | \hskip-\fboxsep\hskip-\fboxrule |
111 | 116 | \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth |
112 | 117 | }% |
113 | | -% #1 = for material above frame, such as a caption or a "continued" hint |
114 | | -% #2 = for material below frame, such as a caption or "continues on next page" |
115 | | -% #3 = actual contents, which will be typeset with a background color |
116 | | -\long\def\spx@CustomFBox#1#2#3{% |
| 118 | +% #1 = color of frame |
| 119 | +% #2 = for material above frame, such as a caption or a "continued" hint |
| 120 | +% #3 = for material below frame, such as a caption or "continues on next page" |
| 121 | +% #4 = contents; or rather if called from \spx@fcolorbox (only use case here), |
| 122 | +% the contents are in \box\z@ and #4 is |
| 123 | +% \color{<bgcolor>}\color@block {\wd \z@ }{\ht \z@ }{\dp \z@ }\box \z@ |
| 124 | +\long\def\spx@CustomFBox#1#2#3#4{% |
117 | 125 | \begingroup |
118 | | - \setbox\@tempboxa\hbox{{#3}}% inner braces to avoid color leaks |
119 | | - \vbox{#1% above frame |
| 126 | + \setbox\@tempboxa\hbox{{#4}}% inner braces to avoid background color leak |
| 127 | + \vbox{#2% above frame |
120 | 128 | % draw frame border _latest_ to avoid pdf viewer issue |
121 | 129 | \kern\fboxrule |
122 | 130 | \hbox{\kern\fboxrule |
123 | 131 | \copy\@tempboxa |
| 132 | + {\color{#1}% frame color |
124 | 133 | \kern-\wd\@tempboxa\kern-\fboxrule |
125 | 134 | \vrule\@width\fboxrule |
126 | 135 | \kern\wd\@tempboxa |
127 | 136 | \vrule\@width\fboxrule}% |
| 137 | + }% |
| 138 | + {\color{#1}% frame color |
128 | 139 | \kern-\dimexpr\ht\@tempboxa+\dp\@tempboxa+\fboxrule\relax |
129 | 140 | \hrule\@height\fboxrule |
130 | 141 | \kern\dimexpr\ht\@tempboxa+\dp\@tempboxa\relax |
131 | | - \hrule\@height\fboxrule |
132 | | - #2% below frame |
| 142 | + \hrule\@height\fboxrule}% |
| 143 | + #3% below frame |
133 | 144 | }% |
134 | 145 | \endgroup |
135 | 146 | }% |
|
145 | 156 | % |
146 | 157 | \def\sphinxVerbatim@Continued |
147 | 158 | {\csname spx@fcolorbox@put@\spx@opt@verbatimcontinuedalign\endcsname |
148 | | - {\normalcolor\sphinxstylecodecontinued\literalblockcontinuedname}}% |
| 159 | + {{\normalcolor\sphinxstylecodecontinued\literalblockcontinuedname}}}% |
149 | 160 | \def\sphinxVerbatim@Continues |
150 | 161 | {\csname spx@fcolorbox@put@\spx@opt@verbatimcontinuesalign\endcsname |
151 | | - {\normalcolor\sphinxstylecodecontinues\literalblockcontinuesname}}% |
| 162 | + {{\normalcolor\sphinxstylecodecontinues\literalblockcontinuesname}}}% |
152 | 163 | \def\sphinxVerbatim@Title |
153 | 164 | {\spx@fcolorbox@put@c{\unhcopy\sphinxVerbatim@TitleBox}}% |
154 | 165 | \let\sphinxVerbatim@Before\@empty |
|
0 commit comments