Hi all, I just released a snapshot with a fun (but not yet complete) new feature you may want to play with. What's new: * The OCP debug information is removed again. * There is a new callback that I am quite excited about myself: 'token_filter'. A bit of text from the reference manual: -------------------- This callback allows you to change the modify any lexical token that enters the \type{main_control} function before \LUATEX\ executes the associated command. Note: not all tokens can be intercepted yet, only those that are `seen' by \LUATEX's main control function. Supplemental tokens like the bodies of macro definitions and the right-hand side of register assignments are not seen. For now, this is intentional. \startfunctioncall function (table <token>) return table <token> end \stopfunctioncall Calling convention for this callback is bit more complicated then for most other callbacks. Initially, lua function will be called with the next token from \type{get_next()} as argument, represented as a small lua table. The function should either return a lua table representing a valid to-be-processed token, or something else like nil or an empty table. If your lua function does not return a table representing a valid token, it will be immediately called again with yet another token from \type{get_next()} as argument, until it eventually does return a useful token. But if the function does return a usable token, then that token will be processed by \LUATEX. Afterwards, the function will be called again, but now without an argument. This is repeated until it stops returning tokens. Then processing reverts back to the other branch. The point behind that roundabout calling convention is that it allows the lua function to buffer tokens for various uses. That in turn makes it possible to do some really advanced things like replacing OTPs. Now about that table. The table that the function will receive contains four fields: \starttabulate[|l|i|p|] \NC Key \NC type \NC Explanation \NC\FR \NC cmd \NC string \NC A representation of \LUATEX's internal command code\NC\NR \NC chr \NC number \NC The command code modifier\NC\NR \NC cs \NC string \NC If the token came from a csname, this is that csname\NC\NR \NC mod \NC character \NC A single character string representing the current processing mode. One of {\bf v}ertical, {\bf h}orizontal, display {\bf m}ath, {\bf n}o, internal {\bf V}ertical, restricted {\bf H}orizontal, or inline {\bf M}ath mode.\NC\LR \stoptabulate If you modify the table before returning it, then it is wise to return either a (\type{cmd}, \type{chr}) pair, or a \type{cs} string. That is because if both options are present, the pair has precedence and the string is ignored. On the return table, {\bf mod} is ignored always. -------------- I have no long example code yet and it is not as complete as one would want it to be because it is not intercepting everything that comes in, only the bits that are triggered by the main control loop. I decided to do a fast snapshot release for two reasons: * It is one of the easier extensions to get started with if you want to learn a bit about lua programming * I would welcome feedback on the token interface, because it will be needed in other places as well, soon. I am still not sure whether converting the command to/from strings is worth it, for example. And maybe it would be less confusing if you could return a list of tokens instead of being called repeatedly? Here is the trivial example to get you started: \directlua0{ callback.register('token_filter', function (t) return t end) } Happy TeXing, Taco ----- Downloading and installation details: If you go to https://foundry.supelec.fr/frs/?group_id=10 you will see that there are three new released files: * luatex-snapshot-20070309.tar.bz2 This is the source tree. * luatex-snapshot-20070309-win32.zip A cross-compiled (mingw) windows binary. This is a web2c based binary, so it needs a texmf.cnf file (It will NOT work if you have only miktex installed). * luatex-snapshot-20070309-linux-i386.tar.bz2 An intel 32 linux binary (2.6.17)
Hi all! On Fre, 09 Mär 2007, Taco Hoekwater wrote:
* luatex-snapshot-20070309.tar.bz2
Debian packages at the usual place. I was a bit late due to being in the
mountains for some time ...
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining
participants (2)
-
Norbert Preining
-
Taco Hoekwater