[latex3-commits] [latex3/latex2e] tagging705-float: switch to tagging sockets in float module, WIP (7dd40b5a)

github at latex-project.org github at latex-project.org
Sat Sep 14 00:40:54 CEST 2024


Repository : https://github.com/latex3/latex2e
On branch  : tagging705-float
Link       : https://github.com/latex3/latex2e/commit/7dd40b5ad71cf3a05b0b6877d9bcdba479aab5d8

>---------------------------------------------------------------

commit 7dd40b5ad71cf3a05b0b6877d9bcdba479aab5d8
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Sat Sep 14 00:40:54 2024 +0200

    switch to tagging sockets in float module, WIP


>---------------------------------------------------------------

7dd40b5ad71cf3a05b0b6877d9bcdba479aab5d8
 base/changes.txt                                   |   2 +
 base/lttagging.dtx                                 |  24 ++++-
 required/latex-lab/changes.txt                     |   2 +
 required/latex-lab/latex-lab-float.dtx             | 119 ++++++++++++++++-----
 .../testfiles-float/float-010-outside.luatex.tlg   |   4 +-
 .../testfiles-float/float-010-outside.tlg          |   4 +-
 6 files changed, 122 insertions(+), 33 deletions(-)

diff --git a/base/changes.txt b/base/changes.txt
index 92554f96..03b5aacb 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -5,6 +5,8 @@ hotfixes). It is provided for convenience only.  It therefore makes no claims
 to completeness or accuracy and it contains some references to files that are
 not part of the distribution.
 ================================================================================
+2024-09-13 Ulrike Fischer <Ulrike.Fischer at latex-project.org>
+	* lttagging.dtx: declare tagging sockets for floats
 
 2024-09-11  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
 
diff --git a/base/lttagging.dtx b/base/lttagging.dtx
index f4d23778..445c6d8a 100644
--- a/base/lttagging.dtx
+++ b/base/lttagging.dtx
@@ -33,7 +33,7 @@
 %<*driver>
 % \fi
 \ProvidesFile{lttagging.dtx}
-             [2024/08/10 v1.0g LaTeX Kernel (tagging support)]
+             [2024/09/13 v1.0h LaTeX Kernel (tagging support)]
 % \iffalse
 \documentclass{l3doc}
 \GetFileInfo{lttagging.dtx}
@@ -295,7 +295,7 @@
 %    \end{macrocode}
 % \end{socketdecl}
 % 
-% \subsection{Tagging support for table/tabular packages}
+% \subsubsection{Tagging support for table/tabular packages}
 %
 % The code uses a number of sockets to inject the tagging
 % commands. These can be easily set to a noop-plug in case the
@@ -433,9 +433,27 @@
 %    \end{macrocode}
 % \end{socketdecl}
 %
+% \subsubsection{Tagging Support for floats}
 % 
+% \begin{socketdecl}{tagsupport/float/hmode/begin,
+%                    tagsupport/float/hmode/end}
+%  These sockets are used if the float is called in 
+%  hmode.
+% \changes{v1.0h}{2024/09/13}{Sockets for floats added}
+%    \begin{macrocode}
+\NewSocket{tagsupport/float/hmode/begin}{0}
+\NewSocket{tagsupport/float/hmode/end}{0}
+%    \end{macrocode}
+% \end{socketdecl}
 %
-%
+% \begin{socketdecl}{tagsupport/float/begin,
+%                    tagsupport/float/end}
+%  These sockets start and stop the float structure.
+%    \begin{macrocode}
+\NewSocket{tagsupport/float/begin}{0}
+\NewSocket{tagsupport/float/end}{0}
+%    \end{macrocode}
+% \end{socketdecl}
 % 
 % \section{For lttab.dtx parked here for now}
 %
diff --git a/required/latex-lab/changes.txt b/required/latex-lab/changes.txt
index 3378f641..1250f157 100644
--- a/required/latex-lab/changes.txt
+++ b/required/latex-lab/changes.txt
@@ -1,3 +1,5 @@
+2024-09-13 Ulrike Fischer <Ulrike.Fischer at latex-project.org>
+	* latex-lab-float.dtx: switch to tagging sockets
 
 2024-09-03 Ulrike Fischer <Ulrike.Fischer at latex-project.org>
 	* documentmetadata-support.dtx: switch to T1 encoding by default for non-Unicode
