ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Simplified input for natural tables
Date: Sun, 08 Mar 2009 19:36:17 +0100	[thread overview]
Message-ID: <49B41021.5090000@wxs.nl> (raw)
In-Reply-To: <87ocwbhoyc.fsf@cordelia.devereux.me.uk>

John Devereux wrote:
> Hans Hagen <pragma@wxs.nl> writes:
> 
> 
> [...]
> 
> Hi Hans,
> 
> Is there any possible way to use the wiki-style tables like:
> 
> ^ Heading 1 ^ Heading 2 ^
> | Item 1    | Item 2 |
> | Item 3    | Item 4 |
> 
> (Probably with some wrapper)
> 
> Perhaps this boils down to asking if it is possible to (re)define
> "special" characters, within a region of text.

doing that in the running text is asking for troubles (catcode mess)

if there is real interest in that kind of stuff we can make a module 
that does something

\starttext

\startluacode
function commands.wiki_to_table(str) -- wrong namespace
     str = string.gsub(str,"%^ *[\n\r]","\\NC\\NR\n")
     str = string.gsub(str,"%^","\\NC ")
     str = string.gsub(str,"| *[\n\r]","\\NC\\NR\n")
     str = string.gsub(str,"|","\\NC ")
     tex.sprint(tex.ctxcatcodes,"\\startTABLE")
     tex.sprint(tex.ctxcatcodes,str)
     tex.sprint(tex.ctxcatcodes,"\\stopTABLE")
end
\stopluacode

\def\startwikitable
   {\bgroup
    \obeylines
    \dostartwikitable}

\long\def\dostartwikitable#1\stopwikitable
   {\ctxlua{commands.wiki_to_table([[\detokenize{#1}]])}%
    \egroup}

\startwikitable
^ Heading 1 ^ Heading 2 ^
| Item 1    | Item 2 |
| Item 3    | Item 4 |
\stopwikitable

\startTABLE
\NC Text 1 \NC Text 2 \NC \NR
\NC Text 3 \NC Text 4 \NC \NR
\stopTABLE

\stoptext



-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2009-03-08 18:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-08 15:24 Wolfgang Schuster
2009-03-08 16:34 ` Aditya Mahajan
2009-03-08 16:58   ` Hans Hagen
2009-03-08 18:03     ` John Devereux
2009-03-08 18:36       ` Hans Hagen [this message]
2009-03-08 19:10         ` John Devereux
2009-03-09 13:35           ` George N. White III
2009-03-12 10:57             ` Henning Hraban Ramm
2009-03-09 12:15       ` Mojca Miklavec
2009-03-08 19:26     ` Wolfgang Schuster
2009-03-08 19:50       ` Hans Hagen
2009-03-12 17:14 Vyatcheslav Yatskovsky
2009-03-12 18:05 ` Wolfgang Schuster
     [not found] <mailman.19.1236882597.12697.ntg-context@ntg.nl>
2009-03-12 19:51 ` Vyatcheslav Yatskovsky
2009-03-12 20:06   ` Aditya Mahajan
2009-03-12 20:19     ` Wolfgang Schuster
2009-03-13 22:13     ` Mohamed Bana

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=49B41021.5090000@wxs.nl \
    --to=pragma@wxs.nl \
    --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).