[NTG-context] need help comparing strings

Wolfgang Schuster wolfgang.schuster.lists at gmail.com
Tue Oct 13 19:14:02 CEST 2020


Pablo Rodriguez schrieb am 13.10.2020 um 19:06:
> On 10/13/20 5:54 PM, Aditya Mahajan wrote:
>> On Tue, 13 Oct 2020, Pablo Rodriguez wrote:
>>> [...]
>>> Could anyone explain me what I’m missing here?
> Many thanks for your reply, Aditya.
>
>> I find it simpler to write macros where there is clean communicating
>> between tex and lua. For example:
>> [...]
>>      \define[1]\numbersfname
>>          {\cldcontext{userdata.numbersfname([==[#1]==])}}
> This is the first time I see that way of wrapping an argument.
>
> In any case, I cannot compare to a number:
>
>    \startluacode
>      userdata = userdata or {}
>      function userdata.numbersfname(name)
>          return string.match(name, "%d+")
>      end
>    \stopluacode
>
>    \define[1]\numbersfname
>        {\cldcontext{userdata.numbersfname([==[#1]==])}}

Untested:

\defineexpandable[1]\numbersfname
   {\cldcontext{userdata.numbersfname([==[#1]==])}}

Wolfgang



More information about the ntg-context mailing list