Here is an example of what I'm talking about:
\documentclass{article}
\directlua{
luatexbase.add_to_callback('mlist_to_hlist',
function (h, d, p)
  print ("I'm here")
  return node.mlist_to_hlist(h, d, p)
end,
'mlist modifier')
}

\usepackage[color=no]{nodetree}
\nodetreeregister{mhlist}

\begin{document}
$a$
\end{document}




On 10/2/2019 3:45 PM, Marcel Fabian Krüger wrote:
On Wed, Oct 02, 2019 at 02:45:57PM +0300, Linas Stonys wrote:
Hi luatex team,
mlist_to_hlist callback requires to return a hlist. And that is a big problem 
because
there is no possibility to use this callback if some style already used it.
If two different styles uses this callback luatex always throws error "! This can't 
happen (mlist1)."
because mlist is already converted to hlist for second callback.
I want to offer a new callback "mlist_to_mlist" were one could access math list 
without conversion to hlist.
Usually if one uses this callback he needs mlist and not a hlist.
And probably would be even better to have one more callback "mhpack_filter" 
which could access result of
node.milst_to_hlist(math list converted hlist).

So mlist_to_hlist callback would be splited into to parts like:

m = list_of_mlist_to_mlist_callbacks (h)
n = node.mlis_to_hlist(m)
x = list_of_mhpack_filter_callbacks (n)
return x

What do you think?

Hello,

this doesn't need a change in LuaTeX, it can be implemented on top of
the current callback. Basically you just have to add your code as
mlist_to_hlist callback, where list_of_mlist_to_mlist_callbacks and
list_of_mhpack_filter_callbacks are implemented in Lua.

Additionally, you probably also want to use a callback for
node.mlist_to_hlist if someone wants to customize the complete
conversion.

The "big problem" is a LaTeX bug: Normally mlist_to_hlist in it's
current form should be an exclusive fallback, but currently LaTeX allows
multiple callbacks to be registered for it, leading to the error you
found. That problem exists for multiple callbacks, so you might want to
report it on the LaTeX bug tracker (https://github.com/latex3/latex2e/issues).

-- Marcel


_______________________________________________
dev-luatex mailing list
dev-luatex@ntg.nl
https://mailman.ntg.nl/mailman/listinfo/dev-luatex

Reply via email to