Compare commits

..

No commits in common. "3995c7ae05f2deee382e379033025f3c33c3fc26" and "aa98c70f82a7f39ccc5662b985c078281165d10e" have entirely different histories.

5 changed files with 5 additions and 63 deletions

View File

@ -281,35 +281,12 @@ function nodes_to_table(head, cur_style)
local result = t local result = t
local nonscript local nonscript
local core, mn = space_like local core, mn = space_like
local no_binop_context, last_noad, last_noad_core = true
for n, id, sub in node.traverse(head) do 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 new_core, new_mn
local props = properties[n] props = props and props.mathml_table local props = properties[n] props = props and props.mathml_table
if props then if props then
t[#t+1], new_core = props, user_provided t[#t+1], new_core = props, user_provided
elseif id == noad_t then 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 local new_n
new_n, new_core, new_mn = noad_to_table(n, sub, cur_style, mn) new_n, new_core, new_mn = noad_to_table(n, sub, cur_style, mn)
if new_mn == false then if new_mn == false then
@ -317,14 +294,8 @@ function nodes_to_table(head, cur_style)
else else
t[#t+1] = new_n -- might be nil t[#t+1] = new_n -- might be nil
end 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 elseif id == accent_t then
t[#t+1], new_core = accent_to_table(n, sub, cur_style) 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 elseif id == style_t then
if sub ~= cur_style then if sub ~= cur_style then
if #t == 0 then if #t == 0 then
@ -351,13 +322,10 @@ function nodes_to_table(head, cur_style)
or assert(false)], 2*size), space_like or assert(false)], 2*size), space_like
elseif id == radical_t then elseif id == radical_t then
t[#t+1], new_core = radical_to_table(n, sub, cur_style) 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 elseif id == fraction_t then
t[#t+1], new_core = fraction_to_table(n, sub, cur_style) 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 elseif id == fence_t then
t[#t+1], new_core = fence_to_table(n, sub, cur_style) 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 elseif id == kern_t then
if not nonscript then if not nonscript then
t[#t+1], new_core = space_to_table(n.kern, sub, cur_style) t[#t+1], new_core = space_to_table(n.kern, sub, cur_style)

View File

@ -41,32 +41,11 @@ local remap_oms = { [0] =
0x1D4B3, 0x1D4B4, 0x1D4B5, 0x222A, 0x2229, 0x228E, 0x2227, 0x2228, 0x1D4B3, 0x1D4B4, 0x1D4B5, 0x222A, 0x2229, 0x228E, 0x2227, 0x2228,
0x22A2, 0x22A3, 0x230A, 0x230B, 0x2308, 0x2309, 0x7B, 0x7D, 0x22A2, 0x22A3, 0x230A, 0x230B, 0x2308, 0x2309, 0x7B, 0x7D,
0x27E8, 0x27E9, 0x7C, 0x2016, 0x2195, 0x21D5, 0x5C, 0x2240, 0x27E8, 0x27E9, 0x7C, 0x2016, 0x2195, 0x21D5, 0x5C, 0x2240,
0x221A, 0x2A3F, 0x2207, 0x222B, 0x2294, 0x2293, 0x2291, 0x2292, 0x221A, 0x2210, 0x2207, 0x222B, 0x2294, 0x2293, 0x2291, 0x2292,
0xA7, 0x2020, 0x2021, 0xB6, 0x2663, 0x2662, 0x2661, 0x2660, 0xA7, 0x2020, 0x2021, 0xB6, 0x2663, 0x2662, 0x2661, 0x2660,
} }
-- We are not remapping symbols which are only used as large variants
local remap_omx = { [0] =
nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, 0x27EE, 0x27EF, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, 0x2A06, nil,
0x222E, nil, 0x2A00, nil, 0x2A01, nil, 0x2A02, nil,
0x2211, 0x220F, 0x222B, 0x22C3, 0x22C2, 0x2A04, 0x22C0, 0x22C1,
nil, nil, nil, nil, nil, nil, nil, nil,
0x2210, nil, 0x5E, 0x5E, 0x5E, 0x7E, 0x7E, 0x7E,
nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, 0x23B0, 0x23B1, nil, nil, nil, nil,
}
return { return {
oml = remap_oml, oml = remap_oml,
oms = remap_oms, oms = remap_oms,
omx = remap_omx,
} }

View File

@ -87,7 +87,7 @@ lua.get_functions_table()[funcid] = function()
"I was asked to provide MathML code for the last formula, but there weren't any new formulas since you last asked." "I was asked to provide MathML code for the last formula, but there weren't any new formulas since you last asked."
}) })
end end
tex.sprint(-2, tostring(pdf.immediateobj('stream', mlist_result, '/Subtype/application#2Fmathml+xml' .. token.scan_argument(true)))) tex.sprint(-2, tostring(pdf.immediateobj('stream', mlist_result, '/Subtype /application#2Fmathml+xml\n' .. token.scan_argument(true))))
mlist_result = nil mlist_result = nil
end end

View File

@ -13,18 +13,14 @@ local function escape_text(text)
return string.gsub(tostring(text), '("<>&)', escapes) return string.gsub(tostring(text), '("<>&)', escapes)
end end
local attrs = {}
local function write_elem(tree, indent) local function write_elem(tree, indent)
if not tree[0] then print('ERR', require'inspect'(tree)) end if not tree[0] then print('ERR', require'inspect'(tree)) end
local escaped_name = escape_name(assert(tree[0])) local escaped_name = escape_name(assert(tree[0]))
local i = 0 local out = "<" .. escaped_name
if indent then out = indent .. out end
for attr, val in next, tree do if type(attr) == 'string' then for attr, val in next, tree do if type(attr) == 'string' then
i = i + 1 out = out .. ' ' .. escape_name(attr) .. '="' .. escape_text(val) .. '"'
attrs[i] = string.format(' %s="%s"', escape_name(attr), escape_text(val))
end end end end
table.sort(attrs)
local out = string.format('%s<%s%s', indent or '', escaped_name, table.concat(attrs))
for j = 1, i do attrs[j] = nil end
if not tree[1] then if not tree[1] then
return out .. '/>' return out .. '/>'
end end

View File

@ -4,7 +4,6 @@
\usepackage{luamml} \usepackage{luamml}
\RegisterFamilyMapping\symsymbols{oms} \RegisterFamilyMapping\symsymbols{oms}
\RegisterFamilyMapping\symletters{oml} \RegisterFamilyMapping\symletters{oml}
\RegisterFamilyMapping\symlargesymbols{omx}
\ExplSyntaxOn \ExplSyntaxOn
\pdfvariable compresslevel0 \pdfvariable compresslevel0
\cs_new_protected:Npn \ShowMathMLObj { \cs_new_protected:Npn \ShowMathMLObj {