John Devereux wrote:
Hans Hagen <pra...@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
___________________________________________________________________________________