From: John Devereux <john@devereux.me.uk>
To: ntg-context@ntg.nl
Subject: Re: Simplified input for natural tables
Date: Sun, 08 Mar 2009 19:10:24 +0000 [thread overview]
Message-ID: <87k56zhlun.fsf@cordelia.devereux.me.uk> (raw)
In-Reply-To: <49B41021.5090000@wxs.nl> (Hans Hagen's message of "Sun\, 08 Mar 2009 19\:36\:17 +0100")
Hans Hagen <pragma@wxs.nl> writes:
> 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
That appears to be exactly what I was after!
(Sorry I don't have MKIV set up right now but will try it when I can).
I don't know if it is of general interest.
I find that writing documents for context - once you get used to it -
is much nicer than using a wordprocessor.
But the process of entering tables remains tedious and error prone,
compared to e.g. the Word equivalent that many will be used to.
--
John Devereux
___________________________________________________________________________________
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
___________________________________________________________________________________
next prev parent reply other threads:[~2009-03-08 19:10 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
2009-03-08 19:10 ` John Devereux [this message]
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=87k56zhlun.fsf@cordelia.devereux.me.uk \
--to=john@devereux.me.uk \
--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).