[luatex] lua script on the run

Philipp Stephani st_philipp at yahoo.de
Thu Jan 6 20:50:30 CET 2011

Am 06.01.2011 um 20:06 schrieb Luis Rivera:

> "tables and functions". So how would you set a table for the six
> special characters of esperanto (^c, ^g, ^h, ^j, ^s, ^u)?

  local translate = {
    c = "ĉ",
    g = "ĝ",
    h = "ĥ",
    j = "ĵ",
    s = "ŝ",
    u = "û"
  function texperanto(text)
    result = text:gsub("\percentchar^(\percentchar a)", translate)
\input luaotfload.sty
\font\rm={name:DejaVu Sans:}\relax
\texperanto{^a ^b ^c ^d ^e ^f ^g ^h ^i ^j ^s ^u}

> I thought of a macro package independent solution. This one works for
> LuaLaTeX, but Patrick's should also work for plain LuaTeX.

of course that's possible, but a bit more awkward since you have to e.g. escape percent characters. "macro package independence" is even harder with LuaTeX than with pdfTeX, since you need lots of external packages to e.g. load fonts. Luaotfload works with LaTeX and plain, but probably not with ConTeXt, which is completely different anyway.

> What occurs to me is to use a babel-like solution: make ^ active in
> textual context, and define it in terms of Lua functions so that it
> may check the following character and apply a conversion on a match:
> otherwise, typeset the original two character string.

Never do this if you have LuaTeX, it is completely obsolete and causes many issues. If you are sure to run on LuaTeX, do everything in Lua, and avoid catcode changes and the like.

More information about the luatex mailing list