[latex3-commits] [latex3/latex2e] UF-latexlab-toc: use sockets for contentsline and leaders tagging (b50ca68cf)
github at latex-project.org
github at latex-project.org
Thu Jul 11 14:44:16 CEST 2024
Repository : https://github.com/latex3/latex2e
On branch : UF-latexlab-toc
Link : https://github.com/latex3/latex2e/commit/b50ca68cf4cc2014378418e86fcdf6bcdbd8d589
>---------------------------------------------------------------
commit b50ca68cf4cc2014378418e86fcdf6bcdbd8d589
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Thu Jul 11 14:44:16 2024 +0200
use sockets for contentsline and leaders tagging
>---------------------------------------------------------------
b50ca68cf4cc2014378418e86fcdf6bcdbd8d589
.../latex-lab/latex-lab-toc-kernel-changes.dtx | 29 ++++++++++-------
required/latex-lab/latex-lab-toc.dtx | 36 +++++++++++++---------
2 files changed, 40 insertions(+), 25 deletions(-)
diff --git a/required/latex-lab/latex-lab-toc-kernel-changes.dtx b/required/latex-lab/latex-lab-toc-kernel-changes.dtx
index bb88ffdcb..c70918153 100644
--- a/required/latex-lab/latex-lab-toc-kernel-changes.dtx
+++ b/required/latex-lab/latex-lab-toc-kernel-changes.dtx
@@ -187,11 +187,11 @@
% \subsection{\cs{contentsline} extension}
% [latex-lab]
% The tagging code must add code at the begin and end of \cs{contentsline}.
-% This code must have access to the arguments. We set it up as config point
-% for now.
+% This code must have access to the arguments. They are passed
+% together in tagging socket.
% \begin{macrocode}
-\def\@contentsline at cfgpoint@before#1#2#3#4{}
-\def\@contentsline at cfgpoint@after#1#2#3#4{}
+\NewSocket{tagsupport/toc/contentsline/before}{1}
+\NewSocket{tagsupport/toc/contentsline/after}{1}
% \end{macrocode}
% for the hooks we need that the \cs{l at XX} pass also the destination and
% that \cs{l at XX} takes three arguments.
@@ -200,10 +200,10 @@
% \begin{macrocode}
\def\contentsline#1#2#3#4%
{%
- \@contentsline at cfgpoint@before{#1}{#2}{#3}{#4}%
+ \UseTaggingSocket{toc/contentsline/before}{{#1}{#2}{#3}{#4}}%
\gdef\@contentsline at destination{#4}%
\csname l@#1\endcsname{#2}{#3}%
- \@contentsline at cfgpoint@after{#1}{#2}{#3}{#4}%
+ \UseTaggingSocket{toc/contentsline/after}{{#1}{#2}{#3}{#4}}%
}
% \end{macrocode}
%
@@ -274,10 +274,16 @@
% So we need a config point.
%
% \cs{@dottedtocline} needs hooks and formatting commands.
-% We add a sixth argument so that it can grab the destination too.
+% To make the leaders into artifact we use tagging sockets.
+% The declaration should perhaps be moved into lttagging so that
+% it can be used also by external packages even if the tagging code is not
+% loaded?
+% \begin{macrocode}
+\NewSocket{tagsupport/toc/leaders/before}{0}
+\NewSocket{tagsupport/toc/leaders/after}{0}
+% \end{macrocode}
+% The destination is accessed throught \cs{@contentsline at destination}.
% \begin{macrocode}
-\def\@dottedtocline at cfgpoint@leaders#1{#1}
-
\def\@dottedtocline#1#2#3#4#5{%
\ifnum #1>\c at tocdepth \else
\vskip \z@ \@plus.2\p@
@@ -291,10 +297,11 @@
\csname contentsline at text@#1 at format\endcsname{#4}%
\UseHookWithArguments{contentsline/text/after}{4}{#1}{#4}{#5}{\@contentsline at destination}%
\nobreak
- \@dottedtocline at cfgpoint@leaders{%
+ \UseTaggingSocket{toc/leaders/before}\SuspendTagging{toc/leaders}%
\leaders\hbox{$\m at th
\mkern \@dotsep mu\hbox{.}\mkern \@dotsep
- mu$}\hfill}%
+ mu$}\hfill
+ \ResumeTagging{toc/leaders}\UseTaggingSocket{toc/leaders/after}%
\nobreak
\hb at xt@\@pnumwidth{\hfil\normalfont \normalcolor
\UseHookWithArguments{contentsline/page/before}{4}{#1}{#4}{#5}{\@contentsline at destination}%
diff --git a/required/latex-lab/latex-lab-toc.dtx b/required/latex-lab/latex-lab-toc.dtx
index 7235eb9ed..7b992eca2 100644
--- a/required/latex-lab/latex-lab-toc.dtx
+++ b/required/latex-lab/latex-lab-toc.dtx
@@ -249,10 +249,11 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@@_toc_contentsline_begin:nnn}
+% \begin{macro}{\@@_toc_contentsline_begin:nnnn}
% This is main command executed at the begin of a |\contentsline|.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_toc_contentsline_begin:nnn #1 #2 #3 %#1 level, #2 content, #3 destination
+\cs_new_protected:Npn \@@_toc_contentsline_begin:nnnn #1 #2 #3 #4
+ %#1 level, #2 content, #3 page number (unused) #4 destination
{
\tag_if_active:T
{
@@ -308,7 +309,7 @@
% \end{NOTE}
% \begin{macrocode}
\prop_gput:Nee \g_@@_struct_ref_by_dest_prop
- { \tag_get:n {struct_num} }{#3}
+ { \tag_get:n {struct_num} }{#4}
\seq_gpush:Ne \g_@@_toc_stack_seq {{TOCI}\use:c{toclevel@#1}}
\group_end:
}
@@ -317,21 +318,23 @@
% \end{macrocode}
% Now map it into the config point:
% \begin{macrocode}
-\cs_set_protected:Npn\@contentsline at cfgpoint@before#1#2#3#4
+\NewSocketPlug{tagsupport/toc/contentsline/before}{tagged}
{
- \@@_toc_contentsline_begin:nnn {#1}{#2}{#4}
+ \@@_toc_contentsline_begin:nnnn #1
}
+\AssignSocketPlug{tagsupport/toc/contentsline/before}{tagged}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@@_toc_contentsline_end:n}
+% \begin{macro}{\@@_toc_contentsline_end:nnnn}
% This is the closing code of a |\contentsline|.
% If the contentsline was actually printed, the code has to
% close the TOCI structure and to update the stack.
% \begin{macrocode}
\msg_new:nnn {tag}{toc-no-TOCI}{Missing~TOCI~structure~on~toc~stack}
-\cs_new_protected:Npn \@@_toc_contentsline_end:n #1 %#1 level name
+\cs_new_protected:Npn \@@_toc_contentsline_end:nnnn #1 #2 #3 #4
+% #1 level, #2 content (unused), #3 page number (unused) #4 destination (unused)
{
\int_compare:nNnF { \use:c{toclevel@#1} } > {\use:c{c at tocdepth}}
{
@@ -350,10 +353,11 @@
% \end{macrocode}
% Now we map it to the config point
% \begin{macrocode}
-\cs_set_protected:Npn \@contentsline at cfgpoint@after #1#2#3#4
- {
- \@@_toc_contentsline_end:n {#1}
- }
+\NewSocketPlug{tagsupport/toc/contentsline/after}{tagged}
+ {
+ \@@_toc_contentsline_end:nnnn #1
+ }
+\AssignSocketPlug{tagsupport/toc/contentsline/after}{tagged}
% \end{macrocode}
% \end{macro}
%
@@ -382,10 +386,14 @@
% \end{macrocode}
%
% \begin{macrocode}
-\def\@dottedtocline at cfgpoint@leaders#1{%
- \tag_mc_begin:n{artifact}\tag_stop:n{leaders}\nobreak#1\nobreak\tag_start:n{leaders}\tag_mc_end:}
+\NewSocketPlug{tagsupport/toc/leaders/before}{artifact}
+ {\tag_mc_begin:n{artifact}\nobreak}
+\NewSocketPlug{tagsupport/toc/leaders/after}{artifact}
+ {\nobreak\tag_mc_end:}
+\AssignSocketPlug{tagsupport/toc/leaders/before}{artifact}
+\AssignSocketPlug{tagsupport/toc/leaders/after}{artifact}
% \end{macrocode}
-
+%
%
% \begin{macrocode}
%</package>
More information about the latex3-commits
mailing list.