Opportunistic inclusion of MathML in text content

This commit is contained in:
Marcel Fabian Krüger 2021-05-03 21:57:58 +02:00
parent 8e5cee495d
commit 743d8f85c5
2 changed files with 17 additions and 6 deletions

View File

@ -48,7 +48,7 @@ lua.get_functions_table()[funcid] = function()
else else
-- Oh no, we got text. Let't complain to the user, it's probably their fault -- Oh no, we got text. Let't complain to the user, it's probably their fault
print'We are mathematicians, don\'t bother us with text' print'We are mathematicians, don\'t bother us with text'
store_column_xml(to_text(startmath, tex.nest.top.tail)) store_column_xml(to_text(startmath, tex.nest.top.tail)).columnalign = alignment
end end
end end

View File

@ -34,8 +34,19 @@ local function to_unicode(head, tail)
subresult[i] = '\u{FFFD}' subresult[i] = '\u{FFFD}'
end end
end end
-- elseif node.id'math' == id then elseif node.id'math' == id then
-- n = node.end_of_math(n) -- Not sure yet if props then
local mml = props.saved_mathml_table
if mml then
if i ~= 0 then
result[#result+1] = {[0] = 'mtext', table.concat(subresult)}
for j = i, 1, -1 do subresult[j] = nil end
i = 0
end
result[#result+1] = mml
n = node.end_of_math(n)
end
end
-- elseif node.id'whatsit' == id then -- elseif node.id'whatsit' == id then
-- TODO(?) -- TODO(?)
elseif node.id'glue' == id then elseif node.id'glue' == id then
@ -50,12 +61,13 @@ local function to_unicode(head, tail)
subresult[i] = nested[1] subresult[i] = nested[1]
else else
if i ~= 0 then if i ~= 0 then
i = 0
result[#result+1] = {[0] = 'mtext', table.concat(subresult)} result[#result+1] = {[0] = 'mtext', table.concat(subresult)}
for j = i, 1, -1 do subresult[j] = nil end
i = 0
end end
if nested[0] == 'mrow' then if nested[0] == 'mrow' then
table.move(nested, 1, #nested, #result+1, result) table.move(nested, 1, #nested, #result+1, result)
else -- should be unreachable else -- should be unreachable (propbably actually is reachable if the inner list only contains math
result[#result+1] = nested result[#result+1] = nested
end end
end end
@ -71,7 +83,6 @@ local function to_unicode(head, tail)
end end
end end
if i ~= 0 then if i ~= 0 then
i = 0
result[#result+1] = {[0] = 'mtext', table.concat(subresult)} result[#result+1] = {[0] = 'mtext', table.concat(subresult)}
end end
if #result == 0 then if #result == 0 then