diff --git a/required/latex-lab/latex-lab-float.dtx b/required/latex-lab/latex-lab-float.dtx
index 25ae805c..3da0404b 100644
--- a/required/latex-lab/latex-lab-float.dtx
+++ b/required/latex-lab/latex-lab-float.dtx
@@ -43,6 +43,7 @@
 % customizations}}
 %
 % \providecommand\hook[1]{\texttt{#1}}
+% \ProvideDocElement[printtype=\textit{plug},idxtype=plug,idxgroup=Plugs]{Plug}{plugdecl}
 % \begin{documentation}
 % \begin{abstract}
 % The following code implements a first draft for the tagging of float 
@@ -146,22 +147,28 @@
   {Code related to the tagging of floats}
 %    \end{macrocode}
 % \subsection{Variables}
-% We rolemap to float to Aside, and float sections to Sect.
+% We rolemap floats to Aside, and float sections to Sect.
 %
 % \begin{variable}{
 %  \g_@@_float_sect_prop,
 %  \g_@@_float_types_seq,
-%  \@current at float@struct
+%  \@current at float@struct,
+%  \g_@@_float_int
 %   }
 % These variables will hold the structure number for the float container  
 % and the list of float types. Currently only figure and table are supported
 % TODO: interface to declare new float types.
+% To set the target for links we need also a unique counter.
+% With tagging we could use the structure number, but
+% the structure commands now are hidden inside tagging sockets 
+% so we use a dedicated counter.
 %    \begin{macrocode}
 \prop_new:N \g_@@_float_sect_prop
 \seq_new:N  \g_@@_float_types_seq
 \seq_gput_right:Nn \g_@@_float_types_seq {figure}
 \seq_gput_right:Nn \g_@@_float_types_seq {table}
 \tl_new:N\@current at float@struct
+\int_new:N\g_@@_float_int
 %    \end{macrocode}
 % \end{variable}
 % 
@@ -176,6 +183,17 @@
 %    \end{macrocode}
 % \end{variable}
 % 
+% \begin{macro}{\@@_float_init:}
+% To be able to set unique targets for links, we
+% need a counter outside the tagging sockets.  
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_float_init:
+ {
+   \int_gincr:N \g_@@_float_int
+   \tl_set:Ne \@current at float@struct { \int_use:N \g_@@_float_int}
+ }
+%    \end{macrocode}
+% \end{macro}
 % 
 %\subsection{Moving float structures}
 % 
@@ -260,15 +278,71 @@
   {
    split-float .code:n = 
     { 
-      \@@_float_end:
-      \@@_float_begin:
-      \MakeLinkTarget*{floatstructure.\int_use:N\c at g__tag_struct_abs_int}
+      \UseTaggingSocket{float/end}
+      \@@_float_init:     
+      \UseTaggingSocket{float/begin}
+      \MakeLinkTarget*{floatstructure.\@current at float@struct}
     }  
  }
 %    \end{macrocode}
 % \end{macro}
- 
-% \subsection{Patching}
+% 
+% \subsection{Tagging sockets}
+% For now we test if the sockets are already defined
+%    \begin{macrocode}
+\str_if_exist:cF { l__socket_tagsupport/float/begin_plug_str }
+  {
+    \NewSocket{tagsupport/float/hmode/begin}{0}
+    \NewSocket{tagsupport/float/hmode/end}{0}
+    \NewSocket{tagsupport/float/begin}{0}
+    \NewSocket{tagsupport/float/end}{0}
+  }
+%    \end{macrocode}
+%
+% \begin{plugdecl}{default}
+% This plug should be used if a float is called in hmode.
+% In then closes the MC-chunks and starts the structure.
+%    \begin{macrocode}
+\NewSocketPlug {tagsupport/float/hmode/begin}{default}
+  {
+    \@@_float_stop_par:
+  }
+\AssignSocketPlug{tagsupport/float/hmode/begin}{default}  
+%    \end{macrocode}
+% \end{plugdecl}
+%
+% \begin{plugdecl}{default}
+% This plug should be used if a float is called in hmode
+% and the end of the float it then restarts the MC.
+%    \begin{macrocode}
+\NewSocketPlug{tagsupport/float/hmode/end}{default}
+  {
+    \@@_float_start_par:
+  } 
+\AssignSocketPlug{tagsupport/float/hmode/end}{default}  
+%    \end{macrocode}
+% \end{plugdecl}
+% 
+% \begin{plugdecl}{default}
+%    \begin{macrocode}
+\NewSocketPlug{tagsupport/float/begin}{default}
+  {
+    \@@_float_begin:
+  }
+\AssignSocketPlug{tagsupport/float/begin}{default}   
+%    \end{macrocode}
+% \end{plugdecl}
+% 
+% \begin{plugdecl}{default}
+%    \begin{macrocode}
+\NewSocketPlug{tagsupport/float/end}{default}
+  {
+    \@@_float_end:
+  } 
+\AssignSocketPlug{tagsupport/float/end}{default}   
+%    \end{macrocode}
+% \end{plugdecl}
+% 
 % \begin{macro}{\@@_float_stop_par:,\@@_float_start_par:}
 % if a float is in a par, we need commands to stop and restart the P-mc
 %    \begin{macrocode}
@@ -288,7 +362,6 @@
      }
    \tag_mc_begin:n{tag=P}    
   } 
