On Fri, Oct 6, 2017 at 5:30 PM, Craig Parker-Feldmann
<tschaka-do...@email.de> wrote:
> What I want to know is: am I going about this in a sensible way?

The use case you presented is definitely easier to implement in Lua
than in TeX, or at least more straightforward. However, you should
consider if you want to support other engines, in which case having a
dedicated Lua implementation would only make sense if it were faster.

> I am also unsure as to which strategy I would use to implement the percent 
> character in a pattern expression.

That's one of the several problems of embedding Lua code in TeX. The
usual solution is to split off the bulk of the Lua code to a separate
module and retain only the minimum in \directlua (namely require and
the function call). Sometimes it's feasible to use \luafunction, which
avoids any Lua parsing, passing arguments through registers.

You should also consider using \luaescapestring to pass strings to
Lua; without it, TeX token sequences will be passed as-is, which can
raise Lua errors.

Regards,
David

Reply via email to