[luatex] lua script on the run

Philipp Stephani st_philipp at yahoo.de
Fri Jan 7 12:51:16 CET 2011


Am 07.01.2011 um 10:08 schrieb Martin Schröder:

> 2011/1/6 Philipp Stephani <st_philipp at yahoo.de>:
>> Sadly, the documentation for the token library is quite incomplete and sometimes incorrect, but finally I got it to work:
> 
> Patches are welcome. :-)

- token.get_next() removes the next token, which is not documented
- there is no function to peek ahead without removing the next token
- the meaning of the entries of the token tables is undocumented
- the documented values for the "mode" key in the semantic nest level tables are wrong:

\def\printmode#1{%
  \directlua{%
    tex.sprint(tostring(tex.nest[tex.nest.ptr].mode) .. [[ #1]])
  }%
}

\printmode{= 1 = vertical} % print 1, correct

\vbox{
  \printmode{= -1 = internal vertical} % prints -1, correct
}

a \printmode{= 127 = horizontal} % prints 118

\hbox{
  \printmode{= -127 = restricted horizontal} % prints -118
}

$$
\printmode{= 253 = display math} % prints 235
$$

$
\printmode{= -253 = inline math} % prints -235
$

\bye

Please use symbolic constants instead of magic numbers for such things. TeX has already too many magic numbers, and this unfortunate tradition should not continue.



More information about the luatex mailing list