Debian Codegraph @

texmf-dist/source/latex/ltx-talk/ltx-talk-structure.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: ltx-talk-structure.dtx Copyright (C) 2024-2026 Joseph Wright
4 %
5 % It may be distributed and/or modified under the conditions of the
6 % LaTeX Project Public License (LPPL), either version 1.3c of this
7 % license or (at your option) any later version. The latest version
8 % of this license is in the file
9 %
10 % https://www.latex-project.org/lppl.txt
11 %
12 % This file is part of the "ltx-talk bundle" (The Work in LPPL)
13 % and all files in that bundle must be distributed together.
14 %
15 % The released version of this bundle is available from CTAN.
16 %
17 % -----------------------------------------------------------------------
18 %
19 % The development version of the bundle can be found at
20 %
21 % https://github.com/josephwright/ltx-talk
22 %
23 % for those people who are interested.
24 %
25 % -----------------------------------------------------------------------
26 %
27 %<*driver>
28 \documentclass{l3doc}
29 % Additional commands needed in this source
30 \NewDocumentCommand\email{m}{\href{mailto:#1}{\nolinkurl{#1}}}
31 \begin{document}
32 \DocInput{\jobname.dtx}
33 \end{document}
34 %</driver>
35 % \fi
36 %
37 % ^^A As we are dealing with a class, this has to be done manually
38 % \def\filedate{2026-04-30}
39 % \def\fileversion{v0.5.0}
40 %
41 % \title{^^A
42 % \pkg{ltx-talk-structure} -- Structural commands^^A
43 % \thanks{This file describes \fileversion,
44 % last revised \filedate.}^^A
45 % }
46 %
47 % \author{^^A
48 % Joseph Wright^^A
49 % \thanks{^^A
50 % E-mail: \email{[email protected]}^^A
51 % }^^A
52 % }
53 %
54 % \date{Released \filedate}
55 %
56 % \maketitle
57 %
58 % \begin{documentation}
59 %
60 % \end{documentation}
61 %
62 % \begin{implementation}
63 %
64 % \section{\pkg{ltx-talk-structure} implementation}
65 %
66 % Start the \pkg{DocStrip} guards.
67 % \begin{macrocode}
68 %<*class>
69 % \end{macrocode}
70 %
71 % Identify the internal prefix.
72 % \begin{macrocode}
73 %<@@=talk>
74 % \end{macrocode}
75 %
76 % \subsection{Frame title}
77 %
78 % \begin{variable}{\g_@@_frame_title_tl, \g_@@_frame_subtitle_tl}
79 % \begin{macrocode}
80 \tl_new:N \g_@@_frame_title_tl
81 \tl_new:N \g_@@_frame_subtitle_tl
82 % \end{macrocode}
83 % \end{variable}
84 %
85 % \begin{macro}{\frametitle}
86 % Just data storage: at the present no use of the optional argument.
87 % \begin{macrocode}
88 \NewDocumentCommand \frametitle { D <> { all } O {#3} m }
89 {
90 \@@_if_overlay:nT {#1}
91 { \tl_gset:Nn \g_@@_frame_title_tl {#3} }
92 }
93 \NewDocumentCommand \framesubtitle { D <> { all } O {#3} m }
94 {
95 \@@_if_overlay:nT {#1}
96 { \tl_gset:Nn \g_@@_frame_subtitle_tl {#3} }
97 }
98 % \end{macrocode}
99 % \end{macro}
100 %
101 % \begin{macro}{\@@_frame_title:n, \@@_frame_title_tagged:n}
102 % Inserting the frame title requires we deal with tagging as well as
103 % appearance: if there is a title, we need to tag just this part of the
104 % header.
105 % \begin{macrocode}
106 \NewTemplateType { frametitle } { 1 }
107 \DeclareTemplateInterface { frametitle } { talk } { 1 }
108 {
109 after-vspace : skip = \bigskipamount ,
110 before-vspace : skip = 0em ,
111 color : tokenlist = ,
112 font : tokenlist = \Large \bfseries
113 }
114 \DeclareTemplateCode { frametitle } { talk } { 1 }
115 {
116 after-vspace = \l_@@_frametitle_after_skip ,
117 before-vspace = \l_@@_frametitle_before_skip ,
118 color = \l_@@_frametitle_color_tl ,
119 font = \l_@@_frametitle_font_tl
120 }
121 {
122 \noindent
123 \vspace { \l_@@_frametitle_before_skip }
124 \group_begin:
125 \tl_if_empty:NF \l_@@_frametitle_color_tl
126 { \color_select:V \l_@@_frametitle_color_tl }
127 \l_@@_frametitle_font_tl
128 \tl_if_blank:nF {#1}
129 { \@@_frame_title:n {#1} }
130 \par
131 \group_end:
132 \vspace { \l_@@_frametitle_after_skip }
133 }
134 \DeclareInstance { frametitle } { header } { talk } { }
135 \cs_new_protected:Npn \@@_frame_title:n #1
136 {
137 \bool_if:NTF \g_@@_frame_tag_bool
138 { \@@_frame_title_tagged:n }
139 { \use:n }
140 {#1}
141 }
142 \cs_new_protected:Npn \@@_frame_title_tagged:n #1
143 {
144 \@@_header_tag_begin:e
145 {
146 firstkid = true ,
147 parent = \int_use:N \g_@@_frame_struct_int ,
148 tag = frametitle ,
149 title = { \text_purify:n { \g_@@_frame_title_tl } } ,
150 }
151 \group_begin:
152 \tagpdfparaOff
153 #1
154 \group_end:
155 \@@_header_tag_end:
156 }
157 % \end{macrocode}
158 % \end{macro}
159 %
160 % \subsection{Headings}
161 %
162 % \begin{variable}
163 % {
164 % \l_@@_section_tl ,
165 % \g_@@_section_tl ,
166 % \l_@@_subsection_tl ,
167 % \g_@@_subsection_tl ,
168 % \l_@@_subsubsection_tl ,
169 % \g_@@_subsubsection_tl
170 % }
171 % Two versions of the data store: one set locally (but at the top level) for
172 % general use, one set (and more importantly cleared) globally to allow
173 % insertion in the header area just once per name.
174 % \begin{macrocode}
175 \tl_new:N \l_@@_section_tl
176 \tl_new:N \g_@@_section_tl
177 \tl_new:N \l_@@_subsection_tl
178 \tl_new:N \g_@@_subsection_tl
179 \tl_new:N \l_@@_subsubsection_tl
180 \tl_new:N \g_@@_subsubsection_tl
181 % \end{macrocode}
182 % \end{variable}
183 %
184 % \begin{variable}
185 % {
186 % \l_@@_sec_bookmark_tl ,
187 % \l_@@_sec_label_tl ,
188 % \l_@@_sec_nameref_tl ,
189 % \l_@@_sec_numbered_bool ,
190 % \l_@@_sec_quote_tl ,
191 % \l_@@_sec_running_tl ,
192 % \l_@@_sec_subtitle_tl ,
193 % \l_@@_sec_toc_tl
194 % }
195 % Here, we set up the same keyval interface as used by the kernel
196 % (see \file{latex-lab-sec-template.dtx})
197 % \begin{macrocode}
198 \keys_define:nn { talk / heading }
199 {
200 bookmark .tl_set:N =
201 \l_@@_sec_bookmark_tl ,
202 label .code:n =
203 { \tl_put_right:N \l_@@_sec_label_tl { \label {#1} } } ,
204 nameref .tl_set:N =
205 \l_@@_sec_nameref_tl ,
206 numbered .bool_set:N
207 = \l_@@_sec_numbered_bool ,
208 numbered .default:n
209 = true ,
210 unnumbered .bool_set_inverse:N
211 = \l_@@_sec_numbered_bool ,
212 unnumbered .default:n
213 = true ,
214 quote .tl_set:N =
215 \l_@@_sec_quote_tl ,
216 running .tl_set:N =
217 \l_@@_sec_running_tl ,
218 shorttitle .meta:n =
219 {
220 bookmark = {#1} ,
221 nameref = {#1} ,
222 running = {#1} ,
223 toc = {#1}
224 } ,
225 subtitle .tl_set:N =
226 \l_@@_sec_subtitle_tl ,
227 toc .tl_set:N =
228 \l_@@_sec_toc_tl
229 }
230 \tl_new:N \l_@@_sec_label_tl
231 % \end{macrocode}
232 % \end{variable}
233 %
234 % \begin{macro}{\section, \subsection, \subsubsection}
235 % \begin{macro}{\thesection, \thesubsection, \thesubsubsection}
236 % Here, we need full \LaTeX{} counters, so create them using the appropriate
237 % mechanism: that also means we can sort out counter dependency and the
238 % appearance (using the same setup as in \pkg{article}). As (subsub)section
239 % numbers never increment inside frames, we remove these counters from the
240 % general tracker.
241 % \begin{macrocode}
242 \newcounter { section }
243 \newcounter { subsection } [ section ]
244 \newcounter { subsubsection } [ subsection ]
245 \seq_gremove_all:Nn \g_@@_cnt_reset_seq { section }
246 \seq_gremove_all:Nn \g_@@_cnt_reset_seq { subsection }
247 \seq_gremove_all:Nn \g_@@_cnt_reset_seq { subsubsection }
248 \cs_gset:Npn \thesection { \@arabic \c@section }
249 \cs_gset:Npn \thesubsection { \thesection . \@arabic \c@subsection }
250 \cs_gset:Npn \thesubsubsection { \thesubsection . \@arabic \c@subsubsection }
251 % \end{macrocode}
252 % \end{macro}
253 % \end{macro}
254 %
255 % \begin{macro}{\section, \subsection, \subsubsection}
256 % \begin{macro}
257 % {
258 % \insertsection ,
259 % \insertsubsection ,
260 % \insertsubsubsection
261 % }
262 % \begin{macro}
263 % {
264 % \@@_head_section:Nnn,
265 % \@@_head_subsection:Nnn,
266 % \@@_head_subsubsection:Nnn
267 % }
268 % The sectioning commands all have essentially the same form: we therefore
269 % create using a generator with the necessary conditionals in place. As we
270 % do not typeset sections at this stage, the code is quite different from
271 % \pkg{article}. This also means that the bookmark links need to point forward
272 % to the next slide: if that doesn't appear, the bookmarks will be out. Using
273 % the general scratch sequence here should be OK: it really is a one-off
274 % setting. We need a sequence to allow indexed mapping to avoid any extra
275 % setup for the depth value.
276 % \begin{macrocode}
277 \seq_set_from_clist:Nn \l_tmpa_seq
278 { section , subsection , subsubsection }
279 \seq_map_indexed_inline:Nn \l_tmpa_seq
280 {
281 \use:e
282 {
283 \NewDocumentCommand \exp_not:c { insert #2 } { }
284 {
285 \exp_not:N \tl_use:N
286 \exp_not:c { l_@@_ #2 _tl }
287 }
288 \NewDocumentCommand \exp_not:c {#2}
289 { s D <> { all } = { shorttitle } O {##4} m }
290 {
291 \exp_not:N \bool_if:NF \exp_not:N \l_@@_frame_bool
292 {
293 \@@_if_overlay:nT {##2}
294 { \exp_not:c { @@_head_ #1 :Nnn } ##1 {##3} {##4} }
295 }
296 }
297 \cs_new_protected:Npn \exp_not:c { @@_head_ #1 :Nnn } ##1##2##3
298 {
299 \exp_not:N \refstepcounter {#2}
300 \UseTaggingSocket { sec / end } { \use:c { toclevel@ #2 } }
301 \UseTaggingSocket { sec / begin }
302 {
303 { \use:c { toclevel@ #2 } }
304 {
305 tag =
306 \exp_not:N \UseStructureName
307 { sec / \use:c { toclevel@ #2 } }
308 }
309 }
310 \tl_set:Nn \exp_not:c { l_@@_ #2 _tl } {##3}
311 \keys_set:nn { talk / heading } { shorttitle = {##3} , ##2 }
312 \exp_not:N \bool_if:NT ##1
313 {
314 \tl_clear:N \exp_not:N \l_@@_sec_bookmark_tl
315 \tl_clear:N \exp_not:N \l_@@_sec_running_tl
316 \tl_clear:N \exp_not:N \l_@@_sec_toc_tl
317 \bool_set_false:N \exp_not:N \l_@@_sec_numbered_bool
318 }
319 \UseTaggingSocket { talk / sec / title } {#2}
320 \str_if_eq:nnT {#2} { section }
321 { \tl_clear:N \exp_not:N \l_@@_subsection_tl }
322 \str_if_eq:nnF {#2} { subsubsection }
323 { \tl_clear:N \exp_not:N \l_@@_subsubsection_tl }
324 \exp_not:N \@@_head_marks:nnVVV {#2} {#1}
325 \exp_not:N \l_@@_sec_toc_tl
326 \exp_not:N \l_@@_sec_bookmark_tl
327 \exp_not:N \l_@@_sec_nameref_tl
328 \hook_use:n { #2 / begin }
329 }
330 \hook_new:n { #2 / begin }
331 }
332 }
333 % \end{macrocode}
334 % \end{macro}
335 % \end{macro}
336 % \end{macro}
337 % \begin{macro}
338 % {
339 % \addcontentslinebookmark ,
340 % \addcontentslinebookmarkOff ,
341 % \addcontentslinebookmarkOn
342 % }
343 % Patches as in \file{latex-lab-sec-template.dtx}.
344 % \begin{macrocode}
345 \providecommand \addcontentslinebookmark [ 3 ] { }
346 \providecommand \addcontentslinebookmarkOff { }
347 \providecommand \addcontentslinebookmarkReset { }
348 \providecommand \texorpdfstring [ 2 ] {#1}
349 % \end{macrocode}
350 % \end{macro}
351 % \begin{macro}{\@@_head_marks:nnnnn, \@@_head_marks:nnVVV}
352 % \begin{macro}{\@@_head_marks_aux:Nnn}
353 % For handling bookmarks, TOC, \foreign{etc.}: the naming here follows the
354 % \LaTeX{} kernel, as does the code in general, but with some minor
355 % adjustments.
356 % \begin{macrocode}
357 \cs_new_protected:Npn \@@_head_marks:nnnnn #1#2#3#4#5
358 {
359 \tl_set:Nn \@currentlabelname {#5}
360 \tl_if_blank:nTF {#3}
361 {
362 \tl_if_blank:nF {#4}
363 {
364 \@@_head_marks_aux:Nnnn
365 \addcontentslinebookmark {#1} {#2} {#4}
366 }
367 }
368 {
369 \tl_if_blank:nT {#4}
370 { \addcontentslinebookmarkOff }
371 \@@_head_marks_aux:Nnnn
372 \addcontentsline {#1} {#2} { \texorpdfstring {#3} {#4} }
373 }
374 }
375 \cs_generate_variant:Nn \@@_head_marks:nnnnn { nnVVV }
376 \cs_new_protected:Npn \@@_head_marks_aux:Nnnn #1#2#3#4
377 {
378 #1 { toc } {#2}
379 {
380 \int_compare:nNnF {#3} > { \value { secnumdepth } }
381 { \protect \numberline { \use:c { the #2 } } }
382 #4
383 }
384 }
385 % \end{macrocode}
386 % \end{macro}
387 % \end{macro}
388 %
389 % \begin{macro}{talk/sec/title}
390 % \begin{macro}{\@@_head_tag:nn}
391 % The argument is one of section, subsection or subsubsection.
392 % \begin{macrocode}
393 \NewTaggingSocket { talk / sec / title } { 1 }
394 \NewTaggingSocketPlug { talk / sec / title } { default }
395 {
396 \exp_args:Ne \@@_head_tag:nn
397 { \text_purify:v { l_@@_ #1 _ tl } } {#1}
398 }
399 \cs_new_protected:Npn \@@_head_tag:nn #1#2
400 {
401 \tag_struct_begin:e
402 {
403 tag =
404 \UseStructureName { sec / \use:c { toclevel@ #2 } / title } ,
405 title = {#1} ,
406 actualtext = {#1} ,
407 }
408 \tag_struct_end:
409 }
410 \AssignTaggingSocketPlug { talk / sec / title } { default }
411 % \end{macrocode}
412 % \end{macro}
413 % \end{macro}
414 %
415 % \subsection{Table of contents}
416 %
417 % \begin{macro}{\@starttoc}
418 % The standard kernel implementation here deliberately overwrites the file
419 % as soon as it's read. That's no good for us as the table of contents can
420 % be read multiple times. So we modify the code: we start from the
421 % tagging-aware version (this may need to be revisited). We retain the
422 % \LaTeXe{} code as much as possible.
423 % \begin{macrocode}
424 \cs_gset_protected:Npn \@starttoc #1
425 {
426 \begingroup
427 \makeatletter
428 \UseTaggingSocket { toc / starttoc / before } {#1}
429 \@input { \jobname .#1 }
430 \UseTaggingSocket { toc / starttoc / after } {#1}
431 \legacy_if:nT { @filesw }
432 {
433 \AddToHook { enddocument / afterlastpage }
434 {
435 \expandafter \newwrite \csname tf@ #1 \endcsname
436 \immediate \openout \csname tf@ #1 \endcsname \jobname .#1 \relax
437 }
438 }
439 \@nobreakfalse
440 \endgroup
441 }
442 % \end{macrocode}
443 % \end{macro}
444 %
445 % \begin{macro}{\tableofcontents}
446 % For the present simply print the output.
447 % \begin{macrocode}
448 \NewDocumentCommand \tableofcontents { O { } }
449 {
450 \group_begin:
451 \@starttoc { toc }
452 \group_end:
453 }
454 % \end{macrocode}
455 % \end{macro}
456 %
457 % \begin{macro}{\l@section, \l@subsection, \l@subsubsection}
458 % \begin{macro}{\@@_toc_aux:nnnn}
459 % \begin{macro}{\@@_toc_dest:n}
460 % \begin{macro}{\@@_toc_dest:w}
461 % \begin{macro}{\@@_toc_level:nnnn}
462 % Initial hard-coded versions to be templated once we have some other effects
463 % also working. We may need to look at this \enquote{higher up} as we will need
464 % to know the section numbers.
465 % \begin{macrocode}
466 \cs_new_protected:Npn \l@section #1#2
467 { \@@_toc_aux:nnnn { 1 } { \bfseries \color { structure } } {#1} {#2} }
468 \cs_new_protected:Npn \l@subsection #1#2
469 {
470 \@@_toc_aux:nnnn
471 { 2 }
472 {
473 \skip_set:Nn \leftskip { 2em }
474 \color_ensure_current:
475 }
476 {#1} {#2}
477 }
478 \cs_new_protected:Npn \l@subsubsection #1#2
479 {
480 \@@_toc_aux:nnnn
481 { 3 }
482 {
483 \skip_set:Nn \leftskip { 4em }
484 \color_ensure_current:
485 \footnotesize
486 }
487 {#1} {#2}
488 }
489 \cs_new_protected:Npn \@@_toc_aux:nnnn #1#2#3#4
490 {
491 \int_compare:nNnTF { \value { section } } < 1
492 { \use:n }
493 { \@@_toc_dest:n }
494 { \@@_toc_level:nnnn {#1} {#2} {#3} {#4} }
495 }
496 % \end{macrocode}
497 % We can extract the details for the TOC levels from
498 % \tn{@contentsline@destination}. At present, that is quite simple-minded:
499 % if we are in the current section, show fully, else make semi-opaque. Needs
500 % a rounded-out interface but the basic idea will be the same.
501 % \begin{macrocode}
502 \cs_new_protected:Npn \@@_toc_dest:n
503 {
504 \exp_after:wN \@@_toc_dest:w \@contentsline@destination
505 . 0 . 0 . 0 . \q_stop
506 }
507 \cs_new_protected:Npn \@@_toc_dest:w #1 . #2 . #3 . #4 . #5 \q_stop #6
508 {
509 \bool_lazy_or:nnTF
510 {
511 \bool_lazy_and_p:nn
512 { \int_compare_p:nNn { \value { section } } = {#2} }
513 { \int_compare_p:nNn { \value { subsection } } = 0 }
514 }
515 {
516 \bool_lazy_and_p:nn
517 { \int_compare_p:nNn { \value { section } } = {#2} }
518 { \int_compare_p:nNn { \value { subsection } } = {#3} }
519 }
520 {#6}
521 {
522 \opacity_begin:n { 0.2 }
523 #6
524 \opacity_end:
525 }
526 }
527 \cs_new_protected:Npn \@@_toc_level:nnnn #1#2#3#4
528 {
529 \int_compare:nNnF {#1} > { \value { tocdepth } }
530 {
531 \group_begin:
532 \noindent
533 #2
534 \UseHookWithArguments { contentsline / text / before } { 4 }
535 {#1} {#3} {#4} { \@contentsline@destination }
536 #3
537 \UseHookWithArguments { contentsline / text / after } { 4 }
538 {#1} {#3} {#4} { \@contentsline@destination }
539 \UseHookWithArguments { contentsline / page / before } { 4 }
540 {#1} {#3} {#4}
541 { \@contentsline@destination }
542 \UseHookWithArguments { contentsline / page / after } { 4 }
543 {#1} {#3} {#4}
544 { \@contentsline@destination }
545 \par
546 \group_end:
547 \vfil
548 }
549 }
550 % \end{macrocode}
551 % \end{macro}
552 % \end{macro}
553 % \end{macro}
554 % \end{macro}
555 % \end{macro}
556 %
557 % \begin{macrocode}
558 \setcounter { tocdepth } { 2 }
559 % \end{macrocode}
560 %
561 % \subsection{Block environments}
562 %
563 % \begin{environment}{description, quote, quotation, verse}
564 % \begin{environment}{stdquote, stdquotation, stdverse}
565 % Stub logical environments: needed as the tagging setup expects these
566 % to exist.
567 % \begin{macrocode}
568 \NewDocumentEnvironment { description } { } { } { }
569 \NewDocumentEnvironment { quote } { } { } { }
570 \NewDocumentEnvironment { quotation } { } { } { }
571 \NewDocumentEnvironment { verse } { } { } { }
572 \AddToHook { begindocument / before }
573 {
574 \clist_map_inline:nn { quote , quotation , verse }
575 {
576 \NewEnvironmentCopy { std #1 } {#1}
577 \RenewDocumentEnvironment {#1} { d <> !O { } }
578 {
579 \@@_action_begin:n {##1}
580 \begin { std #1 } [ {##2} ]
581 \ignorespaces
582 }
583 {
584 \end { std #1 }
585 \@@_action_end:
586 }
587 }
588 }
589 % \end{macrocode}
590 % \end{environment}
591 % \end{environment}
592 %
593 % \begin{environment}{block}
594 % \begin{macrocode}
595 \NewDocumentEnvironment { block } { d <> m }
596 {
597 \@@_action_begin:n {#1}
598 \par
599 \vbox_set:Nw \l_@@_tmp_box
600 \group_begin:
601 \medskip
602 \leavevmode
603 \normalfont \large \bfseries
604 \color { structure }
605 #2
606 \par
607 \medskip
608 \group_end:
609 }
610 {
611 \vbox_set_end:
612 \box_use:N \l_@@_tmp_box
613 \par
614 \@@_action_end:
615 }
616 % \end{macrocode}
617 % \end{environment}
618 %
619 % \subsection{Lists}
620 %
621 % \begin{macro}{\item}
622 % \begin{macro}{\@@_item_parse_spec:w}
623 % \begin{macro}{\@@_item_parse_spec:n}
624 % Again, add the additional argument: here, we have to do a little
625 % gymnastics. The test for an overlay has to come after the standard item
626 % definition: in a list, items have to \emph{close} the structure before
627 % them first, so if we test too early, we'd end up covering then uncovering
628 % straight away! Once it is stable, we should revisit here to see if it would
629 % be sensible to use the hook mechanism.
630 % \begin{macrocode}
631 \AddToHook { begindocument / before }
632 {
633 \NewCommandCopy \stditem \item
634 \RenewDocumentCommand \item { d <> o }
635 {
636 \IfNoValueTF {#2}
637 { \stditem }
638 { \stditem [ {#2} ] }
639 \IfNoValueTF {#1}
640 {
641 \exp_after:wN \@@_item_parse_spec:w
642 \l_@@_action_spec_str < all > \q_stop
643 }
644 { \@@_item_parse_spec:n {#1} }
645 }
646 }
647 % \end{macrocode}
648 % Parsing the spec is a separate function here as there are a couple of
649 % routes to get here. At present we only have a \texttt{false} branch, but
650 % for spacing we likely will need to add something to the \texttt{true}
651 % branch too. The odd stuff with \tn{currentgrouplevel} here is needed
652 % so we only close the item at the correct nesting, allowing for the
653 % group that gets added.
654 % \begin{macrocode}
655 \cs_new_protected:Npn \@@_item_parse_spec:w #1 < #2 > #3 \q_stop
656 { \@@_item_parse_spec:n {#2} }
657 \cs_new_protected:Npn \@@_item_parse_spec:n #1
658 {
659 \bool_lazy_or:nnF
660 { \tl_if_blank_p:n {#1} }
661 { \str_if_eq_p:nn {#1} { all } }
662 {
663 \tl_set:Ne \l_@@_list_end_tl
664 {
665 \exp_not:N \int_compare:nNnT \tex_currentgrouplevel:D =
666 { \int_eval:n { \tex_currentgrouplevel:D + 1 } }
667 {
668 \@@_action_end:
669 \tl_clear:N \exp_not:N \l_@@_list_end_tl
670 }
671 }
672 \@@_action_begin:n {#1}
673 }
674 }
675 % \end{macrocode}
676 % \end{macro}
677 % \end{macro}
678 % \end{macro}
679 % \begin{variable}{\l_@@_list_end_tl}
680 % \begin{macrocode}
681 \tl_new:N \l_@@_list_end_tl
682 % \end{macrocode}
683 % \end{variable}
684 % \begin{macro}{\__block_inter_item:, \BlockEnvEnd, \endblockenv}
685 % Before \LaTeX{} 2026-6-01, there was no hook pair for surrounding items, so
686 % so patching had to be done. The extra complexity here is that there
687 % is no test for hook existence, and the hook was not in the first
688 % dev release of 2026-06-01. So there is some low-level testing needed:
689 % \cs{l__block_topsepadd_skip} is used as a marker.
690 % \begin{macrocode}
691 \cs_if_exist:NTF \l__block_topsepadd_skip
692 {
693 \cs_gset_protected:Npn \__block_inter_item:
694 {
695 \legacy_if:nT { @inlabel }
696 { \indent \par }
697 \mode_if_horizontal:T
698 {
699 \__block_skip_remove_last:
700 \__block_skip_remove_last:
701 \par
702 }
703 \l_@@_list_end_tl
704 \__kernel_list_item_end:
705 \__kernel_list_item_begin:
706 \addpenalty \@itempenalty
707 \addvspace \itemsep
708 }
709 % \end{macrocode}
710 % A rather long block done by expansion to avoid duplication in a patch.
711 % \begin{macrocode}
712 \IfFormatAtLeastTF { 2026-06-01 }
713 { \cs_gset_protected:Npe \BlockEnvEnd }
714 { \cs_gset:Npe \endblockenv }
715 {
716 \exp_not:n
717 { \__block_debug_typeout:n { blockenv~common~ending \on@line } }
718 \cs_if_exist:NTF \l__block_transparent_level_bool
719 {
720 \exp_not:N \bool_if:NF
721 \exp_not:N \l__block_transparent_level_bool
722 }
723 {
724 \exp_not:N \bool_if:NT
725 \exp_not:N \l__block_level_incr_bool
726 }
727 { \int_gdecr:N \exp_not:N \g_block_nesting_depth_int }
728 \exp_not:n
729 {
730 \legacy_if:nT { @inlabel }
731 {
732 \mode_leave_vertical:
733 \legacy_if_gset_false:n { @inlabel }
734 }
735 \__block_if_list:T
736 { \legacy_if:nT { @newlist } { \@noitemerr } }
737 \mode_if_horizontal:TF
738 {
739 \__block_skip_remove_last:
740 \__block_skip_remove_last:
741 \par
742 }
743 { \@inmatherr { \end { \@currenvir } } }
744 \l_@@_list_end_tl
745 \__kernel_displayblock_end:
746 \__block_if_list:T { \legacy_if_gset_false:n { @newlist } }
747 \legacy_if_gset_false:n { @nobreak }
748 \legacy_if:nF { @noparlist }
749 {
750 \__block_skip_set_to_last:N \l_tmpa_skip
751 \dim_compare:nNnT \l_tmpa_skip > \c_zero_dim
752 {
753 \skip_vertical:n { - \l_tmpa_skip }
754 \skip_vertical:n
755 { \l_tmpa_skip + \parskip - \@outerparskip }
756 }
757 \addpenalty \@endparpenalty
758 \addvspace \l__block_topsepadd_skip
759 }
760 \socket_use:n { block / endpe }
761 }
762 }
763 }
764 % \end{macrocode}
765 % \end{macro}
766 % The branch where \cs{l__block_topsepadd_skip} is not defined, which means we
767 % have a sufficiently new kernel to use the hooks. When we revise for the updated
768 % kernel, we could consider simply adding the code directly to the hook rather
769 % than using a token list, although that would mean hook operations each time
770 % there is an overlay.
771 % \begin{macrocode}
772 {
773 \AddToHook { item / after }
774 { \l_@@_list_end_tl }
775 }
776 % \end{macrocode}
777 % \begin{environment}{itemize, enumerate, description}
778 % Allow for the classical \cls{beamer} syntax: currently two versions but that
779 % will only last until the 2026-06-01 release of \LaTeX{} is out.
780 % \begin{macrocode}
781 \AddToHook { begindocument / before }
782 {
783 \clist_map_inline:nn { itemize , enumerate , description }
784 {
785 \IfFormatAtLeastTF { 2026-06-01 }
786 {
787 \RenewDocumentEnvironment {#1} { = { action-spec } !o }
788 { \SimpleBlockEnv {#1} {##1} }
789 { \BlockEnvEnd }
790 }
791 {
792 \RenewDocumentEnvironment {#1} { = { action-spec } !o }
793 {
794 \IfNoValueTF {##1}
795 { \UseInstance { blockenv } {#1} { } }
796 { \UseInstance { blockenv } {#1} {##1} }
797 }
798 { \endblockenv }
799 }
800 }
801 }
802 % \end{macrocode}
803 % \end{environment}
804 % And add the structural color to item labels.
805 % \begin{macrocode}
806 \AddToHook { begindocument / before }
807 {
808 \EditInstance { item } { basic }
809 { label-format = \color { structure } #1 }
810 \EditInstance { item } { description }
811 { label-format = \normalfont \bfseries \color { structure } #1 }
812 }
813 % \end{macrocode}
814 %
815 % \begin{variable}{\l_@@_action_spec_str}
816 % Add an overlay key to the \texttt{block} template. Placed here, it applies
817 % \emph{before} the \cs{item} starts, so we do not have to redefine the
818 % latter to do actions up-front. This also means it can apply to whatever we
819 % want it to within a block. Currently two versions but that will only last
820 % until the 2026-06-01 release of \LaTeX{} is out.
821 % \begin{macrocode}
822 \IfFormatAtLeastTF { 2026-06-01 }
823 {
824 \keys_define:nn { template / block / std }
825 { action-spec .str_set:N = \l_@@_action_spec_str }
826 }
827 {
828 \keys_define:nn { template / block / display }
829 { action-spec .str_set:N = \l_@@_action_spec_str }
830 }
831 % \end{macrocode}
832 % \end{variable}
833 %
834 % \subsection{Theorems, \foreign{etc.}}
835 %
836 % \begin{macro}{\newtheorem, \stdnewtheorem}
837 % We need to extend the creation of theorems in two ways: add the overlay
838 % argument, and add the counter to the list of those reset during overlay
839 % creation.
840 % \begin{macrocode}
841 \NewCommandCopy \stdnewtheorem \newtheorem
842 \RenewDocumentCommand \newtheorem { m o m o }
843 {
844 \IfNoValueTF {#4}
845 {
846 \IfNoValueTF {#2}
847 { \stdnewtheorem {#1} {#3} }
848 { \stdnewtheorem {#1} [ {#2} ] {#3} }
849 }
850 {
851 \IfNoValueTF {#2}
852 { \stdnewtheorem {#1} {#3} [ {#4} ] }
853 { \stdnewtheorem {#1} [ {#2} ] {#3} [ {#4} ] }
854 }
855 \NewEnvironmentCopy { std #1 } {#1}
856 \RenewDocumentEnvironment {#1} { D <> { all } o }
857 {
858 \@@_action_begin:n {##1}
859 \IfNoValueTF {##2}
860 { \begin { std #1 } }
861 { \begin { std #1 } [ {##2} ] }
862 \ignorespaces
863 }
864 {
865 \end { std #1 }
866 \@@_action_end:
867 }
868 }
869 % \end{macrocode}
870 % \end{macro}
871 %
872 % \begin{macrocode}
873 %</class>
874 % \end{macrocode}
875 %
876 % \end{implementation}
877 %
878 % \PrintIndex