Skip to content

Commit

Permalink
Switch to tagging sockets in the latex-lab toc code (#1411)
Browse files Browse the repository at this point in the history
* use sockets for contentsline and leaders tagging

* switch to sockets for starttoc

* use default as plug name

* document and change version

* from review

* move toc tagging socket to lttagging
  • Loading branch information
u-fischer authored Jul 14, 2024
1 parent a4685aa commit c2f7848
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 61 deletions.
3 changes: 3 additions & 0 deletions base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ to completeness or accuracy and it contains some references to files that are
not part of the distribution.
================================================================================

2024-07-13 Ulrike Fischer <Ulrike.Fischer@latex-project.org>
* lttagging.dtx: (subsection{Tagging sockets}): toc-related tagging sockets added.

2024-07-13 Frank Mittelbach <Frank.Mittelbach@latex-project.org>

* lttagging.dtx (subsection{Tagging support for table/tabular packages}):
Expand Down
42 changes: 37 additions & 5 deletions base/lttagging.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
%<*driver>
% \fi
\ProvidesFile{lttagging.dtx}
[2024/07/13 v1.0c LaTeX Kernel (tagging support)]
[2024/07/14 v1.0d LaTeX Kernel (tagging support)]
% \iffalse
\documentclass{l3doc}
\GetFileInfo{lttagging.dtx}
Expand Down Expand Up @@ -219,11 +219,43 @@
%
% \end{macro}
%
% \subsection{Tagging sockets}
% This collects tagging sockets that should be generally available
% so that they can also be used even if the tagging code is not loaded.
%
% \subsubsection{Tagging sockets for toc}

% \begin{socketdecl}{tagsupport/toc/contentsline/before,
% tagsupport/toc/contentsline/after}
% Tagging sockets at the begin and end of contentsline.
% They receive \emph{all} contentsline arguments as one argument
% in four brace groups. The socket code should then use the parts it needs.
% \begin{macrocode}
\NewSocket{tagsupport/toc/contentsline/before}{1}
\NewSocket{tagsupport/toc/contentsline/after}{1}
% \end{macrocode}
% \end{socketdecl}
%
%
%
%
%
% \begin{socketdecl}{tagsupport/toc/starttoc/before,
% tagsupport/toc/starttoc/after}
% Tagging sockets for the begin and end of start of \cs{@starttoc}.
% They take one argument, the extension.
% \begin{macrocode}
\NewSocket{tagsupport/toc/starttoc/before}{1}
\NewSocket{tagsupport/toc/starttoc/after}{1}
% \end{macrocode}
% \end{socketdecl}
%
% \begin{socketdecl}{tagsupport/toc/leaders/before,
% tagsupport/toc/leaders/after}
% Tagging sockets to make the dot leaders an artifact.
% They do not take an argument.
% \begin{macrocode}
\NewSocket{tagsupport/toc/leaders/before}{0}
\NewSocket{tagsupport/toc/leaders/after}{0}
% \end{macrocode}
% \end{socketdecl}
%
% \subsection{Tagging support for table/tabular packages}
%
% The code uses a number of sockets to inject the tagging
Expand Down
4 changes: 4 additions & 0 deletions required/latex-lab/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
add plugs for tbl/leaders/begin and /end
(subsection{Misc stuff}): drop unused socket

2024-07-11 Ulrike Fischer <Ulrike.Fischer@latex-project.org>
* latex-lab-toc.dtx, latex-lab-toc-kernel-changes: switch from configuration points
to sockets.

2024-05-25 Ulrike Fischer <Ulrike.Fischer@latex-project.org>
* latex-lab-table.dtx: disable table headers in presentation tables.

Expand Down
91 changes: 71 additions & 20 deletions required/latex-lab/latex-lab-toc-kernel-changes.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
% for those people who are interested or want to report an issue.
%
% dates for latex-lab-kernel-changes.sty (pulled from various sources, see ins)
\def\ltlabkerneldate{2024-02-12}
\def\ltlabkernelversion{0.85c}
\def\ltlabkerneldate{2024-07-11}
\def\ltlabkernelversion{0.85d}
%<*driver>
\documentclass{l3doc}
\EnableCrossrefs
Expand All @@ -44,6 +44,11 @@
%
% \providecommand\hook[1]{\texttt{#1}}
%
%
% \ProvideDocElement[printtype=\textit{socket},idxtype=socket,idxgroup=Sockets]{Socket}{socketdecl}
% \ProvideDocElement[printtype=\textit{hook},idxtype=hook,idxgroup=Hooks]{Hook}{hookdecl}
% \ProvideDocElement[printtype=\textit{plug},idxtype=plug,idxgroup=Plugs]{Plug}{plugdecl}
%
% \begin{abstract}
% \end{abstract}
%
Expand Down Expand Up @@ -187,23 +192,35 @@
% \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{socketdecl}{tagsupport/toc/contentsline/before,
% tagsupport/toc/contentsline/after}
% Tagging sockets at the begin and end of contentsline.
% They receive \emph{all} contentsline arguments as one argument
% in four brace groups. The socket code should then use the parts it needs.
% The sockets will be in lttagging.dtx, but that may only happen in
% the next main release, so for now we test if they are in the
% format and if not define them now.
% \begin{macrocode}
\def\@contentsline@cfgpoint@before#1#2#3#4{}
\def\@contentsline@cfgpoint@after#1#2#3#4{}
\str_if_exist:cF { l__socket_tagsupport/toc/contentsline/before_plug_str }
{
\NewSocket{tagsupport/toc/contentsline/before}{1}
\NewSocket{tagsupport/toc/contentsline/after}{1}
}
% \end{macrocode}
% \end{socketdecl}
% for the hooks we need that the \cs{l@XX} pass also the destination and
% that \cs{l@XX} takes three arguments.
% TODO: test that, if there are two many problems we should pass the
% destination through a command name ...
% \begin{macrocode}
\def\contentsline#1#2#3#4%
{%
\@contentsline@cfgpoint@before{#1}{#2}{#3}{#4}%
\UseTaggingSocket{toc/contentsline/before}{{#1}{#2}{#3}{#4}}%
\gdef\@contentsline@destination{#4}%
\csname l@#1\endcsname{#2}{#3}%
\@contentsline@cfgpoint@after{#1}{#2}{#3}{#4}%
\UseTaggingSocket{toc/contentsline/after}{{#1}{#2}{#3}{#4}}%
}
% \end{macrocode}
%
Expand All @@ -225,17 +242,33 @@
% \subsection{\cs{@starttoc}}
% [kernel?]
%
% We add a configuration point before and after reading the file
% We add a tagging socket before and after reading the file
% for the tagging.
% \begin{socketdecl}{tagsupport/toc/starttoc/before,
% tagsupport/toc/starttoc/after}
% Tagging sockets for the begin and end of start of \cs{@starttoc}.
% They take one argument, the extension.
% The sockets will be in lttagging.dtx, but that may only happen in
% the next main release, so for now we test if they are in the
% format and if not define them now.
% \begin{macrocode}
\str_if_exist:cF { l__socket_tagsupport/toc/starttoc/before_plug_str }
{
\NewSocket{tagsupport/toc/starttoc/before}{1}
\NewSocket{tagsupport/toc/starttoc/after}{1}
}
% \end{macrocode}
% \begin{macrocode}
% \end{macrocode}
% \end{socketdecl}
%
% \begin{macrocode}
\def\@starttoc@cfgpoint@before#1{}
\def\@starttoc@cfgpoint@after#1{}
\def\@starttoc#1{%
\begingroup
\makeatletter
\@starttoc@cfgpoint@before{#1}%
\UseTaggingSocket{toc/starttoc/before}{#1}%
\@input{\jobname.#1}%
\@starttoc@cfgpoint@after{#1}%
\UseTaggingSocket{toc/starttoc/after}{#1}%
\if@filesw
\expandafter\newwrite\csname tf@#1\endcsname
\immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
Expand Down Expand Up @@ -269,15 +302,32 @@
\NewMirroredHookPairWithArguments{contentsline/page/before}{contentsline/page/after}{4}%
% \end{macrocode}
%
% The dot in the leader must be set as artifact.
% The dots in the leader must be set as artifact.
% But luatex requires that the mc are set outside the leaders.
% So we need a config point.
% So we need sockets.
%
% \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{socketdecl}{tagsupport/toc/leaders/before,
% tagsupport/toc/leaders/after}
% Tagging sockets to make the dot leaders an artifact.
% They do not take an argument.
% The sockets will be in lttagging.dtx, but that may only happen in
% the next main release, so for now we test if they are in the
% format and if not define them now.
% \begin{macrocode}
\str_if_exist:cF { l__socket_tagsupport/toc/leaders/before_plug_str }
{
\NewSocket{tagsupport/toc/leaders/before}{0}
\NewSocket{tagsupport/toc/leaders/after}{0}
}
% \end{macrocode}
% \end{socketdecl}
% The destination is accessed through \cs{@contentsline@destination}.
% \begin{macrocode}
\def\@dottedtocline@cfgpoint@leaders#1{#1}

\def\@dottedtocline#1#2#3#4#5{%
\ifnum #1>\c@tocdepth \else
\vskip \z@ \@plus.2\p@
Expand All @@ -291,10 +341,11 @@
\csname contentsline@text@#1@format\endcsname{#4}%
\UseHookWithArguments{contentsline/text/after}{4}{#1}{#4}{#5}{\@contentsline@destination}%
\nobreak
\@dottedtocline@cfgpoint@leaders{%
\UseTaggingSocket{toc/leaders/before}\SuspendTagging{toc/leaders}%
\leaders\hbox{$\m@th
\mkern \@dotsep mu\hbox{.}\mkern \@dotsep
mu$}\hfill}%
mu$}\hfill
\ResumeTagging{toc/leaders}\UseTaggingSocket{toc/leaders/after}%
\nobreak
\hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor
\UseHookWithArguments{contentsline/page/before}{4}{#1}{#4}{#5}{\@contentsline@destination}%
Expand Down
Loading

0 comments on commit c2f7848

Please sign in to comment.