2021-05-31 00:26:35 +02:00
|
|
|
local properties = node.get_properties_table()
|
|
|
|
local if_vertical = token.create'ifv@'
|
|
|
|
local if_horizontal = token.create'ifh@'
|
|
|
|
local iftrue_index = token.create'iftrue'.index
|
|
|
|
|
2021-06-22 17:44:18 +02:00
|
|
|
local funcid = luatexbase.new_luafunction'__luamml_kernel_finalize_phantom:'
|
|
|
|
token.set_lua('__luamml_kernel_finalize_phantom:', funcid, 'protected')
|
2021-05-31 00:26:35 +02:00
|
|
|
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 boxnum = 0
|
|
|
|
local startmath = tex.box[boxnum].list
|
|
|
|
assert(startmath.id == node.id"math")
|
|
|
|
local nucl = assert(tex.nest.top.tail.nucleus)
|
|
|
|
local props = properties[nucl]
|
|
|
|
if not props then -- very likely
|
|
|
|
props = {}
|
|
|
|
properties[nucl] = props
|
|
|
|
end
|
|
|
|
assert(not props.mathml_table)
|
2021-05-31 01:54:21 +02:00
|
|
|
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)
|
2021-05-31 00:26:35 +02:00
|
|
|
-- 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
|
|
|
|
saved = {[0] = 'mpadded', height = 0, depth = 0, saved}
|
|
|
|
end
|
|
|
|
if if_horizontal.index ~= iftrue_index then
|
|
|
|
saved = {[0] = 'mpadded', width = 0, saved}
|
|
|
|
end
|
2021-05-31 01:54:21 +02:00
|
|
|
props.mathml_table, props.mathml_core = saved, saved_core
|
2021-05-31 00:26:35 +02:00
|
|
|
end
|