Debian Codegraph @

texmf-dist/tex/latex/latex-lab/latex-lab-testphase-context.sty

raw
1 %%
2 %% This is file `latex-lab-testphase-context.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% latex-lab-context.dtx (with options: `package')
8 %%
9 %% This is a generated file.
10 %%
11 %% Copyright 2021-2025 LaTeX Project
12 %%
13 %% This file was generated from file(s) of the `LaTeX-lab Bundle'.
14 %% ------------------------------------------------------------------------------------
15 %%
16 %% It may be distributed and/or modified under the
17 %% conditions of the LaTeX Project Public License, either version 1.3c
18 %% of this license or (at your option) any later version.
19 %% The latest version of this license is in
20 %% http://www.latex-project.org/lppl.txt
21 %% and version 1.3c or later is part of all distributions of LaTeX
22 %% version 2008 or later.
23 %%
24 %% This file may only be distributed together with a copy of the LaTeX
25 %% `LaTeX-lab Bundle'. You may however distribute the `LaTeX-lab Bundle'
26 %% without such generated files.
27 %%
28 %% The newest sources can be found below
29 %%
30 %% https://github.com/latex3/latex2e/required/latex-lab
31 %%
32 %% where one can also log issues in case there are any.
33 %%
34 %%
35 %% File: latex-lab-context.dtx (C) Copyright 2025 LaTeX Project
36 \def\ltlabcontextdate{2025-10-09}
37 \def\ltlabcontextversion{0.5b}
38
39 \ProvidesExplPackage {latex-lab-testphase-context}
40 {\ltlabcontextdate}
41 {\ltlabcontextversion}
42 {Providing context for instance, etc.}
43 \RequirePackage{latex-lab-testphase-block}
44 \bool_new:N \g__context_debug_bool
45 \cs_new_eq:NN \__context_debug:n \use_none:n
46 \cs_new_eq:NN \__context_debug_typeout:n \use_none:n
47 \cs_new_protected:Npn \context_debug_on:
48 {
49 \bool_gset_true:N \g__context_debug_bool
50 \__context_debug_gset:
51 }
52 \cs_new_protected:Npn \context_debug_off:
53 {
54 \bool_gset_false:N \g__context_debug_bool
55 \__context_debug_gset:
56 }
57 \cs_new_protected:Npn \__context_debug_gset:
58 {
59 \cs_gset_protected:Npx \__context_debug:n ##1
60 { \bool_if:NT \g__context_debug_bool {##1} }
61 \cs_gset_protected:Npx \__context_debug_typeout:n ##1
62 { \bool_if:NT \g__context_debug_bool { \typeout{[Context]~ ==>~ ##1} } }
63 }
64 \cs_new_protected:Npn \DebugContextsOn { \context_debug_on: }
65 \cs_new_protected:Npn \DebugContextsOff { \context_debug_off: }
66 \DebugContextsOff
67 \str_new:N \l_context_primary_str
68 \cs_new_protected:Npn \SetPrimaryContext #1 {
69 \str_set:Ne \l_context_primary_str
70 { \tl_if_empty:nF { #1 }
71 { \cs_if_exist_use:cF
72 { g__context_primary_ \l_context_primary_str _ #1 _tl }
73 { \cs_if_exist_use:cF
74 { g__context_primary_ * _ #1 _tl }
75 { #1 }
76 }
77 }
78 }
79 \__context_debug_typeout:n{set~primary~ <-~ \l_context_primary_str }
80 \SetSecondaryContext {}
81 }
82 \cs_new_protected:Npn \DeclarePrimaryContextRule #1#2#3 {
83 \tl_gclear_new:c { g__context_primary_ #1 _ #2 _tl }
84 \tl_gset:cn { g__context_primary_ #1 _ #2 _tl } {#3}
85 }
86 \str_new:N \l_context_secondary_str
87 \cs_new_protected:Npn \SetSecondaryContext #1 {
88 \str_set:Ne \l_context_secondary_str
89 { \tl_if_empty:nF { #1 }
90 { \cs_if_exist_use:cF
91 { g__context_secondary_ \l_context_secondary_str _ #1 _tl }
92 { \cs_if_exist_use:cF
93 { g__context_secondary_ * _ #1 _tl }
94 { #1 }
95 }
96 }
97 }
98 \__context_debug_typeout:n{set~ secondary~ <-~ \l_context_secondary_str }
99 }
100 \cs_new_protected:Npn \DeclareSecondaryContextRule #1#2#3 {
101 \tl_gclear_new:c { g__context_secondary_ #1 _ #2 _tl }
102 \tl_gset:cn { g__context_secondary_ #1 _ #2 _tl } {#3}
103 }
104 \def\@setfontsize#1#2#3{\@nomath#1%
105 \ifx\protect\@typeset@protect
106 \let\@currsize#1%
107 \begingroup
108 \escapechar\m@ne
109 \expandafter
110 \endgroup
111 \expandafter
112 \SetSecondaryContext
113 \expandafter {\string#1}%
114 \fi
115 \fontsize{#2}{#3}\selectfont
116 }
117
118 \DeclareSecondaryContextRule{*}{normalsize}{}
119 \AddToHook{cmd/@float/before}{\SetPrimaryContext{float}}
120
121 \cs_set_protected:Npn \__template_use_instance_aux:nn #1#2 {
122 \__template_debug:n { \str_if_empty:NF \l_context_primary_str
123 { \__template_debug_typeout:n {primary~ context~ is~
124 '\l_context_primary_str' } } }
125 \__template_debug:n { \str_if_empty:NF \l_context_secondary_str
126 { \__template_debug_typeout:n {secondary~ context~ is~
127 '\l_context_secondary_str' } } }
128 \tl_if_empty:NTF \l__context_secondary_tl
129 {
130 \str_if_empty:NTF \l_context_primary_str
131 {
132 \__template_if_instance_exist:nnTF { #1 } { #2 }
133 { \__template_use_existing_instance:nn { #1 } { #2 } }
134 { \msg_error:nnnn { template } { unknown-instance } {#1} {#2} }
135 }
136 {
137 \__template_if_instance_exist:nnTF { #1 } { #2 : \l_context_primary_str }
138 { \__template_use_existing_instance:nn { #1 }
139 { #2 : \l_context_primary_str } }
140 {
141 \__template_if_instance_exist:nnTF { #1 } { #2 }
142 { \__template_use_existing_instance:nn { #1 } { #2 } }
143 { \msg_error:nnnn { template } { unknown-instance } {#1} {#2} }
144 }
145 }
146 }
147 {
148 \__template_if_instance_exist:nnTF { #1 }
149 { #2 : \l_context_primary_str
150 : \l_context_secondary_str }
151 { \__template_use_existing_instance:nn { #1 }
152 { #2 : \l_context_primary_str : \l_context_secondary_str } }
153 {
154 \str_if_empty:NTF \l_context_primary_str
155 {
156 \__template_if_instance_exist:nnTF { #1 } { #2 }
157 { \__template_use_existing_instance:nn { #1 } { #2 } }
158 { \msg_error:nnnn { template } { unknown-instance } {#1} {#2} }
159 }
160 {
161 \__template_if_instance_exist:nnTF { #1 }
162 { #2 : \l_context_primary_str }
163 { \__template_use_existing_instance:nn { #1 }
164 { #2 : \l_context_primary_str } }
165 {
166 \__template_if_instance_exist:nnTF { #1 } { #2 }
167 { \__template_use_existing_instance:nn { #1 } { #2 } }
168 { \msg_error:nnnn { template } { unknown-instance } {#1} {#2} }
169 }
170 }
171 }
172 }
173 }
174 \cs_new_protected:Npn \__template_use_existing_instance:nn #1#2 {
175 \__template_debug_typeout:n{use~ '#1'~ instance:~ #2 \on@line }
176 \use:c { \c__template_instances_root_tl #1 / #2 }
177 }
178 \bool_new:N \g__template_debug_bool
179 \cs_new_eq:NN \__template_debug:n \use_none:n
180 \cs_new_eq:NN \__template_debug_typeout:n \use_none:n
181 \cs_new_protected:Npn \template_debug_on:
182 {
183 \bool_gset_true:N \g__template_debug_bool
184 \__template_debug_gset:
185 }
186 \cs_new_protected:Npn \template_debug_off:
187 {
188 \bool_gset_false:N \g__template_debug_bool
189 \__template_debug_gset:
190 }
191 \cs_new_protected:Npn \__template_debug_gset:
192 {
193 \cs_gset_protected:Npx \__template_debug:n ##1
194 { \bool_if:NT \g__template_debug_bool {##1} }
195 \cs_gset_protected:Npx \__template_debug_typeout:n ##1
196 { \bool_if:NT \g__template_debug_bool { \typeout{[Template]~ ==>~ ##1} } }
197 }
198 \cs_new_protected:Npn \DebugTemplatesOn { \template_debug_on: }
199 \cs_new_protected:Npn \DebugTemplatesOff { \template_debug_off: }
200 \DebugTemplatesOn
201 \endinput
202 %%
203 %% End of file `latex-lab-testphase-context.sty'.