From 58ad8a5766a43c1864f78f29f62903724b1efa6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= Date: Thu, 24 Oct 2024 23:45:07 +0200 Subject: [PATCH] Support \smash and cleanup --- luamml-patches-kernel.sty | 39 ++++++++++++++++++++++++++------------- luamml-tex-annotate.lua | 9 +++++++++ 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/luamml-patches-kernel.sty b/luamml-patches-kernel.sty index fa3aaae..5575b64 100644 --- a/luamml-patches-kernel.sty +++ b/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@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 { diff --git a/luamml-tex-annotate.lua b/luamml-tex-annotate.lua index 7e09217..050a00a 100644 --- a/luamml-tex-annotate.lua +++ b/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 {'