Closed lemzwerg closed 1 year ago
If the luatexbase
module is available, nodetree
uses luatexbase
to register its callbacks. Using luatexbase
it is possible to register multiple callbacks.
In plain LuaTex you can load luatexbase
using \input ltluatex.tex
Yes, I could do this on the lua side. However, it would be nice to make 'nodetree' do something like the following pseudo-code if I call \NodetreeRegisterCallback
.
<get original hook>
if <pre>
new_hook = function, which calls nodetree hook then original hook
else if <post>
new_hook = function, which calls original hook then nodetree hook
else
new_hook = nodetree hook
By the way, the newest version of luatexbase.add_to_callback
(as distributed with the core LaTeX stuff) allows to install stuff 'before' and 'after' hooks...
... the newest version of luatexbase.add_to_callback allows to install stuff 'before' and 'after' hooks...
Are you sure? As I understand it, you can only change the order of the registered user functions.
http://mirrors.ctan.org/macros/latex/base/ltluatex.pdf
luatexbase.declare_callback_rule(⟨name⟩, ⟨first⟩, ⟨relation⟩, ⟨second ⟩)
: relation = before | after
<get original hook> if <pre> new_hook = function, which calls nodetree hook then original hook else if <post> new_hook = function, which calls original hook then nodetree hook else new_hook = nodetree hook
thanks for your thoughts in pseudo code form. I don't know how to get the original hook? Is the original hyphenate algorithm not written in C? If your registered hyphenate hook returns false, then the internal hyphenate algorithm is disabled.
From the LuaTeX manual:
No return values. This callback has to insert discretionary nodes in the node list it receives. Setting this callback to false will prevent the internal discretionary insertion pass.
I'm a LuaTeX newbie, so I'm not sure at all and just poke in the dark. Perhaps I got this wrong. It probably makes sense to discuss this on the LuaTeX mailing list...
I have drawn a diagram that visualizes in what order the callbacks are called: Callbacks graph
This looks great, but I don't understand it at all. Please add a legend and some more documentation.
I tried to visualize in which order the callbacks are executed. The ligaturing
hook is always called after the hyphenate
hook. But before the hyphenate
hook come many different hooks.
OK. However, some steps need more explanation IMHO.
The wanted functionality is now available by using leading and trailing colons to the callback name (commit ac67fe792bb37b51c21f7629e7f4f2fa4933b91b and some follow-up fixes until a52c7560a6efdd3e6abbb79867c3e2ba4670d8a9).
Right now, if I select, say, the
hyph
hook, 'nodetree' completely replaces any existing hooks with its own. This makes it inconvenient to actually watch what already installed hooks (or LuaTeX's default actions) actually do.I thus suggest a new feature to improve this: If I add a prefix
pre-
orpost-
to a hook name, nodetree's hook gets installed as the very first or the very last, respectively. For example, adding bothpre-hyph
andpost-hyph
would allow me closely watch what LuaTeX's default hyphenation handler is doing.