- 
 %    \end{macrocode}
 % \end{macro}
 % These commands are the main commands to start and end the float tagging.
@@ -315,6 +388,7 @@
 \cs_new_protected:Npn\@@_float_end:{\tag_struct_end:} %end Aside
 
 %    \end{macrocode}
+% \subsection{Patching}
 % This patches the main command \cs{@xfloat}.
 % There is a : in the code, so we disable expl3 syntax
 %    \begin{macrocode}
@@ -337,7 +411,7 @@
 %    \end{macrocode}
 % If the float is in hmode we have to interrupt the P 
 %    \begin{macrocode}
-     \@nameuse{@@_float_stop_par:}% <---end P
+     \UseTaggingSocket{float/hmode/begin}%
      \@floatpenalty -\@Mii
    \else
      \@floatpenalty-\@Miii
@@ -383,7 +457,8 @@
 %    \end{macrocode}
 % This starts the structure for the float.
 %    \begin{macrocode}
-  \@nameuse{@@_float_begin:}%
+  \csname @@_float_init:\endcsname
+  \UseTaggingSocket{float/begin}%
   \global \setbox\@currbox
     \color at vbox
       \normalcolor
@@ -394,14 +469,14 @@
 %    \end{macrocode}
 % We add a target for links. TODO: check that it doesn't affect spacing!!
 %    \begin{macrocode}
-        \MakeLinkTarget*{floatstructure.\number\value{g__tag_struct_abs_int}}%
+        \MakeLinkTarget*{floatstructure.\@current at float@struct}%
 }%
 %    \end{macrocode}
 %  The end code of the float ...
 %    \begin{macrocode}
 \def\end at float{%
   \@endfloatbox
-  \@nameuse{@@_float_end:}%
+  \UseTaggingSocket{float/end}%
   \ifnum\@floatpenalty <\z@
     \@largefloatcheck
     \@cons\@currlist\@currbox
@@ -413,7 +488,7 @@
       \penalty\@floatpenalty
     \else
       \vadjust{\penalty -\@Miv \vbox{}\penalty\@floatpenalty}\@Esphack
-      \@nameuse{@@_float_start_par:}% restart P safe here??
+      \UseTaggingSocket{float/hmode/end}%
     \fi
   \fi
 }
