mathml/luamml-tex.lua

28 lines
886 B
Lua
Raw Normal View History

2021-04-23 02:58:07 +02:00
local mlist_to_mml = require'luamml-convert'
2021-04-22 23:38:28 +02:00
local process_mlist = mlist_to_mml.process
local register_family = mlist_to_mml.register_family
2021-04-23 02:58:07 +02:00
local mappings = require'luamml-legacy-mappings'
local write_xml = require'luamml-xmlwriter'
2021-04-18 15:19:52 +02:00
2021-04-22 23:38:28 +02:00
local funcid = luatexbase.new_luafunction'RegisterFamilyMapping'
token.set_lua('RegisterFamilyMapping', funcid, 'protected')
lua.get_functions_table()[funcid] = function()
local fam = token.scan_int()
local mapping = token.scan_string()
if mappings[mapping] then
register_family(fam, mappings[mapping])
else
tex.error(string.format('Unknown font mapping %q', mapping))
end
end
2021-04-19 13:30:54 +02:00
luatexbase.add_to_callback('pre_mlist_to_hlist_filter', function(mlist, style)
2021-04-22 23:38:28 +02:00
print''
local xml = process_mlist(mlist, style == 'display' and 2 or 0)
2021-04-19 13:30:54 +02:00
print(write_xml(xml))
-- print(write_xml(xml, '\n'))
2021-04-22 23:38:28 +02:00
print''
2021-04-18 15:19:52 +02:00
return true
end, 'dump_list')