tabl-nte.mkiv /size: 3180 b    last modification: 2021-10-28 13:50
1%D \module
2%D   [       file=core-nte,
3%D        version=2009.03.08,
4%D          title=\CONTEXT\ Table Macros,
5%D       subtitle=Natural Tables Extensions,
6%D         author=Hans Hagen \& Wolfgang Schuster,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Table Module / Natural Tables Extensions}
15
16\unprotect
17
18%D This module is suggested by Wolfgang Schuster who also prototyped
19%D it and came up with the rationale:
20%D
21%D This module provides an easy way to use natural in a similiar
22%D way as the older table module (based on the \TABLE\ macros) and
23%D the newer tabulate module.
24%D
25%D You can see the advantage in the following table, once created
26%D with the new macros and once with the normal macros provided
27%D with the natural table module.
28%D
29%D Let us start with the original macros:
30%D
31%D \startbuffer
32%D \bTABLE
33%D   \bTR
34%D     \bTD Text 1 \eTD
35%D     \bTD Text 2 \eTD
36%D   \eTR
37%D   \bTR
38%D     \bTD Text 3 \eTD
39%D     \bTD Text 4 \eTD
40%D   \eTR
41%D \eTABLE
42%D \stopbuffer
43%D
44%D \typebuffer \getbuffer
45%D
46%D Watch how the new macros use less code:
47%D
48%D \startbuffer
49%D \startTABLE
50%D \NC Text 1 \NC Text 2 \NC\NR
51%D \NC Text 3 \NC Text 4 \NC\NR
52%D \stopTABLE
53%D \stopbuffer
54%D
55%D \typebuffer \getbuffer
56%D
57%D The actual code differs from the prototype that it does not need
58%D to collect whole rows and parse them but looks ahead instead.
59
60\newconditional\c_tabl_nte_in_nc
61
62\unexpanded\def\startTABLE
63  {\dosingleempty\tabl_nte_start}
64
65\def\tabl_nte_start[#1]%
66  {\bgroup
67   \bTABLE[#1]%
68   \let\NC\tabl_nte_start_nc
69   \let\NR\tabl_nte_start_nr
70   \let\bTR\relax
71   \let\bTD\relax
72   \let\bTH\relax
73   \let\bTN\relax}
74
75\unexpanded\def\stopTABLE
76  {\eTABLE
77   \egroup}
78
79\unexpanded\def\tabl_nte_start_nr
80  {\eTR
81   \setfalse\c_tabl_nte_in_nc}
82
83\unexpanded\def\tabl_nte_start_nc
84  {\futurelet\nexttoken\tabl_nte_start_nc_indeed}
85
86\def\tabl_nte_start_nc_indeed
87  {\ifx\nexttoken\tabl_nte_start_nr \else
88     \expandafter\tabl_nte_start_nc_finish
89   \fi}
90
91\def\tabl_nte_start_nc_finish#1\NC
92  {\ifconditional\c_tabl_nte_in_nc \else
93     \settrue\c_tabl_nte_in_nc
94     \dobTR[]%
95   \fi
96   \dobTD#1\eTD\NC}
97
98%D The related structure commands are also available:
99
100\unexpanded\def\startTABLEhead{\dosingleempty\tabl_nte_start_head} \let\stopTABLEhead\relax
101\unexpanded\def\startTABLEnext{\dosingleempty\tabl_nte_start_next} \let\stopTABLEnext\relax
102\unexpanded\def\startTABLEbody{\dosingleempty\tabl_nte_start_body} \let\stopTABLEbody\relax
103\unexpanded\def\startTABLEfoot{\dosingleempty\tabl_nte_start_foot} \let\stopTABLEfoot\relax
104
105\def\tabl_nte_start_head[#1]#2\stopTABLEhead{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_head}
106\def\tabl_nte_start_next[#1]#2\stopTABLEnext{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_next}
107\def\tabl_nte_start_body[#1]#2\stopTABLEbody{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_body}
108\def\tabl_nte_start_foot[#1]#2\stopTABLEfoot{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_foot}
109
110\protect \endinput
111