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? Linas
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
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
On Wed, Oct 02, 2019 at 04:04:50PM +0300, Linas Stonys wrote:
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}
Right. I think there are two parts: Instead of passing a hlist to mlist_to_hlist, adding a second mlist_to_hlist should fail to make it easier to debug the code. I added a bug for this to the LaTeX tracker (https://github.com/latex3/latex2e/issues/188) The other thing you suggest is adding additional pre/post callbacks (similar to pre/post_linebreak_filter) to allow multiple packages to use mlist_to_hlist, right? I think that this is a good idea (also for some other callbacks) but it makes sense to implement this in a package instead of in the LaTeX kernel first to allow some experiments in getting the interface right. Anyways, in my opinion think we should continue this discussion on the LaTeX bug tracker or the LaTeX mailing list (LATEX-L@listserv.uni-heidelberg.de) because it is about how LaTeX deals with LuaTeX callbacks and not about the LuaTeX engine directly. Best regards, Marcel
The other thing you suggest is adding additional pre/post callbacks (similar to pre/post_linebreak_filter) to allow multiple packages to use mlist_to_hlist, right? exactly
I think that this is a good idea (also for some
other callbacks) but it makes sense to implement this in a package instead of in the LaTeX kernel first to allow some experiments in getting the interface right.
Maybe luatexbase is candidate for that. Like now we use luatexbase.add_to_callback() and similar function could add mlist_to_hlist dedicated functions to the list and all of them at one callback function. But you are right it has to become defacto standard that everybody could adapt their packages.
Anyways, in my opinion think we should continue this discussion on the LaTeX bug tracker or the LaTeX mailing list (LATEX-L@listserv.uni-heidelberg.de) because it is about how LaTeX deals with LuaTeX callbacks and not about the LuaTeX engine directly.
ok!
participants (2)
-
Linas Stonys
-
Marcel Fabian Krüger