Discussion:
[NTG-context] directlua question
Hans van der Meer
2018-12-04 12:29:14 UTC
Permalink
I am trying to extract something from a string with a \directlua call, the last word of a string in case:

\directlua{tex.print(string.match(“This is a string","%s%a$"))}

However, the %s%a are not working with the TeX-error “unfinished string near eof”. Obviously caused by the %’s.
How to get this working? \textpercent will not do, off course within Luacode.

dr. Hans van der Meer
Hans van der Meer
2018-12-04 12:41:32 UTC
Permalink
Post by Hans van der Meer
\directlua{tex.print(string.match(“This is a string","%s%a$"))}
However, the %s%a are not working with the TeX-error “unfinished string near eof”. Obviously caused by the %’s.
How to get this working? \textpercent will not do, off course within Luacode.
Also I tried to no avail

\begingroup\catcode`\%=12\relax\directlua{tex.print(string.match(“This is a string","%s%a$"))}\endgroup

dr. Hans van der Meer
Wolfgang Schuster
2018-12-04 12:44:43 UTC
Permalink
Post by Hans van der Meer
I am trying to extract something from a string with a \directlua call,
\directlua{tex.print(string.match(“This is a string","%s%a$"))}
However, the %s%a are not working with the TeX-error “unfinished string
near eof”. Obviously caused by the %’s.
How to get this working? \textpercent will not do, off course within Luacode.
% = \letterpercent
$ = \letterdollar

You can also replace

\directlua{tex.print(...)}

with

\ctxlua{context(...)}

or

\cldcontext{...}

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
_____________________________________________________________________________
Loading...