Compare commits
No commits in common. "912173cab11414b65f9c76937ddefb8eb00b02a9" and "598dfc1b646998d34dcc748191be3a5eeada3a1e" have entirely different histories.
912173cab1
...
598dfc1b64
@ -53,6 +53,6 @@ lua.get_functions_table()[funcid] = function()
|
|||||||
texio.write_nl'WARNING: Tag extraction failed'
|
texio.write_nl'WARNING: Tag extraction failed'
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
store_tag({[0] = 'mtd', last_tag})
|
store_tag({[0] = 'mtd', {[0] = 'mtext', last_tag}})
|
||||||
last_tag = nil
|
last_tag = nil
|
||||||
end
|
end
|
||||||
|
@ -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{[0] = 'mtext', to_text(startmath, tex.nest.top.tail)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
local remap_comb = require'luamml-data-combining'
|
local remap_comb = require'luamml-data-combining'
|
||||||
local stretchy = require'luamml-data-stretchy'
|
local stretchy = require'luamml-data-stretchy'
|
||||||
local to_text = require'luamml-lr'
|
|
||||||
|
|
||||||
local properties = node.get_properties_table()
|
local properties = node.get_properties_table()
|
||||||
|
|
||||||
local hlist_t, kern_t, glue_t, rule_t = node.id'hlist', node.id'kern', node.id'glue', node.id'rule'
|
local kern_t, glue_t = node.id'kern', node.id'glue'
|
||||||
|
|
||||||
local noad_t, accent_t, style_t, choice_t = node.id'noad', node.id'accent', node.id'style', node.id'choice'
|
local noad_t, accent_t, style_t, choice_t = node.id'noad', node.id'accent', node.id'style', node.id'choice'
|
||||||
local radical_t, fraction_t, fence_t = node.id'radical', node.id'fraction', node.id'fence'
|
local radical_t, fraction_t, fence_t = node.id'radical', node.id'fraction', node.id'fence'
|
||||||
@ -88,13 +87,8 @@ local function kernel_to_table(kernel, cur_style)
|
|||||||
}
|
}
|
||||||
return result, result
|
return result, result
|
||||||
elseif id == sub_box_t then
|
elseif id == sub_box_t then
|
||||||
if kernel.list.id == hlist_t then -- We directly give up for vlists
|
local result = {[0] = 'mi', {[0] = 'mglyph', ['tex:box'] = kernel.list}}
|
||||||
local result = to_text(kernel.list.head)
|
return result, result
|
||||||
return result, result
|
|
||||||
else
|
|
||||||
local result = {[0] = 'mi', {[0] = 'mglyph', ['tex:box'] = kernel.list}}
|
|
||||||
return result, result
|
|
||||||
end
|
|
||||||
elseif id == sub_mlist_t then
|
elseif id == sub_mlist_t then
|
||||||
return nodes_to_table(kernel.list, cur_style)
|
return nodes_to_table(kernel.list, cur_style)
|
||||||
else
|
else
|
||||||
@ -188,7 +182,8 @@ local function noad_to_table(noad, sub, cur_style, mn)
|
|||||||
nucleus,
|
nucleus,
|
||||||
{[0] = 'mo', '\u{203E}',},
|
{[0] = 'mo', '\u{203E}',},
|
||||||
}, core
|
}, core
|
||||||
elseif class == 'vcenter' then -- Ignored. Nucleus will need special handling anyway
|
elseif class == 'vcenter' then
|
||||||
|
nucleus['tex:TODO'] = class
|
||||||
else
|
else
|
||||||
error[[confusion]]
|
error[[confusion]]
|
||||||
end
|
end
|
||||||
@ -289,24 +284,6 @@ local function space_to_table(amount, sub, cur_style)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local running_length = -1073741824
|
|
||||||
local function rule_to_table(rule, sub, cur_style)
|
|
||||||
local width = string.format("%.3fpt", rule.width/65781.76)
|
|
||||||
local height = rule.height
|
|
||||||
if height == running_length then
|
|
||||||
height = '0.8em'
|
|
||||||
else
|
|
||||||
height = height
|
|
||||||
end
|
|
||||||
local depth = rule.depth
|
|
||||||
if depth == running_length then
|
|
||||||
depth = '0.2em'
|
|
||||||
else
|
|
||||||
depth = depth
|
|
||||||
end
|
|
||||||
return {[0] = 'mspace', mathbackground = 'currentColor', width = width, height = height, depth = depth}, space_like
|
|
||||||
end
|
|
||||||
|
|
||||||
function nodes_to_table(head, cur_style)
|
function nodes_to_table(head, cur_style)
|
||||||
local t = {[0] = 'mrow'}
|
local t = {[0] = 'mrow'}
|
||||||
local result = t
|
local result = t
|
||||||
@ -323,8 +300,7 @@ function nodes_to_table(head, cur_style)
|
|||||||
and 'normal' or nil
|
and 'normal' or nil
|
||||||
end
|
end
|
||||||
local new_core, new_mn
|
local new_core, new_mn
|
||||||
local props = properties[n]
|
local props = properties[n] props = props and props.mathml_table
|
||||||
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
|
||||||
@ -402,10 +378,10 @@ function nodes_to_table(head, cur_style)
|
|||||||
t[#t+1], new_core = space_to_table(n.width, sub, cur_style)
|
t[#t+1], new_core = space_to_table(n.width, sub, cur_style)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif id == rule_t then
|
else
|
||||||
t[#t+1], new_core = rule_to_table(n, sub, cur_style)
|
new_core = {[0] = 'tex:TODO', other = n}
|
||||||
-- elseif id == disc_t then -- Uncommon, does not play nicely with math mode and no sensible mapping anyway
|
t[#t+1] = new_core
|
||||||
end -- The other possible ids are whatsit, penalty, adjust, ins, mark. Ignore them.
|
end
|
||||||
nonscript = nil
|
nonscript = nil
|
||||||
if core and new_core ~= space_like then
|
if core and new_core ~= space_like then
|
||||||
core = core == space_like and new_core or nil
|
core = core == space_like and new_core or nil
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
local properties = node.get_properties_table()
|
local properties = node.get_properties_table()
|
||||||
|
|
||||||
local function to_unicode(head, tail)
|
local function to_unicode(head, tail)
|
||||||
local result, subresult, i = {[0] = 'mrow'}, {}, 0
|
local result, i = {}, 0
|
||||||
local characters, last_fid
|
local characters, last_fid
|
||||||
local iter, state, n = node.traverse(head)
|
local iter, state, n = node.traverse(head)
|
||||||
while true do
|
while true do
|
||||||
@ -10,7 +10,7 @@ local function to_unicode(head, tail)
|
|||||||
local props = properties[n]
|
local props = properties[n]
|
||||||
if props and props.glyph_info then
|
if props and props.glyph_info then
|
||||||
i = i+1
|
i = i+1
|
||||||
subresult[i] = glyph_info
|
result[i] = glyph_info
|
||||||
else
|
else
|
||||||
local char, fid = node.is_glyph(n)
|
local char, fid = node.is_glyph(n)
|
||||||
if char then
|
if char then
|
||||||
@ -23,15 +23,15 @@ local function to_unicode(head, tail)
|
|||||||
i = i+1
|
i = i+1
|
||||||
if uni then
|
if uni then
|
||||||
if type(uni) == 'number' then
|
if type(uni) == 'number' then
|
||||||
subresult[i] = utf.char(uni)
|
result[i] = utf.char(uni)
|
||||||
else
|
else
|
||||||
subresult[i] = utf.char(table.unpack(uni))
|
result[i] = utf.char(table.unpack(uni))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if char < 0x110000 then
|
if char < 0x110000 then
|
||||||
subresult[i] = utf.char(char)
|
result[i] = utf.char(char)
|
||||||
else
|
else
|
||||||
subresult[i] = '\u{FFFD}'
|
result[i] = '\u{FFFD}'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- elseif node.id'math' == id then
|
-- elseif node.id'math' == id then
|
||||||
@ -41,47 +41,23 @@ local function to_unicode(head, tail)
|
|||||||
elseif node.id'glue' == id then
|
elseif node.id'glue' == id then
|
||||||
if n.width > 1000 then -- FIXME: Coordinate constant with tagpdf
|
if n.width > 1000 then -- FIXME: Coordinate constant with tagpdf
|
||||||
i = i+1
|
i = i+1
|
||||||
subresult[i] = ' '
|
result[i] = ' '
|
||||||
end
|
end
|
||||||
elseif node.id'hlist' == id then
|
elseif node.id'hlist' == id then
|
||||||
local nested = to_unicode(n.head)
|
i = i+1
|
||||||
if nested[0] == 'mtext' and #nested == 1 and type(nested[1]) == 'string' then
|
result[i] = '\u{FFFD}'
|
||||||
i=i+1
|
|
||||||
subresult[i] = nested[1]
|
|
||||||
else
|
|
||||||
if i ~= 0 then
|
|
||||||
i = 0
|
|
||||||
result[#result+1] = {[0] = 'mtext', table.concat(subresult)}
|
|
||||||
end
|
|
||||||
if nested[0] == 'mrow' then
|
|
||||||
table.move(nested, 1, #nested, #result+1, result)
|
|
||||||
else -- should be unreachable
|
|
||||||
result[#result+1] = nested
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif node.id'vlist' == id then
|
elseif node.id'vlist' == id then
|
||||||
i = i+1
|
i = i+1
|
||||||
subresult[i] = '\u{FFFD}'
|
result[i] = '\u{FFFD}'
|
||||||
elseif node.id'rule' == id then
|
elseif node.id'rule' == id then
|
||||||
if n.width ~= 0 then
|
if n.width ~= 0 then
|
||||||
i = i+1
|
i = i+1
|
||||||
subresult[i] = '\u{FFFD}'
|
result[i] = '\u{FFFD}'
|
||||||
end
|
end
|
||||||
end -- CHECK: Everything else can probably be ignored, otherwise shout at me
|
end -- CHECK: Everything else can probably be ignored, otherwise shout at me
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if i ~= 0 then
|
return table.concat(result)
|
||||||
i = 0
|
|
||||||
result[#result+1] = {[0] = 'mtext', table.concat(subresult)}
|
|
||||||
end
|
|
||||||
if #result == 0 then
|
|
||||||
local r = {[0] = 'mtext', ''}
|
|
||||||
return r, r
|
|
||||||
elseif #result == 1 then
|
|
||||||
result = result[1]
|
|
||||||
if result[1] == 'mtext' then return result, result end
|
|
||||||
end
|
|
||||||
return result
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return to_unicode
|
return to_unicode
|
||||||
|
Loading…
Reference in New Issue
Block a user