@@ -423,7 +498,7 @@
 \def\end at dblfloat{%
   \if at twocolumn
     \@endfloatbox
-    \@nameuse{@@_float_end:}%
+    \UseTaggingSocket{float/end}%
     \ifnum\@floatpenalty <\z@
       \@largefloatcheck
       \global\dp\@currbox1sp %
@@ -436,7 +511,7 @@
         \penalty\@floatpenalty
       \else
         \vadjust{\penalty -\@Miv \vbox{}\penalty\@floatpenalty}\@Esphack
-        \@nameuse{@@_float_start_par:}% restart P safe here??
+        \UseTaggingSocket{float/hmode/end}%
       \fi
     \fi
   \else
@@ -456,7 +531,6 @@
 % With hyperref that means that the \cs{refstepcounter} now can affect spacing so we
 % change that to the kernel refstepcounter:
 %    \begin{macrocode}
-\let\@kernel at refstepcounter\refstepcounter %as long it is not in the kernel
 \def\caption{%
    \ifx\@captype\@undefined
      \@latex at error{\noexpand\caption\c_space_tl outside~float}\@ehd
@@ -482,14 +556,7 @@
    {\@dblarg{\@caption\@captype}}%
 }
 %    \end{macrocode}
-% As we will use the structure number in the target, we need to provide a
-% theH-representation. (Once the kernel will create
-% theH-representation generally this will be provided automatically, as tagpdf uses
-% \cs{newcounter})
-%    \begin{macrocode}
-\providecommand\theHg__tag_struct_abs_int{\int_use:N\c at g__tag_struct_abs_int}
-%    \end{macrocode}
-
+%
 % \begin{macro}{\@makecaption}
 % \cs{@makecaption} is defined by the classes so we overwrite it for now
 % at begin document.
@@ -501,9 +568,9 @@
 %    \end{macrocode}
 % we don't want tagging when storing the caption for the singleline check
 %    \begin{macrocode}
-      \tag_stop:n{caption}
+      \SuspendTagging{\@makecaption}
       \sbox\@tempboxa{#1:~#2}%
-      \tag_start:n{caption} 
+      \ResumeTagging{\@makecaption} 
 %    \end{macrocode}
 % we stop paratagging. TODO: check 
 %    \begin{macrocode}
diff --git a/required/latex-lab/testfiles-float/float-010-outside.luatex.tlg b/required/latex-lab/testfiles-float/float-010-outside.luatex.tlg
index d141f389..071ffd31 100644
--- a/required/latex-lab/testfiles-float/float-010-outside.luatex.tlg
+++ b/required/latex-lab/testfiles-float/float-010-outside.luatex.tlg
@@ -1,9 +1,9 @@
 This is a generated file for the l3build validation system.
 Don't change this file in any respect.
 tagpdf DEBUG Info: Tagging stopped
-(tagpdf DEBUG)     level: 0 ==> 1, label: caption [on line ...]
+(tagpdf DEBUG)     level: 0 ==> 1, label: \@makecaption  [on line ...]
 tagpdf DEBUG Info: Tagging restarted
-(tagpdf DEBUG)     level: 1 ==> 0, label: caption [on line ...]
+(tagpdf DEBUG)     level: 1 ==> 0, label: \@makecaption  [on line ...]
 Package tagpdf Info: Parent-Child 'Document' --> 'Caption'.
 (tagpdf)             Relation is -1 (='∅')
 (tagpdf)             Rolemapped from: 'Document' --> 'Caption' on line ...
diff --git a/required/latex-lab/testfiles-float/float-010-outside.tlg b/required/latex-lab/testfiles-float/float-010-outside.tlg
index 71599892..42522379 100644
--- a/required/latex-lab/testfiles-float/float-010-outside.tlg
+++ b/required/latex-lab/testfiles-float/float-010-outside.tlg
@@ -1,9 +1,9 @@
 This is a generated file for the l3build validation system.
 Don't change this file in any respect.
 tagpdf DEBUG Info: Tagging stopped
-(tagpdf DEBUG)     level: 0 ==> 1, label: caption [on line ...]
+(tagpdf DEBUG)     level: 0 ==> 1, label: \@makecaption  [on line ...]
 tagpdf DEBUG Info: Tagging restarted
-(tagpdf DEBUG)     level: 1 ==> 0, label: caption [on line ...]
+(tagpdf DEBUG)     level: 1 ==> 0, label: \@makecaption  [on line ...]
 Package tagpdf Info: Parent-Child 'Document' --> 'Caption'.
 (tagpdf)             Relation is -1 (='^^e2^^88^^85')
 (tagpdf)             Rolemapped from: 'Document' --> 'Caption' on line ...





More information about the latex3-commits mailing list.