Make family mappings configurable in pdfTeX
This commit is contained in:
parent
e7eb77a396
commit
6da728c217
@ -77,6 +77,12 @@
|
||||
\__luamml_pdf_showlists:
|
||||
}
|
||||
|
||||
\NewDocumentCommand \RegisterFamilyMapping {m m} {
|
||||
\iow_log:x {
|
||||
LUAMML_INSTRUCTION:REGISTER_MAPPING: \int_use:N #1 : #2
|
||||
}
|
||||
}
|
||||
|
||||
\endinput
|
||||
|
||||
\cs_new:Npn \__luamml_patch_package:nn #1 #2 {
|
||||
|
@ -14,11 +14,18 @@ local luamml_block = l.Cg('LUAMML_FORMULA_BEGIN:' * id * l.P'\n'^1 * l.Ct(
|
||||
|
||||
local luamml_mark = l.Cg('LUAMML_MARK:' * id * ':' * l.Cs((1 - l.P'\n' + l.Cg('\n' * l.Cc'' - '\nLUAMML_MARK_END\n'))^0) * '\nLUAMML_MARK_END\n' * l.Cc'marks')
|
||||
|
||||
local luamml_instruction = l.Cg('LUAMML_INSTRUCTION:' * l.Cc(nil) * l.C((1 - l.P'\n')^0) * '\n' * l.Cc'instructions')
|
||||
|
||||
local function multi_table_set(t, key, value, table)
|
||||
assert(t[table])[key] = value
|
||||
table = t[table]
|
||||
table[key or #table + 1] = value
|
||||
return t
|
||||
end
|
||||
local log_file = l.Cf(l.Ct(l.Cg(l.Ct'', 'groups') * l.Cg(l.Ct'', 'marks')) * (luamml_block + luamml_mark + line)^0, multi_table_set)
|
||||
local log_file = l.Cf(l.Ct(l.Cg(l.Ct'', 'groups')
|
||||
* l.Cg(l.Ct'', 'marks')
|
||||
* l.Cg(l.Ct'', 'instructions'))
|
||||
* (luamml_block + luamml_mark + luamml_instruction + line)^0,
|
||||
multi_table_set)
|
||||
|
||||
return function(filename)
|
||||
local f
|
||||
|
24
pdfmml.lua
24
pdfmml.lua
@ -4,10 +4,6 @@ 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)
|
||||
|
||||
local parse_showlists = require'pdfmml-showlists'
|
||||
local parse_log = require'pdfmml-logreader'
|
||||
|
||||
@ -30,9 +26,23 @@ if #arg < 1 then
|
||||
If {outname} includes {}, then a separate file is written for every formula with {} replaced by the formula id.\n', arg[0]))
|
||||
os.exit(1)
|
||||
end
|
||||
local math_lists = assert(parse_log(assert(try_extensions(arg[1], '.tml', '.log'),
|
||||
local parsed = assert(parse_log(assert(try_extensions(arg[1], '.tml', '.log'),
|
||||
"Couldn't find input file.")))
|
||||
|
||||
for i, inst in ipairs(parsed.instructions) do
|
||||
local _, _, family, mapping_name = inst:find'^REGISTER_MAPPING:([0-9]+):(.*)$'
|
||||
if family then
|
||||
local mapping = mappings[mapping_name]
|
||||
if mapping then
|
||||
convert.register_family(tonumber(family), mapping)
|
||||
else
|
||||
io.stderr:write(string.format('Unknown mapping %s ignored\n', mapping_name))
|
||||
end
|
||||
else
|
||||
io.stderr:write'Unknown instruction ignored\n'
|
||||
end
|
||||
end
|
||||
|
||||
local out_prefix, out_suffix, out_stream
|
||||
if not arg[2] or arg[2] == '-' then
|
||||
out_stream = io.stdout
|
||||
@ -42,10 +52,10 @@ else
|
||||
out_stream = assert(io.open(arg[2], 'w'))
|
||||
end
|
||||
end
|
||||
for i, block in ipairs(math_lists.groups) do
|
||||
for i, block in ipairs(parsed.groups) do
|
||||
local stream = out_stream or assert(io.open(out_prefix .. tostring(i) .. out_suffix, 'w'))
|
||||
block = block[1]
|
||||
local parsed = parse_showlists(block, nil, nil, math_lists.marks)
|
||||
local parsed = parse_showlists(block, nil, nil, parsed.marks)
|
||||
local style = block.display and 0 or 2
|
||||
stream:write(
|
||||
to_xml(convert.make_root(convert.process(parsed, style), style)), '\n'
|
||||
|
@ -1,9 +1,9 @@
|
||||
\documentclass{article}
|
||||
\usepackage{luamml-pdf}
|
||||
|
||||
% \RegisterFamilyMapping\symsymbols{oms}
|
||||
% \RegisterFamilyMapping\symletters{oml}
|
||||
% \RegisterFamilyMapping\symlargesymbols{omx}
|
||||
\RegisterFamilyMapping\symsymbols{oms}
|
||||
\RegisterFamilyMapping\symletters{oml}
|
||||
\RegisterFamilyMapping\symlargesymbols{omx}
|
||||
|
||||
\ExplSyntaxOn
|
||||
\cs_set_eq:NN \WriteoutFormula \luamml_pdf_write:
|
||||
|
Loading…
Reference in New Issue
Block a user