On 4/10/2024 7:49 PM, Pablo Rodriguez via ntg-context wrote:
Dear list,
I have the following sample:
\starttext \startluacode function document.print_the_thing(str) context(str) end \stopluacode
\unexpanded\def\PrintTheThing#1{% \ctxlua{document.print_the_thing([[\luaescapestring{#1}]])}}
\PrintTheThing{a \em b {c}} \stoptext
I wonder whether there is a proper way in the Lua code to avoid [[\luaescapestring{}]] in \ctxlua.
BTW, [[\luaescapestring{}]] in \ctxlua works better for me, since in my real world document, I’m using str:match() to check whether the string ends with interrogation or exclamation marks ("%?!$"). \starttext \startluacode function document.print_the_thing() context(tokens.scanners.string()) end \stopluacode
\protected\def\PrintTheThing{\ctxlua{document.print_the_thing()}} \PrintTheThing{a \em b {\bf c} d} \stoptext bonus: test!\removepunctuation ? Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------