LATEX-L Archives

Mailing list for the LaTeX3 project


Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Stephan Hennig <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Tue, 19 Aug 2014 20:10:34 +0200
text/plain (47 lines)
Am 19.08.2014 um 19:21 schrieb Heiko Oberdiek:

>> \ExplSyntaxOn
>> \directlua{
>>   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:
>   localmyarg='\mymacro'

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:
>   '\luatexluaescapestring{\mymacro}'

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.

Stephan Hennig