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]==])}}

  \starttext
  \numbersfname{abc123}

  \numbersfname{\env{fname}}
  \doifelse{\numbersfname{\env{fname}}}{123}{yes}{no}
  \stoptext

I don’t know why both strings don’t match.

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to