diff --git a/luamml-convert.lua b/luamml-convert.lua index 2dfa8b0..97161bf 100644 --- a/luamml-convert.lua +++ b/luamml-convert.lua @@ -104,8 +104,8 @@ local digit_map = {["0"] = true, ["1"] = true, ["5"] = true, ["6"] = true, ["7"] = true, ["8"] = true, ["9"] = true,} --- Two marker tables. They are used instead of an embellished operator to mark space-like or user provided constructs -local user_provided, space_like = {}, {} +-- Marker tables replacing the core operator for space like elements +local space_like = {} local nodes_to_table @@ -114,7 +114,7 @@ local function sup_style(s) return s//4*2+4+s%2 end -- The _to_table functions generally return a second argument which is -- could be (if it were a ) a core operator of the embellishe operator --- or space_like/user_provided +-- or space_like -- acc_to_table is special since it's return value should -- always be considered a core operator @@ -122,8 +122,9 @@ local function sup_style(s) return s//4*2+4+s%2 end local function delim_to_table(delim) if not delim then return end local props = properties[delim] - local mathml_table = props and props.mathml_table - if mathml_table then return mathml_table end + local mathml_core = props and props.mathml_core + local mathml_table = props and (props.mathml_table or mathml_core) + if mathml_table then return mathml_table, mathml_core end local mathml_filter = props and props.mathml_filter -- Kind of pointless since the arguments are literals, but present for consistency local char = delim.small_char if char == 0 then @@ -150,8 +151,9 @@ end local function acc_to_table(acc, cur_style, stretch) if not acc then return end local props = properties[acc] - local mathml_table = props and props.mathml_table - if mathml_table then return mathml_table end + local mathml_core = props and props.mathml_core + local mathml_table = props and (props.mathml_table or mathml_core) + if mathml_table then return mathml_table, mathml_core end if acc.id ~= math_char_t then error'confusion' end @@ -173,8 +175,9 @@ end local function kernel_to_table(kernel, cur_style) if not kernel then return end local props = properties[kernel] - local mathml_table = props and props.mathml_table - if mathml_table then return mathml_table, user_provided end + local mathml_core = props and props.mathml_core + local mathml_table = props and (props.mathml_table or mathml_core) + if mathml_table then return mathml_table, mathml_core end local mathml_filter = props and props.mathml_filter -- Kind of pointless since the arguments are literals, but present for consistency local id = kernel.id if id == math_char_t then @@ -500,9 +503,10 @@ function nodes_to_table(head, cur_style) for n, id, sub in node.traverse(head) do local new_core, new_mn, new_node, new_noad local props = properties[n] - local mathml_table = props and props.mathml_table + local mathml_core = props and props.mathml_core + local mathml_table = props and (props.mathml_table or mathml_core) if mathml_table then - new_node, new_core = mathml_table, user_provided + new_node, new_core = mathml_table, mathml_core elseif id == noad_t then local new_n new_n, new_core, new_mn = noad_to_table(n, sub, cur_style, mn) diff --git a/luamml-kernel.lua b/luamml-kernel.lua index f326ce9..65b3efa 100644 --- a/luamml-kernel.lua +++ b/luamml-kernel.lua @@ -19,7 +19,9 @@ lua.get_functions_table()[funcid] = function() properties[nucl] = props end assert(not props.mathml_table) - local saved = assert(assert(properties[startmath]).saved_mathml_table) + 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)) @@ -38,5 +40,5 @@ lua.get_functions_table()[funcid] = function() if if_horizontal.index ~= iftrue_index then saved = {[0] = 'mpadded', width = 0, saved} end - props.mathml_table = saved + props.mathml_table, props.mathml_core = saved, saved_core end diff --git a/luamml-lr.lua b/luamml-lr.lua index b1cb359..d0cbc55 100644 --- a/luamml-lr.lua +++ b/luamml-lr.lua @@ -36,7 +36,7 @@ local function to_unicode(head, tail) end elseif node.id'math' == id then if props then - local mml = props.saved_mathml_table + local mml = props.saved_mathml_table or props.saved_mathml_core if mml then if i ~= 0 then result[#result+1] = {[0] = 'mtext', table.concat(subresult)} diff --git a/luamml-patches-kernel.sty b/luamml-patches-kernel.sty index 21236cc..5326917 100644 --- a/luamml-patches-kernel.sty +++ b/luamml-patches-kernel.sty @@ -9,6 +9,7 @@ \m@th #1 {#2} + \luamml_flag_save: $ } \finph@nt diff --git a/luamml-table.lua b/luamml-table.lua index f4ab238..340fb06 100644 --- a/luamml-table.lua +++ b/luamml-table.lua @@ -35,7 +35,7 @@ end local function store_column(startmath, display) local props = properties[startmath] if not props then return end - local mml = props.saved_mathml_table + local mml = props.saved_mathml_table or props.saved_mathml_core if mml then return store_column_xml(mml, display) end end diff --git a/luamml-tex.lua b/luamml-tex.lua index f8d4b03..4febba1 100644 --- a/luamml-tex.lua +++ b/luamml-tex.lua @@ -86,7 +86,7 @@ luatexbase.add_to_callback('pre_mlist_to_hlist_filter', function(mlist, style) else new_mlist = mlist end - local xml = process_mlist(new_mlist, style == 'display' and 0 or 2) + local xml, core = process_mlist(new_mlist, style == 'display' and 0 or 2) if flag & 2 == 0 then save_result(xml, style == 'display' or flag & 1 == 1) end @@ -100,7 +100,7 @@ luatexbase.add_to_callback('pre_mlist_to_hlist_filter', function(mlist, style) props = {} properties[startmath] = props end - props.saved_mathml_table = xml + props.saved_mathml_table, props.saved_mathml_core = xml, core end if buffer_tail then mlist.prev, buffer_tail.next = nil, nil