From 7e000a0db1c04b076ba5b935801d7ca9db760015 Mon Sep 17 00:00:00 2001 From: Ulrike Fischer Date: Tue, 28 Jan 2025 00:20:06 +0100 Subject: [PATCH] use sockets for math phantoms --- luamml-patches-kernel.sty | 52 ++++++++++++++++++----------------- luamml.dtx | 57 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 24 deletions(-) diff --git a/luamml-patches-kernel.sty b/luamml-patches-kernel.sty index 38eb28b..304cf26 100644 --- a/luamml-patches-kernel.sty +++ b/luamml-patches-kernel.sty @@ -22,30 +22,34 @@ } } -\cs_set:Npn \mathph@nt #1 #2 { - \setbox \z@ = \hbox { - $ - \m@th - #1 - {#2} - \luamml_save:nNn {mathphant} #1 {mphantom} - $ - } - \luamml_annotate:nen {1} { - nucleus = true, - core = {[0] = 'mpadded', - \ifh@\else - width = 0, - \fi - \ifv@\else - height = 0, depth = 0, - \fi - consume_label'mathphant', - } - } { - \finph@nt - } -} +\IfPackageAtLeastTF{latex-lab-testphase-text}{2025-01-27} + {} + { + \cs_set:Npn \mathph@nt #1 #2 { + \setbox \z@ = \hbox { + $ + \m@th + #1 + {#2} + \luamml_save:nNn {mathphant} #1 {mphantom} + $ + } + \luamml_annotate:nen {1} { + nucleus = true, + core = {[0] = 'mpadded', + \ifh@\else + width = 0, + \fi + \ifv@\else + height = 0, depth = 0, + \fi + consume_label'mathphant', + } + } { + \finph@nt + } + } + } \@ifpackageloaded {unicode-math} {} { \cs_new:Npn \__luamml_kernel_define_character:Nnn #1#2#3 { diff --git a/luamml.dtx b/luamml.dtx index c492c10..2494975 100644 --- a/luamml.dtx +++ b/luamml.dtx @@ -527,6 +527,25 @@ % In various places luamml has to add code to kernel commands. This is done through % sockets which are predeclared in lttagging. % +% \subsubsection{Save socket} +% This socket is a wrapper around the \cs{luamml_save:nNn} command +% It should provided until 2025-06-01 +% \begin{macrocode} +\str_if_exist:cF { l__socket_tagsupport/math/luamml/save_plug_str } + { + \NewSocket{tagsupport/math/luamml/save}{1} + \AssignSocketPlug{tagsupport/math/luamml/save}{noop} + } +% \end{macrocode} +% +% \begin{macrocode} +\NewSocketPlug{tagsupport/math/luamml/save}{luamml} + { + \luamml_save:nNn #1 + } +\AssignSocketPlug{tagsupport/math/luamml/save}{luamml} +% \end{macrocode} +% % \subsubsection{amsmath alignments} % % This socket finalize the \texttt{mtable} in alignments like align or gather. @@ -610,6 +629,44 @@ \AssignSocketPlug{tagsupport/math/luamml/artifact}{default} % % \end{macrocode} +% +% \subsubsection{Math phantom socket} +% This socket is used around \cs{finph@nt}. +% It should provided until 2025-06-01 +% \begin{macrocode} +\str_if_exist:cF { l__socket_tagsupport/math/luamml/finph@nt_plug_str } + { + \NewSocket{tagsupport/math/luamml/finph@nt}{2} + \NewSocketPlug{tagsupport/math/luamml/finph@nt}{default}{#2} + \AssignSocketPlug{tagsupport/math/luamml/finph@nt}{default} + } +% \end{macrocode} +% +% \begin{macrocode} +%<*luatex> +\NewSocketPlug{tagsupport/math/luamml/finph@nt}{luamml} + { + \luamml_annotate:nen {1} + { + nucleus = true, + core = + { + [0] = 'mpadded', + \ifh@\else + width = 0, + \fi + \ifv@\else + height = 0, depth = 0, + \fi + consume_label'mathphant', + } + } + { #2 } + } +\AssignSocketPlug{tagsupport/math/luamml/finph@nt}{luamml} +% +% \end{macrocode} +% % \subsection{Patching} % For some packages, we ship with patches to make them more compatible and to % demonstrate how other code can be patched to work with \texttt{luamml}.