[NTG-context] \doifelse not working, \doiftextelse breaking
Wolfgang Schuster
wolfgang.schuster.lists at gmail.com
Fri Oct 9 16:08:18 CEST 2020
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
More information about the ntg-context
mailing list