diff --git a/luamml-convert.lua b/luamml-convert.lua index ab83c94..b7f8189 100644 --- a/luamml-convert.lua +++ b/luamml-convert.lua @@ -281,35 +281,12 @@ 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 @@ -317,14 +294,8 @@ 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 @@ -351,13 +322,10 @@ 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) diff --git a/luamml-legacy-mappings.lua b/luamml-legacy-mappings.lua index f4236ce..c969a8d 100644 --- a/luamml-legacy-mappings.lua +++ b/luamml-legacy-mappings.lua @@ -41,32 +41,11 @@ local remap_oms = { [0] = 0x1D4B3, 0x1D4B4, 0x1D4B5, 0x222A, 0x2229, 0x228E, 0x2227, 0x2228, 0x22A2, 0x22A3, 0x230A, 0x230B, 0x2308, 0x2309, 0x7B, 0x7D, 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, } --- 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 { oml = remap_oml, oms = remap_oms, - omx = remap_omx, } diff --git a/luamml-tex.lua b/luamml-tex.lua index 1dd3eb2..175ba78 100644 --- a/luamml-tex.lua +++ b/luamml-tex.lua @@ -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." }) 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 end diff --git a/luamml-xmlwriter.lua b/luamml-xmlwriter.lua index efd5f4f..98587ff 100644 --- a/luamml-xmlwriter.lua +++ b/luamml-xmlwriter.lua @@ -13,18 +13,14 @@ local function escape_text(text) return string.gsub(tostring(text), '("<>&)', escapes) end -local attrs = {} local function write_elem(tree, indent) if not tree[0] then print('ERR', require'inspect'(tree)) end 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 - i = i + 1 - attrs[i] = string.format(' %s="%s"', escape_name(attr), escape_text(val)) + out = out .. ' ' .. escape_name(attr) .. '="' .. escape_text(val) .. '"' 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 return out .. '/>' end diff --git a/test_tex.tex b/test_tex.tex index 18b1c24..a6adc1b 100644 --- a/test_tex.tex +++ b/test_tex.tex @@ -4,7 +4,6 @@ \usepackage{luamml} \RegisterFamilyMapping\symsymbols{oms} \RegisterFamilyMapping\symletters{oml} -\RegisterFamilyMapping\symlargesymbols{omx} \ExplSyntaxOn \pdfvariable compresslevel0 \cs_new_protected:Npn \ShowMathMLObj {