Skip to content

Commit

Permalink
use sockets in minipage/parbox tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrike Fischer committed Oct 21, 2023
1 parent f824ff3 commit d99ed22
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions required/latex-lab/latex-lab-minipage.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@
\def\@kernel@init@minipage{}
\def\@kernel@init@parbox{}
% \end{macrocode}
% We need a few hooks.
% We use sockets for the tag support code, as there will be cases where we want
% to exchange the content or disable it.
% \begin{macrocode}
\def\@kernel@before@minipage{}
\def\@kernel@after@minipage{}
\def\@kernel@before@parbox{}
\def\@kernel@after@parbox{}
\socket_new:nn {tagsupport/minipage/before}{0}
\socket_new:nn {tagsupport/minipage/after} {0}
\socket_new:nn {tagsupport/parbox/before} {0}
\socket_new:nn {tagsupport/parbox/after}{0}
% \end{macrocode}
%
% \subsection{Patch minipage}
Expand All @@ -106,16 +107,16 @@
\setlength\@tempdima{#4}%
\def\@mpargs{{#1}{#2}[#3]{#4}}%
% \end{macrocode}
% insert the hook
% insert the socket
% \begin{macrocode}
\@kernel@before@minipage% new
\socket_use:n{tagsupport/minipage/before}% new
\setbox\@tempboxa\vbox\bgroup
\color@begingroup
\hsize\@tempdima
\textwidth\hsize \columnwidth\hsize
\@parboxrestore
\def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@
\AssignSocketPlug{fntext/process}{mp}%
\socket_assign_plug:nn{fntext/process}{mp}%
\let\@listdepth\@mplistdepth \@mplistdepth\z@
\@minipagerestore
\@setminipage}
Expand All @@ -141,7 +142,7 @@
\tag_stop:n{minipage}
\expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}%
\tag_start:n{minipage}
\@kernel@after@minipage%new end ...
\socket_use:n{tagsupport/minipage/after} %new end ...
}
% \end{macrocode}
%
Expand All @@ -152,7 +153,7 @@
\leavevmode
\@pboxswfalse
\setlength\@tempdima{#4}%
\@kernel@before@parbox% new
\socket_use:n{tagsupport/parbox/before}
\@begin@tempboxa\vbox{\hsize\@tempdima\@parboxrestore#5\@@par}%
\ifx\relax#2\else
\setlength\@tempdimb{#2}%
Expand All @@ -167,7 +168,7 @@
\csname bm@#3\endcsname}%
\if@pboxsw \m@th$\fi
\@end@tempboxa%
\@kernel@after@parbox%new end
\socket_use:n{tagsupport/parbox/after}
}
% \end{macrocode}
%
Expand All @@ -176,7 +177,7 @@
% \begin{macrocode}
\tl_new:N \l__ltboxes_tag_tl
\tl_set:Nn \l__ltboxes_tag_tl {Div}
\cs_set_protected:Npn\@kernel@before@minipage
\socket_new_plug:nnn{tagsupport/minipage/before}{tag/dflt}
{
% \end{macrocode}
% As there was a \cs{leavevmode} before that is a P/text open that we have to close.
Expand All @@ -185,14 +186,27 @@
% \end{macrocode}
% TODO: the P can be further up, we need a proper method to test and handle this.
% \begin{macrocode}
\tag_struct_begin:n{tag=\l__ltboxes_tag_tl}}
\cs_set_protected:Npn\@kernel@after@minipage
\tag_struct_begin:n{tag=\l__ltboxes_tag_tl}
}
% \end{macrocode}
% similar for the other sockets:
% \begin{macrocode}
\socket_new_plug:nnn{tagsupport/minipage/after}{tag/dflt}
{\tag_struct_end:\tag_struct_begin:n{tag=\l__tag_para_tag_tl}\tag_mc_begin_pop:n{}}
\cs_set_protected:Npn\@kernel@before@parbox

\socket_new_plug:nnn{tagsupport/parbox/before}{tag/dflt}
{\tag_mc_end_push:\tag_struct_end:\tag_struct_begin:n{tag=\l__ltboxes_tag_tl}}
\cs_set_protected:Npn\@kernel@after@parbox

\socket_new_plug:nnn{tagsupport/parbox/after}{tag/dflt}
{\tag_struct_end:\tag_struct_begin:n{tag=\l__tag_para_tag_tl}\tag_mc_begin_pop:n{}}
% \end{macrocode}
% Activate the default tagging plug
% \begin{macrocode}
\socket_assign_plug:nn{tagsupport/minipage/before}{tag/dflt}
\socket_assign_plug:nn{tagsupport/minipage/after} {tag/dflt}
\socket_assign_plug:nn{tagsupport/parbox/before} {tag/dflt}
\socket_assign_plug:nn{tagsupport/parbox/after} {tag/dflt}
% \end{macrocode}
% \begin{macrocode}
%</package>
% \end{macrocode}
Expand Down

0 comments on commit d99ed22

Please sign in to comment.