[latex3-commits] [latex3/latex2e] UF-latex-lab-math-options: test with newest luamml (32c720f7d)
github at latex-project.org
github at latex-project.org
Sat Oct 26 20:14:34 CEST 2024
Repository : https://github.com/latex3/latex2e
On branch : UF-latex-lab-math-options
Link : https://github.com/latex3/latex2e/commit/32c720f7d05dc14ba5fcd0f8f88867a6a9a2d1c9
>---------------------------------------------------------------
commit 32c720f7d05dc14ba5fcd0f8f88867a6a9a2d1c9
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Sat Oct 26 20:14:34 2024 +0200
test with newest luamml
>---------------------------------------------------------------
32c720f7d05dc14ba5fcd0f8f88867a6a9a2d1c9
texmf/tex/lualatex/luamml/luamml-demo.sty | 2 +-
.../tex/lualatex/luamml/luamml-patches-amsmath.sty | 30 +++++++--------
texmf/tex/lualatex/luamml/luamml-patches-array.sty | 43 +++++++++++++++-------
.../tex/lualatex/luamml/luamml-patches-kernel.sty | 39 +++++++++++++-------
.../lualatex/luamml/luamml-patches-mathtools.sty | 35 ++++++++++++++++++
texmf/tex/lualatex/luamml/luamml-pdf.sty | 20 ++++++----
.../lualatex/luamml/luamml-structelemwriter.lua | 20 +++++++++-
texmf/tex/lualatex/luamml/luamml-table.lua | 2 +-
texmf/tex/lualatex/luamml/luamml-tex-annotate.lua | 13 ++++++-
texmf/tex/lualatex/luamml/luamml.sty | 24 ++++++++----
10 files changed, 166 insertions(+), 62 deletions(-)
diff --git a/texmf/tex/lualatex/luamml/luamml-demo.sty b/texmf/tex/lualatex/luamml/luamml-demo.sty
index 64e4e3ff7..82bed7ff7 100644
--- a/texmf/tex/lualatex/luamml/luamml-demo.sty
+++ b/texmf/tex/lualatex/luamml/luamml-demo.sty
@@ -27,7 +27,7 @@
}
\DeclareOption{structelem}{
\bool_set_true:N \l__luamml_demo_structelem_bool
- \luamml_flag_structelem:
+ \luamml_structelem:
}
\DeclareOption{files}{
\int_new:N \g__luamml_demo_mathml_int
diff --git a/texmf/tex/lualatex/luamml/luamml-patches-amsmath.sty b/texmf/tex/lualatex/luamml/luamml-patches-amsmath.sty
index c0df5ed96..d9a47f071 100644
--- a/texmf/tex/lualatex/luamml/luamml-patches-amsmath.sty
+++ b/texmf/tex/lualatex/luamml/luamml-patches-amsmath.sty
@@ -42,7 +42,7 @@
\m at th
\displaystyle
{##}
- \luamml_flag_save:nNn {} \displaystyle {mtd}
+ \luamml_save:nNn {} \displaystyle {mtd}
$
\__luamml_amsmath_add_last_to_row:
\tabskip \z at skip
@@ -54,7 +54,7 @@
{}
##
}
- \luamml_flag_save:nNn {} \displaystyle {mtd}
+ \luamml_save:nNn {} \displaystyle {mtd}
$
\__luamml_amsmath_add_last_to_row:
\hfil
@@ -85,7 +85,7 @@
\m at th
\displaystyle
##
- \luamml_flag_save:nNn {} \displaystyle {mtd}
+ \luamml_save:nNn {} \displaystyle {mtd}
$
\__luamml_amsmath_add_last_to_row:
\hfil
@@ -122,7 +122,7 @@
\m at th
\displaystyle
{##}
- \luamml_flag_save:nNn {} \displaystyle {mtd}
+ \luamml_save:nNn {} \displaystyle {mtd}
$
}
\__luamml_amsmath_add_box_to_row:
@@ -153,7 +153,7 @@
\cs_set:Npn \gmeasure@ #1 {
\exp_last_unbraced:Nno
\use_ii_i:nn
- { \luamml_flag_ignore: }
+ { \luamml_ignore: }
{ \__luamml_amsmath_original_gmeasure:n {#1} }
}
@@ -178,9 +178,9 @@
\displaystyle
{##}
\ifmeasuring@
- \luamml_flag_ignore:
+ \luamml_ignore:
\else
- \luamml_flag_save:nNn {} \displaystyle {mtd}
+ \luamml_save:nNn {} \displaystyle {mtd}
\fi
$
}
@@ -202,9 +202,9 @@
##
}
\ifmeasuring@
- \luamml_flag_ignore:
+ \luamml_ignore:
\else
- \luamml_flag_save:nNn {} \displaystyle {mtd}
+ \luamml_save:nNn {} \displaystyle {mtd}
\fi
$
}
@@ -289,7 +289,7 @@
\cs_set:Npn \mmeasure@ #1 {
\exp_last_unbraced:Nno
\use_ii_i:nn
- { \luamml_flag_ignore: }
+ { \luamml_ignore: }
{ \__luamml_amsmath_original_mmeasure:n {#1} }
}
@@ -298,14 +298,14 @@
% Less luckily, \endmultline at math sometimes get overwritten for the last line.
% But that isn't a problem since we want special behavior there anyway.
\cs_set:Npn \endmultline at math {
- \luamml_flag_save:nNn {} \displaystyle {mtd}
+ \luamml_save:nNn {} \displaystyle {mtd}
$
\__luamml_amsmath_add_last_to_row:
}
\cs_set:Npn \rendmultline@ {
\iftag@
- \luamml_flag_save:nNn {} \displaystyle {mtd}
+ \luamml_save:nNn {} \displaystyle {mtd}
$
\__luamml_amsmath_add_last_to_row:
\let \endmultline at math \relax
@@ -370,7 +370,7 @@
\m at th
\scriptstyle
##
- \luamml_flag_save:nn {} {mtd} % No \scriptsize here since we want to add the mstyle nodes
+ \luamml_save:nn {} {mtd} % No \scriptsize here since we want to add the mstyle nodes
$
\__luamml_amsmath_add_last_to_row:
\hfil
@@ -381,7 +381,7 @@
\m at th
\scriptstyle
##
- \luamml_flag_save:nn {} {mtd} % No \scriptsize here since we want to add the mstyle nodes
+ \luamml_save:nn {} {mtd} % No \scriptsize here since we want to add the mstyle nodes
$
\__luamml_amsmath_add_last_to_row:
\hfil
@@ -404,7 +404,7 @@
\let \@ifnextchar \new at ifnextchar
\left \lbrace
\def \arraystretch {1.2}
- \array {@{}l@{\quad \luamml_flag_ignore:}l@{}}
+ \array {@{}l@{\quad \luamml_ignore:}l@{}}
}
diff --git a/texmf/tex/lualatex/luamml/luamml-patches-array.sty b/texmf/tex/lualatex/luamml/luamml-patches-array.sty
index ee40b2c48..e4df3d857 100644
--- a/texmf/tex/lualatex/luamml/luamml-patches-array.sty
+++ b/texmf/tex/lualatex/luamml/luamml-patches-array.sty
@@ -18,7 +18,7 @@
} {
\__luamml_array_init_col:
\insert at column
- \luamml_flag_save:nn {} {mtd}
+ \luamml_save:nn {} {mtd}
\d at llarend
\__luamml_array_finalize_col:w 0~
}
@@ -33,7 +33,7 @@
} {
\__luamml_array_init_col:
\insert at column
- \luamml_flag_save:nn {} {mtd}
+ \luamml_save:nn {} {mtd}
\d at llarend
\__luamml_array_finalize_col:w 1~
}
@@ -49,25 +49,25 @@
} {
\__luamml_array_init_col:
\insert at column
- \luamml_flag_save:nn {} {mtd}
+ \luamml_save:nn {} {mtd}
\d at llarend
\__luamml_array_finalize_col:w 2~
}
\do at row@strut
\or
\setbox \ar at mcellbox \vbox \@startpbox { \@nextchar }
- \insert at column
+ \insert at pcolumn
\@endpbox
\ar at align@mcell
\do at row@strut
\or
\vtop \@startpbox { \@nextchar }
- \insert at column
+ \insert at pcolumn
\@endpbox
\do at row@strut
\or
\vbox \@startpbox { \@nextchar }
- \insert at column
+ \insert at pcolumn
\@endpbox
\do at row@strut
\fi
@@ -75,12 +75,27 @@
\prepnext at tok
}
-\cs_set:Npn \endarray {
- \crcr
- \__luamml_array_save_array:
- \egroup
- \egroup
- \mode_if_math:T { \__luamml_array_finalize_array: }
- \@arrayright
- \gdef \@preamble {}
+\IfPackageAtLeastTF {array} {2023/12/11} {
+ \cs_set:Npn \endarray {
+ \tbl_crcr:n{endarray}
+ \__luamml_array_save_array:
+ \egroup
+ \UseTaggingSocket{tbl/finalize}
+ \tbl_restore_outer_cell_data:
+ \egroup
+ \mode_if_math:T { \__luamml_array_finalize_array: }
+ \@arrayright
+ \gdef \@preamble {}
+ }
+} {
+ \cs_new_eq:NN \insert at pcolumn \insert at column
+ \cs_set:Npn \endarray {
+ \crcr
+ \__luamml_array_save_array:
+ \egroup
+ \egroup
+ \mode_if_math:T { \__luamml_array_finalize_array: }
+ \@arrayright
+ \gdef \@preamble {}
+ }
}
diff --git a/texmf/tex/lualatex/luamml/luamml-patches-kernel.sty b/texmf/tex/lualatex/luamml/luamml-patches-kernel.sty
index fa3aaae0e..bc920ac6b 100644
--- a/texmf/tex/lualatex/luamml/luamml-patches-kernel.sty
+++ b/texmf/tex/lualatex/luamml/luamml-patches-kernel.sty
@@ -1,14 +1,34 @@
\ProvidesExplPackage {luamml-patches-kernel} {2024-08-14} {0.1.0}
{Feel free to add a description here}
-\cs_new:Npn \__luamml_kernel_phantom:nnn #1#2#3 {
+\cs_set:Npn \mathsm at sh #1 #2 {
+ \setbox \z@ \hbox {
+ $
+ \m at th #1 {
+ #2
+ }
+ \luamml_save:nNn {mathsmash} #1 {mpadded}
+ \luamml_pdf_write:
+ $
+ }
+ \luamml_annotate:nen {2} {
+ nucleus = true,
+ core = consume_label('mathsmash', function(padded)
+ padded.height, padded.depth = 0, 0~
+ end),
+ } {
+ {}
+ \finsm at sh
+ }
+}
+
+\cs_set:Npn \mathph at nt #1 #2 {
\setbox \z@ = \hbox {
$
\m at th
- #2
- {#3}
- \luamml_flag_save:nNn {mathphant_#1} #2 {mphantom}
- \luamml_pdf_write:
+ #1
+ {#2}
+ \luamml_save:nNn {mathphant} #1 {mphantom}
$
}
\luamml_annotate:nen {1} {
@@ -20,19 +40,12 @@
\ifv@\else
height = 0, depth = 0,
\fi
- data.mathml.mathphant_#1,
+ consume_label'mathphant',
}
} {
\finph at nt
}
}
-\cs_generate_variant:Nn \__luamml_kernel_phantom:nnn {V}
-
-\int_new:N \g__luamml_kernel_phantom_int
-\cs_set:Npn \mathph at nt {
- \int_gincr:N \g__luamml_kernel_phantom_int
- \__luamml_kernel_phantom:Vnn \g__luamml_kernel_phantom_int
-}
\@ifpackageloaded {unicode-math} {} {
\cs_new:Npn \__luamml_kernel_define_character:Nnn #1#2#3 {
diff --git a/texmf/tex/lualatex/luamml/luamml-patches-mathtools.sty b/texmf/tex/lualatex/luamml/luamml-patches-mathtools.sty
new file mode 100644
index 000000000..f73ced84e
--- /dev/null
+++ b/texmf/tex/lualatex/luamml/luamml-patches-mathtools.sty
@@ -0,0 +1,35 @@
+\ProvidesExplPackage {luamml-patches-mathtools} {2024-10-26} {0.1.0}
+ {Feel free to add a description here}
+
+\RequirePackage{luamml-patches-amsmath}
+% see https://github.com/latex3/tagging-project/issues/734
+\renewcommand*\MT_mult_internal:n [1]{
+ \MH_if_boolean:nF {outer_mult}{\alignedspace at left} %<-- requires amsmath 2016/11/05
+ \MT_next:
+ \bgroup
+ \Let@
+ \def\l_MT_multline_lastline_fint{0 }
+ \chardef\dspbrk at context\@ne \restore at math@cr
+ \MH_let:NwN \math at cr@@\MT_mult_mathcr_atat:w
+ \MH_let:NwN \shoveleft\MT_shoveleft:wn
+ \MH_let:NwN \shoveright\MT_shoveright:wn
+ \spread at equation
+ \MH_set_boolean_F:n {mult_firstline}
+ \MT_measure_mult:n {#1}
+ \MH_if_dim:w \l_MT_multwidth_dim<\l_MT_multline_measure_fdim
+ \MH_setlength:dn \l_MT_multwidth_dim{\l_MT_multline_measure_fdim}
+ \fi
+ \MH_set_boolean_T:n {mult_firstline}
+ \MH_if_num:w \l_MT_multline_lastline_fint=\@ne
+ \MH_let:NwN \math at cr@@ \MT_mult_firstandlast_mathcr:w
+ \MH_fi:
+ \ialign\bgroup
+ \hfil\strut@$\m at th\displaystyle{}##
+ \luamml_save:nNn {} \displaystyle {mtd}
+ $
+ \__luamml_amsmath_add_last_to_row:
+ \hfil
+ \crcr
+ \hfilneg
+ #1
+}
diff --git a/texmf/tex/lualatex/luamml/luamml-pdf.sty b/texmf/tex/lualatex/luamml/luamml-pdf.sty
index e3e1128c4..de5d817aa 100644
--- a/texmf/tex/lualatex/luamml/luamml-pdf.sty
+++ b/texmf/tex/lualatex/luamml/luamml-pdf.sty
@@ -42,10 +42,11 @@
\int_set:Nn \l__luamml_pretty_int { 1 }
-\cs_new_protected:Npn \luamml_flag_process: {
+\cs_new_protected:Npn \luamml_process: {
\tl_set:Nn \l__luamml_label_tl {}
\int_set:Nn \l__luamml_flag_int { 3 }
}
+\cs_set_eq:NN \luamml_flag_process: \luamml_process:
\cs_new:Npn \__luamml_maybe_structelem: {
(
8 * \int_mod:nn {
@@ -63,28 +64,33 @@
\Invalid_mathstyle
}
}
-\cs_new_protected:Npn \luamml_flag_save:n #1 {
+\cs_new_protected:Npn \luamml_save:n #1 {
\tl_set:Nn \l__luamml_label_tl {#1}
\int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 1 }
}
-\cs_new_protected:Npn \luamml_flag_save:nN #1#2 {
+\cs_new_protected:Npn \luamml_save:nN #1#2 {
\tl_set:Nn \l__luamml_label_tl {#1}
\int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 17 + \__luamml_style_to_num:N #2 }
}
-\cs_new_protected:Npn \luamml_flag_save:nn #1 {
+\cs_new_protected:Npn \luamml_save:nn #1 {
\tl_set:Nn \l__luamml_label_tl {#1}
\int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 5 }
\tl_set:Nn \l__luamml_root_tl
}
-\cs_new_protected:Npn \luamml_flag_save:nNn #1#2 {
+\cs_new_protected:Npn \luamml_save:nNn #1#2 {
\tl_set:Nn \l__luamml_label_tl {#1}
\int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 21 + \__luamml_style_to_num:N #2 }
\tl_set:Nn \l__luamml_root_tl
}
-\cs_new_protected:Npn \luamml_flag_ignore: {
+\cs_set_eq:NN \luamml_flag_save:n \luamml_save:n
+\cs_set_eq:NN \luamml_flag_save:nN \luamml_save:nN
+\cs_set_eq:NN \luamml_flag_save:nn \luamml_save:nn
+\cs_set_eq:NN \luamml_flag_save:nNn \luamml_save:nNn
+\cs_new_protected:Npn \luamml_ignore: {
\int_set:Nn \l__luamml_flag_int { 0 }
}
-\luamml_flag_process:
+\cs_set_eq:NN \luamml_flag_ignore: \luamml_ignore:
+\luamml_process:
\cs_if_exist:NTF \showstream {
\iow_new:N \l__luamml_pdf_stream
diff --git a/texmf/tex/lualatex/luamml/luamml-structelemwriter.lua b/texmf/tex/lualatex/luamml/luamml-structelemwriter.lua
index eb266a1e9..97a90aced 100644
--- a/texmf/tex/lualatex/luamml/luamml-structelemwriter.lua
+++ b/texmf/tex/lualatex/luamml/luamml-structelemwriter.lua
@@ -13,9 +13,27 @@ local function escape_string(str)
return str
end
+local ltx
+local function get_ltx()
+ if not ltx then
+ ltx = _ENV.ltx
+ if not ltx then
+ tex.error("LaTeX PDF support not loaded", {"Maybe try adding \\DocumentMetadata."})
+ ltx = {pdf = {object_id = function() return 0 end}}
+ end
+ end
+ return ltx
+end
+
local mathml_ns_obj
local function get_mathml_ns_obj()
- mathml_ns_obj = mathml_ns_obj or token.create'c__pdf_backend_object_tag/NS/mathml_int'.index
+ if not mathml_ns_obj then
+ mathml_ns_obj = get_ltx().pdf.object_id'tag/NS/mathml'
+ if not mathml_ns_obj then
+ tex.error("Failed to find MathML namespace", {"The PDF support does not know the mathml namespace"})
+ mathml_ns_obj = 0
+ end
+ end
return mathml_ns_obj
end
diff --git a/texmf/tex/lualatex/luamml/luamml-table.lua b/texmf/tex/lualatex/luamml/luamml-table.lua
index 8b703953f..4fb553af2 100644
--- a/texmf/tex/lualatex/luamml/luamml-table.lua
+++ b/texmf/tex/lualatex/luamml/luamml-table.lua
@@ -58,7 +58,7 @@ end
local function store_tag(xml)
local mml_row = store_get_row()
- mml_row[0] = 'mlabeledtr'
+ xml.intent = ':equationlabel'
table.insert(mml_row, 1, xml)
last_tag = nil
end
diff --git a/texmf/tex/lualatex/luamml/luamml-tex-annotate.lua b/texmf/tex/lualatex/luamml/luamml-tex-annotate.lua
index 4b22374ec..050a00a90 100644
--- a/texmf/tex/lualatex/luamml/luamml-tex-annotate.lua
+++ b/texmf/tex/lualatex/luamml/luamml-tex-annotate.lua
@@ -6,6 +6,15 @@ local mark_environment = {
data = {
},
}
+do
+ local _ENV = mark_environment
+ function consume_label(label, fn)
+ local mathml = data.mathml[label]
+ data.mathml[label] = nil
+ if fn then fn(mathml) end
+ return mathml
+ end
+end
local function annotate()
local annotation, err = load( 'return {'
@@ -59,10 +68,10 @@ local function annotate()
props = {}
properties[marked] = props
end
- if annotation.core then
+ if annotation.core ~= nil then
props.mathml_core = annotation.core
end
- if annotation.struct then
+ if annotation.struct ~= nil then
local saved = props.mathml_filter
local struct = annotation.struct
function props.mathml_filter(mml, core)
diff --git a/texmf/tex/lualatex/luamml/luamml.sty b/texmf/tex/lualatex/luamml/luamml.sty
index 275334321..2b826f74c 100644
--- a/texmf/tex/lualatex/luamml/luamml.sty
+++ b/texmf/tex/lualatex/luamml/luamml.sty
@@ -50,10 +50,11 @@
}
\__luamml_register_output_hook:N \__luamml_output_hook:n
-\cs_new_protected:Npn \luamml_flag_process: {
+\cs_new_protected:Npn \luamml_process: {
\tl_set:Nn \l__luamml_label_tl {}
\int_set:Nn \l__luamml_flag_int { 3 }
}
+\cs_set_eq:NN \luamml_flag_process: \luamml_process:
\cs_new:Npn \__luamml_maybe_structelem: {
(
8 * \int_mod:nn {
@@ -64,35 +65,41 @@
\cs_new:Npn \__luamml_style_to_num:N #1 {
32 * #1
}
-\cs_new_protected:Npn \luamml_flag_save:n #1 {
+\cs_new_protected:Npn \luamml_save:n #1 {
\tl_set:Nn \l__luamml_label_tl {#1}
\int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 1 }
}
-\cs_new_protected:Npn \luamml_flag_save:nN #1#2 {
+\cs_new_protected:Npn \luamml_save:nN #1#2 {
\tl_set:Nn \l__luamml_label_tl {#1}
\int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 17 + \__luamml_style_to_num:N #2 }
}
-\cs_new_protected:Npn \luamml_flag_save:nn #1 {
+\cs_new_protected:Npn \luamml_save:nn #1 {
\tl_set:Nn \l__luamml_label_tl {#1}
\int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 5 }
\tl_set:Nn \l__luamml_root_tl
}
-\cs_new_protected:Npn \luamml_flag_save:nNn #1#2 {
+\cs_new_protected:Npn \luamml_save:nNn #1#2 {
\tl_set:Nn \l__luamml_label_tl {#1}
\int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 21 + \__luamml_style_to_num:N #2 }
\tl_set:Nn \l__luamml_root_tl
}
-\cs_new_protected:Npn \luamml_flag_ignore: {
+\cs_set_eq:NN \luamml_flag_save:n \luamml_save:n
+\cs_set_eq:NN \luamml_flag_save:nN \luamml_save:nN
+\cs_set_eq:NN \luamml_flag_save:nn \luamml_save:nn
+\cs_set_eq:NN \luamml_flag_save:nNn \luamml_save:nNn
+\cs_new_protected:Npn \luamml_ignore: {
\int_set:Nn \l__luamml_flag_int { 0 }
}
-\cs_new_protected:Npn \luamml_flag_structelem: {
+\cs_set_eq:NN \luamml_flag_ignore: \luamml_ignore:
+\cs_new_protected:Npn \luamml_structelem: {
\tl_set:Nn \l__luamml_label_tl {}
\int_set:Nn \l__luamml_flag_int { 11 }
}
+\cs_set_eq:NN \luamml_flag_structelem: \luamml_structelem:
\cs_new_protected:Npn \luamml_set_filename:n {
\tl_set:Nn \l__luamml_filename_tl
}
-\luamml_flag_process:
+\luamml_process:
\cs_new_protected:Npn \luamml_annotate:nen #1#2#3 {
\__luamml_annotate_begin:
#3
@@ -119,6 +126,7 @@
\RequirePackage { luamml-patches-kernel }
\__luamml_patch_package:n {amstext}
\__luamml_patch_package:n {amsmath}
+\__luamml_patch_package:n {mathtools}
\__luamml_patch_package:n {array}
\endinput
More information about the latex3-commits
mailing list.