From ffe3514b7526ecd6026c22d4de1ddc048302b5c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= Date: Tue, 22 Jun 2021 17:44:18 +0200 Subject: [PATCH] Use new flag_save variants --- luamml-amsmath.lua | 4 ++-- luamml-kernel.lua | 15 ++------------- luamml-patches-amsmath.sty | 8 ++++---- luamml-patches-array.sty | 6 +++--- luamml-patches-kernel.sty | 4 ++-- luamml-table.lua | 18 ++++++++++-------- 6 files changed, 23 insertions(+), 32 deletions(-) diff --git a/luamml-amsmath.lua b/luamml-amsmath.lua index 40da8c4..c3bfd80 100644 --- a/luamml-amsmath.lua +++ b/luamml-amsmath.lua @@ -22,7 +22,7 @@ lua.get_functions_table()[funcid] = function() until startmath == head or (startmath.id == math_t and startmath.subtype == 0) if startmath == head then return end assert(startmath.id == node.id"math") - store_column(startmath, true) + store_column(startmath) end local funcid = luatexbase.new_luafunction'__luamml_amsmath_add_box_to_row:' @@ -33,7 +33,7 @@ lua.get_functions_table()[funcid] = function() local boxnum = 0 local startmath = tex.box[boxnum].list assert(startmath.id == math_t) - store_column(startmath, true) + store_column(startmath) end do diff --git a/luamml-kernel.lua b/luamml-kernel.lua index 65b3efa..678fce1 100644 --- a/luamml-kernel.lua +++ b/luamml-kernel.lua @@ -3,12 +3,11 @@ local if_vertical = token.create'ifv@' local if_horizontal = token.create'ifh@' local iftrue_index = token.create'iftrue'.index -local funcid = luatexbase.new_luafunction'__luamml_kernel_finalize_phantom:N' -token.set_lua('__luamml_kernel_finalize_phantom:N', funcid, 'protected') +local funcid = luatexbase.new_luafunction'__luamml_kernel_finalize_phantom:' +token.set_lua('__luamml_kernel_finalize_phantom:', funcid, 'protected') lua.get_functions_table()[funcid] = function() -- TODO: Error handling etc -- At this point, box 0 contains the inner expression and the curent list ends with the noad whose nucleus should get replaced - local size = token.scan_int()//2 local boxnum = 0 local startmath = tex.box[boxnum].list assert(startmath.id == node.id"math") @@ -22,16 +21,6 @@ lua.get_functions_table()[funcid] = function() local saved_props = assert(properties[startmath]) local saved_core = saved_props.saved_mathml_core local saved = assert(saved_props.saved_mathml_table or saved_core) - if saved[0] == 'mstyle' - and (not saved.displaystyle or saved.displaystyle == (size == 0)) - and (not saved.scriptlevel or saved.scriptlevel == (size == 0 and 0 or size-1)) - then - saved[0], saved.displaystyle, saved.scriptlevel = 'mphantom', nil, nil - elseif saved[0] == 'mrow' then - saved[0] = 'mphantom' - else - saved = {[0] = 'mphantom', saved} - end -- The following could be optimized for the case that both if_vertical and if_horizontal -- are set, but that should't happen ayway and is just supported for consistency. if if_vertical.index ~= iftrue_index then diff --git a/luamml-patches-amsmath.sty b/luamml-patches-amsmath.sty index 2de1036..6b01eeb 100644 --- a/luamml-patches-amsmath.sty +++ b/luamml-patches-amsmath.sty @@ -36,7 +36,7 @@ \m@th \displaystyle {##} - \luamml_flag_save:N \displaystyle + \luamml_flag_save:Nn \displaystyle {mtd} $ \__luamml_amsmath_add_last_to_row: \tabskip \z@skip @@ -48,7 +48,7 @@ {} ## } - \luamml_flag_save:N \displaystyle + \luamml_flag_save:Nn \displaystyle {mtd} $ \__luamml_amsmath_add_last_to_row: \hfil @@ -79,7 +79,7 @@ \ifmeasuring@ \luamml_flag_ignore: \else - \luamml_flag_save:N \displaystyle + \luamml_flag_save:Nn \displaystyle {mtd} \fi $ } @@ -103,7 +103,7 @@ \ifmeasuring@ \luamml_flag_ignore: \else - \luamml_flag_save:N \displaystyle + \luamml_flag_save:Nn \displaystyle {mtd} \fi $ } diff --git a/luamml-patches-array.sty b/luamml-patches-array.sty index 757b027..dc15a40 100644 --- a/luamml-patches-array.sty +++ b/luamml-patches-array.sty @@ -18,7 +18,7 @@ } { \__luamml_array_init_col: \insert@column - \luamml_flag_save: + \luamml_flag_save:n {mtd} \d@llarend \__luamml_array_finalize_col:w 0~ } @@ -33,7 +33,7 @@ } { \__luamml_array_init_col: \insert@column - \luamml_flag_save: + \luamml_flag_save:n {mtd} \d@llarend \__luamml_array_finalize_col:w 1~ } @@ -49,7 +49,7 @@ } { \__luamml_array_init_col: \insert@column - \luamml_flag_save: + \luamml_flag_save:n {mtd} \d@llarend \__luamml_array_finalize_col:w 2~ } diff --git a/luamml-patches-kernel.sty b/luamml-patches-kernel.sty index 5326917..bec471b 100644 --- a/luamml-patches-kernel.sty +++ b/luamml-patches-kernel.sty @@ -9,9 +9,9 @@ \m@th #1 {#2} - \luamml_flag_save: + \luamml_flag_save:Nn #1 {mphantom} $ } \finph@nt - \__luamml_kernel_finalize_phantom:N #1 + \__luamml_kernel_finalize_phantom: } diff --git a/luamml-table.lua b/luamml-table.lua index 340fb06..2e4aad9 100644 --- a/luamml-table.lua +++ b/luamml-table.lua @@ -20,23 +20,25 @@ local function store_get_row() end local function store_column_xml(mml, display) - if display and mml[0] == 'mstyle' and mml.displaystyle == true then - mml[0], mml.displaystyle, mml.scriptlevel = 'mtd', nil, nil - else - if display and mml[0] ~= 'mstyle' then - mml = {[0] = 'mstyle', displaystyle = false, mml} + if mml[0] ~= 'mtd' then + if display and mml[0] == 'mstyle' and mml.displaystyle == true then + mml[0], mml.displaystyle, mml.scriptlevel = 'mtd', nil, nil + else + if display and mml[0] ~= 'mstyle' then + mml = {[0] = 'mstyle', displaystyle = false, mml} + end + mml = {[0] = 'mtd', mml} end - mml = {[0] = 'mtd', mml} end table.insert(store_get_row(), mml) return mml end -local function store_column(startmath, display) +local function store_column(startmath) local props = properties[startmath] if not props then return end local mml = props.saved_mathml_table or props.saved_mathml_core - if mml then return store_column_xml(mml, display) end + if mml then return store_column_xml(mml) end end local function store_tag(xml)