Add interfaces in LuaTeX for pdfTeX compatibility

This is a combination of 2 commits.

- Provide \luamml_pdf_write: dummy in LuaTeX
- Make labelled formulas accessible in LuaTeX annotations
This commit is contained in:
Marcel Fabian Krüger 2021-06-28 06:36:36 +02:00
parent e76d9ec8bf
commit 5252cbc90d
3 changed files with 13 additions and 8 deletions

View File

@ -2,7 +2,10 @@ local nest = tex.nest
local properties = node.get_properties_table() local properties = node.get_properties_table()
local mark_environment = {} local mark_environment = {
data = {
},
}
local function annotate() local function annotate()
local annotation, err = load( 'return {' local annotation, err = load( 'return {'
@ -98,3 +101,5 @@ end
funcid = luatexbase.new_luafunction'__luamml_annotate_end:e' funcid = luatexbase.new_luafunction'__luamml_annotate_end:e'
token.set_lua('__luamml_annotate_end:e', funcid, 'protected') token.set_lua('__luamml_annotate_end:e', funcid, 'protected')
lua.get_functions_table()[funcid] = annotate lua.get_functions_table()[funcid] = annotate
return mark_environment

View File

@ -159,7 +159,8 @@ lua.get_functions_table()[funcid] = function()
mlist_result = nil mlist_result = nil
end end
require'luamml-tex-annotate' local annotate_context = require'luamml-tex-annotate'
annotate_context.data.mathml = labelled_mathml
return { return {
save_result = save_result, save_result = save_result,

View File

@ -366,16 +366,14 @@
% \end{macrocode} % \end{macrocode}
% %
% \subsection{Trigger for specific formula} % \subsection{Trigger for specific formula}
% This only applies for pdf\TeX\ since in Lua\TeX\ everything is controlled by the callback. % This only applies for pdf\TeX\ since in Lua\TeX\ everything is controlled by the callback,
% % but for compatibility the function is defined anyway.
% \begin{macrocode}
%<*pdftex>
% \end{macrocode}
% %
% \begin{macro}{\luamml_pdf_write:} % \begin{macro}{\luamml_pdf_write:}
% We could accept parameters for the flag and tag here, but for compatibility % We could accept parameters for the flag and tag here, but for compatibility
% with Lua\TeX they are passed in macros instead. % with Lua\TeX they are passed in macros instead.
% \begin{macrocode} % \begin{macrocode}
%<*pdftex>
\cs_new_protected:Npn \luamml_pdf_write: { \cs_new_protected:Npn \luamml_pdf_write: {
\int_gincr:N \g__luamml_formula_id_int \int_gincr:N \g__luamml_formula_id_int
\iow_now:Nx \l__luamml_pdf_stream { \iow_now:Nx \l__luamml_pdf_stream {
@ -393,11 +391,12 @@
LUAMML_FORMULA_END LUAMML_FORMULA_END
} }
} }
%</pdftex>
%<luatex>\cs_new_eq:NN \luamml_pdf_write: \scan_stop:
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
% %
% \begin{macrocode} % \begin{macrocode}
%</pdftex>
% \end{macrocode} % \end{macrocode}
% %
% \subsection{Further helpers} % \subsection{Further helpers}