Prepare for better pdfTeX support
This commit is contained in:
parent
f5acbf0ab4
commit
903480a3f9
@ -33,6 +33,7 @@
|
|||||||
\iow_now:Nx \l__luamml_pdf_stream {
|
\iow_now:Nx \l__luamml_pdf_stream {
|
||||||
LUAMML_FORMULA_BEGIN:
|
LUAMML_FORMULA_BEGIN:
|
||||||
\int_use:N \g__luamml_formula_id_int
|
\int_use:N \g__luamml_formula_id_int
|
||||||
|
:3:mrow
|
||||||
}
|
}
|
||||||
\__luamml_pdf_showlists:
|
\__luamml_pdf_showlists:
|
||||||
\iow_now:Nx \l__luamml_pdf_stream {
|
\iow_now:Nx \l__luamml_pdf_stream {
|
||||||
|
@ -32,5 +32,8 @@ node = {
|
|||||||
traverse = function(head)
|
traverse = function(head)
|
||||||
return traverse_iter, head, nil
|
return traverse_iter, head, nil
|
||||||
end,
|
end,
|
||||||
|
direct = {
|
||||||
|
todirect = function(n) return n end,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
tex.nulldelimiterspace = tex.nulldelimiterspace or 78643 -- 1.2pt
|
tex.nulldelimiterspace = tex.nulldelimiterspace or 78643 -- 1.2pt
|
||||||
|
@ -7,8 +7,10 @@ local non_final_list_block = (l.C((1-l.P'\n')^1) * '\n' - '### ' + '\n')^0
|
|||||||
local math_lists_block = l.Ct('### ' * l.Cg(l.C'display' * ' ', 'display')^-1 * 'math mode entered at line ' * l.Cg(l.R'09'^1 / tonumber, 'line') * '\n'
|
local math_lists_block = l.Ct('### ' * l.Cg(l.C'display' * ' ', 'display')^-1 * 'math mode entered at line ' * l.Cg(l.R'09'^1 / tonumber, 'line') * '\n'
|
||||||
* non_final_list_block)^1
|
* non_final_list_block)^1
|
||||||
local generic_list_block = '### ' * (line - 'current page:') * non_final_list_block
|
local generic_list_block = '### ' * (line - 'current page:') * non_final_list_block
|
||||||
local luamml_block = l.Cg('LUAMML_FORMULA_BEGIN:' * id * l.P'\n'^1 * l.Ct(
|
local luamml_block = l.Cg('LUAMML_FORMULA_BEGIN:' * id * ':' * l.Ct(
|
||||||
(math_lists_block + generic_list_block/0)^0
|
l.Cg(id, 'flag') * ':' * l.Cg((1-l.P'\n')^0, 'tag') * l.P'\n'^1
|
||||||
|
|
||||||
|
* (math_lists_block + generic_list_block/0)^0
|
||||||
* (line - 'LUAMML_FORMULA_END\n')^0
|
* (line - 'LUAMML_FORMULA_END\n')^0
|
||||||
* 'LUAMML_FORMULA_END\n') * l.Cc'groups')
|
* 'LUAMML_FORMULA_END\n') * l.Cc'groups')
|
||||||
|
|
||||||
|
37
pdfmml.lua
37
pdfmml.lua
@ -52,13 +52,40 @@ else
|
|||||||
out_stream = assert(io.open(arg[2], 'w'))
|
out_stream = assert(io.open(arg[2], 'w'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
parsed.mathml = {}
|
||||||
|
|
||||||
|
local function shallow_copy(t)
|
||||||
|
local new = {}
|
||||||
|
for k, v in next, t do
|
||||||
|
new[k] = v
|
||||||
|
end
|
||||||
|
return new
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Currently only 3 flag values are supported:
|
||||||
|
-- 0: Ignore (Doesn't make a lot of sense here)
|
||||||
|
-- 1: Only save
|
||||||
|
-- 3: Generate normally
|
||||||
for i, block in ipairs(parsed.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'))
|
local flag, tag = block.flag, block.tag
|
||||||
block = block[1]
|
block = block[1]
|
||||||
local parsed = parse_showlists(block, nil, nil, parsed)
|
if flag & 3 ~= 0 then
|
||||||
local style = block.display and 0 or 2
|
local style = block.display and 0 or 2
|
||||||
stream:write(
|
local xml = convert.process(parse_showlists(block, nil, nil, parsed), style)
|
||||||
to_xml(convert.make_root(convert.process(parsed, style), style)), '\n'
|
if flag & 2 == 2 then
|
||||||
)
|
local stream = out_stream or assert(io.open(out_prefix .. tostring(i) .. out_suffix, 'w'))
|
||||||
|
stream:write(to_xml(convert.make_root(shallow_copy(xml), style)), '\n')
|
||||||
if not out_stream then stream:close() end
|
if not out_stream then stream:close() end
|
||||||
end
|
end
|
||||||
|
if tag ~= 'mrow' then
|
||||||
|
if xml[0] == 'mrow' then
|
||||||
|
xml[0] = tag
|
||||||
|
else
|
||||||
|
xml = {[0] = tag, xml}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if style == 2 and flag & 1 == 1 then
|
||||||
|
parsed.mathml[i] = xml
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
\cs_set_eq:NN \WriteoutFormula \luamml_pdf_write:
|
\cs_set_eq:NN \WriteoutFormula \luamml_pdf_write:
|
||||||
\NewDocumentCommand\AnnotateFormula{ o m m }{%
|
\NewDocumentCommand\AnnotateFormula{ o m m }{%
|
||||||
\IfValueTF{#1}{%
|
\IfValueTF{#1}{%
|
||||||
\luamml_annotate:nnn{#1}%
|
\luamml_annotate:nen{#1}%
|
||||||
}{
|
}{
|
||||||
\luamml_annotate:nn
|
\luamml_annotate:en
|
||||||
}{#2}{#3}
|
}{#2}{#3}
|
||||||
}
|
}
|
||||||
\ExplSyntaxOff
|
\ExplSyntaxOff
|
||||||
|
Loading…
Reference in New Issue
Block a user