Debian Codegraph @

texmf-dist/tex/generic/tex4ht/tcolorbox.4ht

raw
1 % tcolorbox.4ht (2026-03-15-12:59), generated from tex4ht-4ht.tex
2 % Copyright 2020-2026 TeX Users Group
3 %
4 % This work may be distributed and/or modified under the
5 % conditions of the LaTeX Project Public License, either
6 % version 1.3c of this license or (at your option) any
7 % later version. The latest version of this license is in
8 % http://www.latex-project.org/lppl.txt
9 % and version 1.3c or later is part of all distributions
10 % of LaTeX version 2005/12/01 or later.
11 %
12 % This work has the LPPL maintenance status "maintained".
13 %
14 % The Current Maintainer of this work
15 % is the TeX4ht Project <http://tug.org/tex4ht>.
16 %
17 % If you modify this program, changing the
18 % version identification would be appreciated.
19 \immediate\write-1{version 2026-03-15-12:59}
20
21
22 % use custom counter that increments for every \tcolorbox
23 \newcounter{:tcbcolcount}
24
25 \ExplSyntaxOn
26 \def\:tempa{%
27 \stepcounter{:tcbcolcount}%
28 % save text and background colors for use in CSS
29 \get:xcolorcss{tcbcolbacktitle}\:tcbcolbacktitle%
30 \get:xcolorcss{tcbcoltitle}\:tcbcoltitle%
31 \get:xcolorcss{tcbcolback}\:tcbcolback%
32 \get:xcolorcss{tcbcolframe}\:tcbcolframe%
33 \get:xcolorcss{tcbcolupper}\:tcbcolupper%
34 % make unique ID for this box
35 \gdef\:tcbcolid{tcolobox-\arabic{:tcbcolcount}}
36 % Open box
37 \a:tcolorbox%
38 % set label if it exists
39 \ifdefined\tcolorbox:label:key%
40 % at this moment, \@currentlabel has wrong value, because this code is executed
41 % after the contents of the box was typeset. Each line uses \refstepcounter,
42 % so the value of \@currentlabel is the last line number.
43 % We need to restore the values saved in \__tcobox_label:n
44 % The same applies as well to \cref@currentlabel, which is used by cleveref package and other similar commands
45 \let\@currentlabel\tcolorbox:currentlabel
46 \let\cref@currentlabel\tcolorbox:cref@currentlabel
47 %\o:tcb@set@label:{\tcolorbox:label:key}%
48 \AnchorLabel% save cross-ref destination
49 \o:__tcobox_label:n:{\tcolorbox:label:key}%
50 \global\let\tcolorbox:label:key\undefined%
51 \fi%
52 % open title
53 \b:tcolorbox%
54 \ifx\kvtcb@title\@empty\else
55 \kvtcb@before@title\kvtcb@title\kvtcb@after@title%
56 \fi
57 % close title and open main box
58 \c:tcolorbox%
59 \box\tcb@upperbox%
60 % deal with lower box, if it is set
61 \iftcb@hasLower%
62 % the paragraph opened in the upper box can be unclosed, it needs to be closed before
63 % we insert the lower box. It caused issues in the past:
64 % https://github.com/michal-h21/make4ht/issues/142#issuecomment-1891507567
65 % but when we moved the \RecallEndP here, it seems to work
66 \RecallEndP
67 \a:tcolorlowerbox%
68 \box\tcb@lowerbox%
69 \b:tcolorlowerbox%
70 \fi%
71 % We need to close box in \tcb@endboxanddraw
72 }
73 \ExplSyntaxOff
74
75 \HLet\tcb@drawcolorbox\:tempa
76 % overwrite other versions of box drawing macros
77 \HLet\tcb@drawcolorbox@standalone\:tempa
78 \HLet\tcb@drawcolorbox@breakable\:tempa
79
80 % save the state of paragraph before opening the content box
81 \pend:def\tcb@set@@upper@and@lower{\SaveEndP}
82
83 % we need to close tcolorbox environment here,
84 % in the box. otherwise, last paragraph end
85 % would be ignored and we would get invalid XML
86 \def\:tempb{\d:tcolorbox\o:tcb@endboxanddraw:}
87 \HLet\tcb@endboxanddraw\:tempb
88
89 % this should correctly close tcolorbox after the \tcbox command
90 \append:defIII\tcb@ox{\d:tcolorbox}
91
92 % tcolorbox supports libraries, but it loads them
93 % in a way that doesn't register them for the use
94 % with .4ht files.
95 % this fix is for tcblistingscore.code.tex
96 \NewConfigure{tcblisting}{1}
97 \def\:tempb{\o:endtcblisting:\a:tcblisting}
98 \HLet\endtcblisting\:tempb
99
100
101 % this code prevents emptying of the box title when
102 % some Tcolorbox options are used
103 \def\:tempb{}
104 \HLet\tcb@detach@title@code\:tempb
105
106 % require end of paragraph before Tcolorbox
107 \long\def\:tempb[#1]{\EndP\o:tcb@@icolorbox:[#1]}
108 \HLet\tcb@@icolorbox\:tempb
109
110
111 \NewConfigure{tcolorbox}{4}
112 \NewConfigure{tcolorlowerbox}{2}
113
114 % we need to save current label for a later use
115 \def\:tempa#1{%
116 \xdef\tcolorbox:label:key{#1}%
117 \global\let\tcolorbox:currentlabel\@currentlabel%
118 \global\let\tcolorbox:cref@currentlabel\cref@currentlabel
119
120 }
121
122 \ExplSyntaxOn
123 %\HLet\tcb@set@label\:tempa
124 \HLet\__tcobox_label_label:n\:tempa
125 \HLet\__tcobox_label_zlabel:n\:tempa
126 \HLet\__tcobox_label:n\:tempa
127 \ExplSyntaxOff
128
129 \pend:def\tcb@minipage{\SaveEndP}
130 \pend:def\tcb@minipage@top{\SaveEndP}
131 \pend:def\tcb@minipage@bottom{\SaveEndP}
132 \pend:def\tcb@minipage@center{\SaveEndP}
133
134
135 \AfterEndPreamble{%
136 % fix \nameref support
137 \def\:tempa#1{%
138 \gdef\NR:Title{\a:newlabel{#1}}%
139 \o:tcb@gettitle:{#1}%
140 }%
141 \HLet\tcb@gettitle\:tempa
142 }
143
144
145 \ifdefined\tcb@manual@entry
146 \Hinput{tcolorbox.documentation}
147 \fi
148
149 \Hinput{tcolorbox}
150 \endinput
151
152
153
154