ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Pablo Rodriguez via ntg-context <ntg-context@ntg.nl>
To: Pablo Rodriguez via ntg-context <ntg-context@ntg.nl>
Cc: Pablo Rodriguez <oinos@gmx.es>
Subject: [NTG-context] Re: command to process CSV file (database module)
Date: Sun, 5 Nov 2023 19:00:14 +0100	[thread overview]
Message-ID: <e6a75e41-64dd-1f5e-9b44-6344c0ccd47f@gmx.es> (raw)
In-Reply-To: <3fea5631-1466-69c5-e2fe-be95e0599786@gmx.es>

On 11/5/23 13:56, Pablo Rodriguez via ntg-context wrote:
> [...]
> I get an error about an unexpected symbol near "\" in the line of
> "\processdatabasefile".
>
> Could anyone enlighten me about what I am missing here?

Replying to myself, thanks to the wiki
(https://wiki.contextgarden.net/Commands_with_optional_arguments).

It seems that the command has to be defined as unexpanded, such as in:

  \setupinteraction[state=start]
  \setupattachments[method=hidden]
  \usemodule[database]

  \starttext

  \unexpanded\def\ItemContents#1#2#3{\doiftext{#2}
    {\item {\em #1}\attachment[file=#2, name=\currentitemnumber-#2]%
      \doiftext{#3}{ (also available at #3)}}}

  \defineseparatedlist
     [test]
     [separator={,},
      quotechar={"},
      before={\startitemize[n]},after={\stopitemize},
      first={\ItemContents},last={.},
      left={\{},right={\}}]

  \processdatabasefile[test][context-documents.csv]

  \stoptext

It is not clear for me why is this needed, but it might be one of the
many aspects of expansion that average users cannot understand from TeX.

Many thanks for your help,

Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

      reply	other threads:[~2023-11-05 18:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-05 12:56 [NTG-context] " Pablo Rodriguez via ntg-context
2023-11-05 18:00 ` Pablo Rodriguez via ntg-context [this message]

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=e6a75e41-64dd-1f5e-9b44-6344c0ccd47f@gmx.es \
    --to=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).