Convert mathbin to mathord if used in odd context

This commit is contained in:
Marcel Fabian Krüger 2021-04-26 15:23:42 +02:00
parent aa98c70f82
commit 91ac3ca2fa
1 changed files with 32 additions and 0 deletions

View File

@ -281,12 +281,35 @@ function nodes_to_table(head, cur_style)
local result = t
local nonscript
local core, mn = space_like
local no_binop_context, last_noad, last_noad_core = true
for n, id, sub in node.traverse(head) do
if last_noad and ((id == noad_t and noad_sub[sub] == 'punct') or (id == fence_t and fence_sub[sub] ~= 'left')) then
last_noad['tex:class'], last_noad_core[0] = nil, 'mi'
last_noad_core.stretchy, last_noad_core.mathvariant = nil, #last_noad_core == 1
and type(last_noad_core[0]) == 'string'
and utf8.len(last_noad_core[0]) == 1
and utf8.codepoint(last_noad_core[0]) < -0x10000
and 'normal' or nil
end
local new_core, new_mn
local props = properties[n] props = props and props.mathml_table
if props then
t[#t+1], new_core = props, user_provided
elseif id == noad_t then
local substr = noad_sub[sub]
if substr == 'bin' then
if no_binop_context then
sub, substr = 0, 'ord'
end
end
no_binop_context = false
or substr == 'bin'
or substr == 'opdisplaylimits'
or substr == 'oplimits'
or substr == 'opnolimits'
or substr == 'rel'
or substr == 'open'
or substr == 'punct'
local new_n
new_n, new_core, new_mn = noad_to_table(n, sub, cur_style, mn)
if new_mn == false then
@ -294,8 +317,14 @@ function nodes_to_table(head, cur_style)
else
t[#t+1] = new_n -- might be nil
end
if substr == 'bin' then
last_noad, last_noad_core = new_n, new_core
else
last_noad, last_noad_core = nil, nil
end
elseif id == accent_t then
t[#t+1], new_core = accent_to_table(n, sub, cur_style)
no_binop_context, last_noad, last_noad_core = false, nil, nil
elseif id == style_t then
if sub ~= cur_style then
if #t == 0 then
@ -322,10 +351,13 @@ function nodes_to_table(head, cur_style)
or assert(false)], 2*size), space_like
elseif id == radical_t then
t[#t+1], new_core = radical_to_table(n, sub, cur_style)
no_binop_context, last_noad, last_noad_core = false, nil, nil
elseif id == fraction_t then
t[#t+1], new_core = fraction_to_table(n, sub, cur_style)
no_binop_context, last_noad, last_noad_core = false, nil, nil
elseif id == fence_t then
t[#t+1], new_core = fence_to_table(n, sub, cur_style)
no_binop_context, last_noad, last_noad_core = false, nil, nil
elseif id == kern_t then
if not nonscript then
t[#t+1], new_core = space_to_table(n.kern, sub, cur_style)