ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Christopher Creutzig <christopher@creutzig.de>
Subject: Re: Antwort: Re: XML
Date: Fri, 23 Sep 2005 21:33:02 +0200	[thread overview]
Message-ID: <4334586E.4040804@creutzig.de> (raw)
In-Reply-To: <20050923150329.14468@mail.comp.lancs.ac.uk>

Adam Lindsay wrote:

> I'm not sure I understand the "CVS or something else" part from the

 Probably a typo for CSV, comma-seperated values.

 It should be rather easy to typeset csv data in table format.  The
following tentative code ignores the fact that csv data may optionally
be enclosed in "" quotes that have to be removed (to be done in
TBLentry) and that these quoted strings may contain commas themselves
(which means writing a custom version of \processcommalist instead).
Apart from that, it seems to work.  (I just felt an urge of creativism,
so I took up the challenge.)


\def\TBLentry#1{\bTD#1\eTD}
\def\TBLline#1{\bTR\processcommalist[#1]\TBLentry}

% Iterate over all the lines of text captured with \obeylines active
% command to call is first argument, is not called for empty lines
\bgroup
\obeylines
\gdef\ProcessLines#1#2{\doProcessLines{#1}#2^^M\doProcessLines}%
\gdef\doProcessLines#1#2^^M#3\doProcessLines{%
  \doifnotempty{#2}{#1{#2}}%
  \doifnotempty{#3}{\doProcessLines{#1}#3\doProcessLines}%
}%
\egroup

\def\startCSV{\bgroup\obeylines\dostartCSV}

\def\dostartCSV#1\stopCSV{%
   \bTABLE
   \ProcessLines\TBLline{#1}%
   \eTABLE
   \egroup
}


\starttext
CSV test:

\startCSV
a,b,c,d,e
1,2,3,4,5
6,7,8,9,10
some text,11,12,,14
\stopCSV

\stoptext


 Hans, what goodies of ConTeXt did I miss?  Is the above sufficiently
ConTeXtish to be wikiable?


regards,
	Christopher

      reply	other threads:[~2005-09-23 19:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-22  7:53 Jessica Holle
2005-09-23 14:29 ` Henning Hraban Ramm
2005-09-23 15:03   ` Adam Lindsay
2005-09-23 19:33     ` Christopher Creutzig [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=4334586E.4040804@creutzig.de \
    --to=christopher@creutzig.de \
    --cc=ntg-context@ntg.nl \
    /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).