mathml/showlists_test.lua

29 lines
952 B
Lua
Raw Normal View History

2021-05-31 12:42:51 +02:00
#!/usr/bin/env texlua
require'pdfmml-emulate-node'
2021-05-30 03:29:50 +02:00
local convert = require'luamml-convert'
local mappings = require'luamml-legacy-mappings'
local to_xml = require'luamml-xmlwriter'
convert.register_family(1, mappings.oml)
convert.register_family(2, mappings.oms)
convert.register_family(3, mappings.omx)
2021-05-31 12:42:51 +02:00
local parse_showlists = require'pdfmml-showlists'
local parse_log = require'pdfmml-logreader'
2021-05-29 12:39:24 +02:00
2021-05-31 12:42:51 +02:00
if #arg < 1 then
io.stderr:write(string.format('Usage: %0 {logname} \n', arg[0]))
os.exit(1)
end
local math_lists = assert(parse_log(arg[1]))
2021-05-29 12:39:24 +02:00
2021-05-31 12:42:51 +02:00
local out_stream = arg[2] and arg[2] ~= '-' and assert(io.open(arg[2], 'w')) or io.stdout
2021-05-30 03:29:50 +02:00
for i, block in ipairs(math_lists) do
block = block[1]
local parsed = parse_showlists(block)
local style = block.display and 0 or 2
2021-05-31 12:42:51 +02:00
out_stream:write(
to_xml(convert.make_root(convert.process(parsed, style), style))
)
2021-05-30 03:29:50 +02:00
end
2021-05-31 12:42:51 +02:00
-- if ... then out_stream:close() end -- Don't bother since we terminate anyway