[luatex] lua script on the run

Khaled Hosny khaledhosny at eglug.org
Thu Jan 6 13:12:16 CET 2011


On Thu, Jan 06, 2011 at 11:41:44AM +0100, Arno Trautmann wrote:
> Philipp Stephani wrote:
> > 
> > […]
> >> \texperanto{Alportu ^caron de sopiro!}
> >>
> >> And LuaTeX actually typesets "Alportu ĉaron de sopiro!"
> > 
> > If you only need simple textual replacements, you can get quite far with Lua's built-in functions:
> > 
> > \documentclass{minimal}
> > \usepackage{fontspec}
> > \usepackage{luacode}
> > \begin{luacode*}
> >  function texperanto(text)
> >    tex.sprint((text:gsub("%^c", "ĉ")))
> >  end
> > \end{luacode*}
> > \newcommand*{\texperanto}[1]{\luadirect{texperanto([[#1]])}}
> > \setmainfont{DejaVu Sans}
> > \begin{document}
> > \texperanto{Alportu ^caron de sopiro!}
> > \end{document}
> 
> These solutions (Patrick's, Paul's and yours) are nice, but how would
> one apply it to a whole document? I have a very similar need and it
> would be nice not to put the whole document inside the \texperanto
> macro. Would it be a good ideo to use this with \everypar to get the
> paragraph gsub'd?

May be you can use "process_input_buffer" callback, but this gets the
raw input before luatex even processing it so you have to be careful
with control sequences and so.

Or you can do the processing on the node list, but then you can't used
regular text processing functions (gsub, lpeg, etc.)

Regards,
 Khaled

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



More information about the luatex mailing list