tabl-nte.mkxl /size: 3124 b    last modification: 2023-12-21 09:44
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\permanent\tolerant\protected\def\startTABLE[#S#1]%
63  {\bgroup
64   \bTABLE[#1]%
65   \enforced\let\NC\tabl_nte_start_nc
66   \enforced\let\NR\tabl_nte_start_nr
67   \enforced\let\bTR\relax
68   \enforced\let\bTD\relax
69   \enforced\let\bTH\relax
70   \enforced\let\bTN\relax}
71
72\permanent\protected\def\stopTABLE
73  {\eTABLE
74   \egroup}
75
76\permanent\protected\def\tabl_nte_start_nr
77  {\eTR
78   \c_tabl_nte_in_nc\conditionalfalse}
79
80\permanent\protected\def\tabl_nte_start_nc
81  {\futurelet\nexttoken\tabl_nte_start_nc_indeed}
82
83\def\tabl_nte_start_nc_indeed
84  {\ifx\nexttoken\tabl_nte_start_nr \else
85     \expandafter\tabl_nte_start_nc_finish
86   \fi}
87
88\def\tabl_nte_start_nc_finish#1\NC
89  {\ifconditional\c_tabl_nte_in_nc \else
90     \c_tabl_nte_in_nc\conditionaltrue
91     \tabl_ntb_bTR[]%
92   \fi
93   \tabl_ntb_bTD#1\eTD\NC}
94
95%D The related structure commands are also available:
96
97\permanent\let\stopTABLEhead\relax
98\permanent\let\stopTABLEnext\relax
99\permanent\let\stopTABLEbody\relax
100\permanent\let\stopTABLEfoot\relax
101
102\permanent\tolerant\protected\def\startTABLEhead[#S#1]#:#2\stopTABLEhead{\toksapp\t_tabl_ntb_head{\tabl_ntb_section[#1]{#2}}}
103\permanent\tolerant\protected\def\startTABLEnext[#S#1]#:#2\stopTABLEnext{\toksapp\t_tabl_ntb_next{\tabl_ntb_section[#1]{#2}}}
104\permanent\tolerant\protected\def\startTABLEbody[#S#1]#:#2\stopTABLEbody{\toksapp\t_tabl_ntb_body{\tabl_ntb_section[#1]{#2}}}
105\permanent\tolerant\protected\def\startTABLEfoot[#S#1]#:#2\stopTABLEfoot{\toksapp\t_tabl_ntb_foot{\tabl_ntb_section[#1]{#2}}}
106
107\protect \endinput
108