# [luatex] Creating a token list

Henri Menke henrimenke at gmail.com
Tue Mar 5 21:22:26 CET 2019


On 6/03/19 3:26 AM, Javier Bezos wrote:
> I wrote:
>
>> How can I create a token list to feed a "write"
>> whatsit? For example, let's suppose I want to write
>> \string\doit{\the\lastypos}.
>
> :-/ Is there no way? Well, I can define a box with a
> \write and then inspect the node (and it works with
> some caveats), but there must be a pure lua solution.

I have no idea what you mean.  Your description is very unclear.  Is it
something like this that you want to do?

\def\doit#1{#1}

\newbox\doitbox
\newtoks\doittoks

\directlua{
tex.scantoks("doittoks", 0, "\luaescapestring{\setbox\doitbox=\hbox{\string\doit{\the\lastypos}}}")
tex.runtoks("doittoks")
for n in node.traverse_id(node.id"glyph", tex.box.doitbox.list) do
print(unicode.utf8.char(n.char))
end
}

\bye

>
> Javier
>