LATEX-L Archives

Mailing list for the LaTeX3 project


Options: Use Classic View

Use Proportional Font
Show Text Part by Default
Condense Mail Headers

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

Print Reply
Sender: Mailing list for the LaTeX3 project <[log in to unmask]>
Date: Tue, 19 Aug 2014 20:10:34 +0200
Reply-To: Mailing list for the LaTeX3 project <[log in to unmask]>
Message-ID: <[log in to unmask]>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
In-Reply-To: <[log in to unmask]>
Content-Type: text/plain; charset=us-ascii
From: Stephan Hennig <[log in to unmask]>
Parts/Attachments: 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