Generalize mn joining to family based joining
This commit is contained in:
parent
5be2282e9b
commit
948818c8bc
@ -107,6 +107,8 @@ local digit_map = {["0"] = true, ["1"] = true,
|
|||||||
-- Marker tables replacing the core operator for space like elements
|
-- Marker tables replacing the core operator for space like elements
|
||||||
local space_like = {}
|
local space_like = {}
|
||||||
|
|
||||||
|
local text_families = {}
|
||||||
|
|
||||||
local nodes_to_table
|
local nodes_to_table
|
||||||
|
|
||||||
local function sub_style(s) return s//4*2+5 end
|
local function sub_style(s) return s//4*2+5 end
|
||||||
@ -249,7 +251,7 @@ local function maybe_to_mn(noad, core)
|
|||||||
core[0] = 'mn'
|
core[0] = 'mn'
|
||||||
end
|
end
|
||||||
|
|
||||||
local function noad_to_table(noad, sub, cur_style, mn)
|
local function noad_to_table(noad, sub, cur_style, joining)
|
||||||
local nucleus, core = kernel_to_table(noad.nucleus, sub == noad_over and cur_style//2*2+1 or cur_style)
|
local nucleus, core = kernel_to_table(noad.nucleus, sub == noad_over and cur_style//2*2+1 or cur_style)
|
||||||
if core and core[0] == 'mo' and core.minsize and not core.maxsize then
|
if core and core[0] == 'mo' and core.minsize and not core.maxsize then
|
||||||
core.maxsize = core.minsize -- This happens when a half-specified delimiter appears alone in a list.
|
core.maxsize = core.minsize -- This happens when a half-specified delimiter appears alone in a list.
|
||||||
@ -265,14 +267,15 @@ local function noad_to_table(noad, sub, cur_style, mn)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if nucleus == core and #core == 1 then
|
if nucleus == core and #core == 1 then
|
||||||
if mn and core[0] == 'mi' and (core[1] == '.' or core[1] == ',') and maybe_to_mn(noad, core) or core[0] == 'mn' then
|
if joining and joining[0] == 'mn' and core[0] == 'mi' and (core[1] == '.' or core[1] == ',') and maybe_to_mn(noad, core)
|
||||||
if mn then
|
or core[0] == 'mn' or text_families[core['tex:family']] then
|
||||||
mn[#mn+1] = core[1]
|
if joining and core[0] == joining[0] and core['tex:family'] == joining['tex:family'] then
|
||||||
nucleus = do_sub_sup(mn, mn, noad, cur_style)
|
joining[#joining+1] = core[1]
|
||||||
if nucleus == mn then
|
nucleus = do_sub_sup(joining, joining, noad, cur_style)
|
||||||
return nil, mn, mn
|
if nucleus == joining then
|
||||||
|
return nil, joining, joining
|
||||||
else
|
else
|
||||||
return nucleus, mn, false
|
return nucleus, joining, false
|
||||||
end
|
end
|
||||||
elseif not noad.sub and not noad.sup then
|
elseif not noad.sub and not noad.sup then
|
||||||
return core, core, core
|
return core, core, core
|
||||||
@ -499,9 +502,9 @@ function nodes_to_table(head, cur_style)
|
|||||||
local t = {[0] = 'mrow'}
|
local t = {[0] = 'mrow'}
|
||||||
local result = t
|
local result = t
|
||||||
local nonscript
|
local nonscript
|
||||||
local core, last_noad, last_core, mn = space_like, nil, nil, nil
|
local core, last_noad, last_core, joining = space_like, nil, nil, nil
|
||||||
for n, id, sub in node.traverse(head) do
|
for n, id, sub in node.traverse(head) do
|
||||||
local new_core, new_mn, new_node, new_noad
|
local new_core, new_joining, new_node, new_noad
|
||||||
local props = properties[n]
|
local props = properties[n]
|
||||||
local mathml_core = props and props.mathml_core
|
local mathml_core = props and props.mathml_core
|
||||||
local mathml_table = props and (props.mathml_table or mathml_core)
|
local mathml_table = props and (props.mathml_table or mathml_core)
|
||||||
@ -509,9 +512,9 @@ function nodes_to_table(head, cur_style)
|
|||||||
new_node, new_core = mathml_table, mathml_core
|
new_node, new_core = mathml_table, mathml_core
|
||||||
elseif id == noad_t then
|
elseif id == noad_t then
|
||||||
local new_n
|
local new_n
|
||||||
new_n, new_core, new_mn = noad_to_table(n, sub, cur_style, mn)
|
new_n, new_core, new_joining = noad_to_table(n, sub, cur_style, joining)
|
||||||
if new_mn == false then
|
if new_joining == false then
|
||||||
t[#t], new_mn = new_n, nil
|
t[#t], new_joining = new_n, nil
|
||||||
else
|
else
|
||||||
new_node = new_n -- might be nil
|
new_node = new_n -- might be nil
|
||||||
end
|
end
|
||||||
@ -591,7 +594,7 @@ function nodes_to_table(head, cur_style)
|
|||||||
end
|
end
|
||||||
t[#t+1] = new_node
|
t[#t+1] = new_node
|
||||||
end
|
end
|
||||||
mn = new_mn
|
joining = new_joining
|
||||||
end
|
end
|
||||||
-- In TeX, groups are never space like
|
-- In TeX, groups are never space like
|
||||||
if core == space_like then
|
if core == space_like then
|
||||||
|
Loading…
Reference in New Issue
Block a user