Support \smash and cleanup

This commit is contained in:
Marcel Fabian Krüger 2024-10-24 23:45:07 +02:00
parent fc430b31ac
commit 58ad8a5766
2 changed files with 35 additions and 13 deletions

View File

@ -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@sh #1 #2 {
\setbox \z@ \hbox {
$
\m@th #1 {
#2
}
\luamml_flag_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@sh
}
}
\cs_set:Npn \mathph@nt #1 #2 {
\setbox \z@ = \hbox {
$
\m@th
#2
{#3}
\luamml_flag_save:nNn {mathphant_#1} #2 {mphantom}
\luamml_pdf_write:
#1
{#2}
\luamml_flag_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@nt
}
}
\cs_generate_variant:Nn \__luamml_kernel_phantom:nnn {V}
\int_new:N \g__luamml_kernel_phantom_int
\cs_set:Npn \mathph@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 {

View File

@ -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 {'