Use new flag_save variants

This commit is contained in:
Marcel Fabian Krüger 2021-06-22 17:44:18 +02:00
parent 3decacd033
commit ffe3514b75
6 changed files with 23 additions and 32 deletions

View File

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

View File

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

View File

@ -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
$
}

View File

@ -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~
}

View File

@ -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:
}

View File

@ -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)