# [luatex] Expanding text in lua

Khaled Hosny khaledhosny at eglug.org
Sun Oct 31 10:59:53 CET 2010

On Sun, Oct 31, 2010 at 10:39:46AM +0100, Taco Hoekwater wrote:
> 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}

Aha, I never thought it would just work that I never tried, thanks for
the tip :) (well, I've read it countless times in the manual, but I
never really understood what is meant, though pretending I do).

Regards,
Khaled

--
Khaled Hosny
Arabic localiser and member of Arabeyes.org team
Free font developer