Pablo Rodriguez schrieb am 09.10.2020 um 15:58:
Dear list,

I have the following sample:

     \starttext
     \startluacode
     function document.starts_with(str, start)
       if str:sub(1, #start) == start then
         context(start)
       end
     end
     \stopluacode

     \unexpanded\def\startswith[#1][#2]
         {\cldcontext{document.starts_with("#1", "#2")}}


You need a % at the end of the definition, otherwise TeX expects a space after the second argument to end the command.

\unexpanded\def\startswith[#1][#2]%
  {...}


To improve your command and allow a space between both arguments you can use

\unexpanded\def\startswith
  {\dodoubleargument\dostartswith}

\def\dostartswith[#1][#2]%
  {...}

or just add a dummy parameter and use #1 and #3 to pass the arguments

\unexpanded\def\startswith[#1]#2[#3]%
  {...}


Wolfgang
___________________________________________________________________________________
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