ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Pablo Rodriguez <oinos@gmx.es>
Subject: Re: \doifelse not working, \doiftextelse breaking
Date: Fri, 9 Oct 2020 16:08:18 +0200	[thread overview]
Message-ID: <bbad4b8c-e1b7-0992-1ac8-0467ac73b853@gmail.com> (raw)
In-Reply-To: <ce5d3ac5-cf88-5f2c-c1e0-41aa4b65dd65@gmx.es>



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	other threads:[~2020-10-09 14:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-09 13:58 Pablo Rodriguez
2020-10-09 14:08 ` Wolfgang Schuster [this message]
2020-10-09 14:31   ` Pablo Rodriguez
2020-10-09 15:10     ` Wolfgang Schuster
2020-10-09 19:24       ` Pablo Rodriguez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bbad4b8c-e1b7-0992-1ac8-0467ac73b853@gmail.com \
    --to=wolfgang.schuster.lists@gmail.com \
    --cc=ntg-context@ntg.nl \
    --cc=oinos@gmx.es \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).