Tue, 19 Aug 2014 20:10:34 +0200
Am 19.08.2014 um 19:21 schrieb Heiko Oberdiek:
>> local myarg = '\mymacro'
>> texio.write_nl('l3: argument is ' .. tostring(myarg))
>> First, spaces are gone in Lua code. Though, spaces are significant in Lua.
> `\ExplSyntaxOn' says that spaces are gone, that's the purpose of this
> command. Explicit spaces are available via `~':
Have already seen that when using l3's message mechanism, but didn't try
in \directlua. Thanks!
>> Second, variable myarg is nil with \ExplSyntaxOn. (I don't understand why.)
> Without spaces you get:
Should have seen that by myself. Thanks again!
> BTW, this is quite a risky way to pass the contents of user variables ot
> Lua code. Consider syntax errors, if "\mymacro" contains ', or
> "\mymacro" could even contain containing something like:
> '; very evil code; local dummy='
> There is \luaescapestring/\luatexluaescapestring:
It's actually a language string that I'm evaluating to a number via
\the\csname l@#1\endcsname or
\int_use:N\cs:w l@#1\cs_end: in LaTeX3
If #1 contains no valid language identifier, the expression should throw
an error. So, I think I'm safe here. I'm indeed using \luaescapestring
in other circumstances.