[luatex] Expanding text in lua

Taco Hoekwater taco at elvenkind.com
Sun Oct 31 10:39:46 CET 2010


On 10/31/2010 10:32 AM, Khaled Hosny wrote:
> (Pretending to be TeXhacker and using terminology I don't actually
> understand)
> I was wondering if one can take a string of TeX input and expand it at
> lua end to get its basic form for further processing, say we have:
>
> \def\sometext{some text}
> \def\sometalk{I wrote\sometext\ for a talk}
>
> Then I can pass \sometalk to lua and get the "I wrote some text for a
> talk" string out of it.

As the body of \directlua is always expanded immediately, it is quite
trivial:

   \def\doexpand#1{\directlua{tex.sprint("#1")}}
   \edef\expandedsome{\doexpand\sometalk}

but there is very little point to that, it is just a complicated way
of writing

   \edef\expandedsome{\sometalk}

Best wishes,
Taco



More information about the luatex mailing list