TeX interface to retrieve handle for MML
This commit is contained in:
parent
8843b99ece
commit
26e1ffad33
@ -24,7 +24,6 @@ lua.get_functions_table()[funcid] = function()
|
|||||||
mml = {[0] = 'mtd', mml}
|
mml = {[0] = 'mtd', mml}
|
||||||
end
|
end
|
||||||
local row_temp = tex.nest[tex.nest.ptr-1]
|
local row_temp = tex.nest[tex.nest.ptr-1]
|
||||||
print(row_temp)
|
|
||||||
props = properties[row_temp]
|
props = properties[row_temp]
|
||||||
if not props then
|
if not props then
|
||||||
props = {}
|
props = {}
|
||||||
@ -42,7 +41,6 @@ token.set_lua('luamml_amsmath_finalize_row:', funcid, 'protected')
|
|||||||
lua.get_functions_table()[funcid] = function()
|
lua.get_functions_table()[funcid] = function()
|
||||||
-- TODO: Error handling etc
|
-- TODO: Error handling etc
|
||||||
local row_temp = tex.nest[tex.nest.ptr-1]
|
local row_temp = tex.nest[tex.nest.ptr-1]
|
||||||
print("final", row_temp)
|
|
||||||
local props = properties[row_temp]
|
local props = properties[row_temp]
|
||||||
if not props then return end
|
if not props then return end
|
||||||
if not props.mathml_row then return end
|
if not props.mathml_row then return end
|
||||||
|
@ -36,6 +36,7 @@ end
|
|||||||
-- Bit 2: Integrate with table mechanism
|
-- Bit 2: Integrate with table mechanism
|
||||||
|
|
||||||
local mlist_buffer
|
local mlist_buffer
|
||||||
|
local mlist_result
|
||||||
|
|
||||||
luatexbase.add_to_callback('pre_mlist_to_hlist_filter', function(mlist, style)
|
luatexbase.add_to_callback('pre_mlist_to_hlist_filter', function(mlist, style)
|
||||||
local flag = tex.count.l__luamml_flag_int
|
local flag = tex.count.l__luamml_flag_int
|
||||||
@ -56,7 +57,7 @@ luatexbase.add_to_callback('pre_mlist_to_hlist_filter', function(mlist, style)
|
|||||||
end
|
end
|
||||||
local xml = process_mlist(new_mlist, style == 'display' and 0 or 2)
|
local xml = process_mlist(new_mlist, style == 'display' and 0 or 2)
|
||||||
if flag & 2 == 0 then
|
if flag & 2 == 0 then
|
||||||
print(write_xml(make_root(xml, (style == 'display' or flag & 1 == 1) and 0 or 2)) .. '\n')
|
mlist_result = write_xml(make_root(xml, (style == 'display' or flag & 1 == 1) and 0 or 2))
|
||||||
else
|
else
|
||||||
assert(style == 'text')
|
assert(style == 'text')
|
||||||
local startmath = tex.nest.top.tail
|
local startmath = tex.nest.top.tail
|
||||||
@ -73,3 +74,15 @@ luatexbase.add_to_callback('pre_mlist_to_hlist_filter', function(mlist, style)
|
|||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end, 'dump_list')
|
end, 'dump_list')
|
||||||
|
|
||||||
|
funcid = luatexbase.new_luafunction'luamml_get_last_mathml_stream:e'
|
||||||
|
token.set_lua('luamml_get_last_mathml_stream:e', funcid)
|
||||||
|
lua.get_functions_table()[funcid] = function()
|
||||||
|
if not mlist_result then
|
||||||
|
tex.error('No current MathML data', {
|
||||||
|
"I was asked to provide MathML code for the last formula, but there weren't any new formulas since you last asked."
|
||||||
|
})
|
||||||
|
end
|
||||||
|
tex.sprint(-2, tostring(pdf.immediateobj('stream', mlist_result, '/Subtype /application#2Fmathml+xml\n' .. token.scan_argument(true))))
|
||||||
|
mlist_result = nil
|
||||||
|
end
|
||||||
|
@ -14,4 +14,4 @@
|
|||||||
\int_set:Nn \l__luamml_flag_int { 6 }
|
\int_set:Nn \l__luamml_flag_int { 6 }
|
||||||
}
|
}
|
||||||
|
|
||||||
\RequirePackage { luamml-patches-amsmath }
|
% \RequirePackage { luamml-patches-amsmath }
|
||||||
|
@ -4,10 +4,17 @@
|
|||||||
\usepackage{luamml}
|
\usepackage{luamml}
|
||||||
\RegisterFamilyMapping\symsymbols{oms}
|
\RegisterFamilyMapping\symsymbols{oms}
|
||||||
\RegisterFamilyMapping\symletters{oml}
|
\RegisterFamilyMapping\symletters{oml}
|
||||||
|
\ExplSyntaxOn
|
||||||
|
\pdfvariable compresslevel0
|
||||||
|
\cs_new_protected:Npn \ShowMathMLObj {
|
||||||
|
\message { \luamml_get_last_mathml_stream:e{}~0~R }
|
||||||
|
}
|
||||||
|
\ExplSyntaxOff
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\[
|
\[
|
||||||
ax^2+bx+c=0
|
ax^2+bx+c=0
|
||||||
\]
|
\]
|
||||||
|
\ShowMathMLObj
|
||||||
\[
|
\[
|
||||||
x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}.
|
x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}.
|
||||||
\]
|
\]
|
||||||
|
Loading…
Reference in New Issue
Block a user