1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Structure Macros Section Block Environments}
15
16\unprotect
17
18
19
20
21
22
23
24
25
26
27
28
29
30\installcorenamespace{sectionblock}
31
32\installcommandhandler \??sectionblock {sectionblock} \??sectionblock
33
34\setupsectionblock
35 [\c!number=\v!yes,
36 \c!page=\v!right]
37
38\newtoks\everybeforesectionblock
39\newtoks\everyaftersectionblock
40
41\let\strc_sectionblock_define_normal\definesectionblock
42
43\permanent\overloaded\tolerant\protected\def\definesectionblock[#1]#*[#2]#*[#S#3]
44 {\strc_sectionblock_define_normal[#1][#3]
45
46 \strc_sectionblock_set_environment{#1}\empty
47 \definemode[*#1]
48 \frozen\protected\defcsname\e!start#2\endcsname{\startsectionblock[#1]}
49 \frozen\protected\defcsname\e!stop #2\endcsname{\stopsectionblock}}
50
51\ifdefined \resetallstructuremarks \else
52 \let\resetallstructuremarks\relax
53\fi
54
55\def\strc_sectionblock_handle_page
56 {\edef\p_strc_sectionblock_page{\sectionblockparameter\c!page}
57 \ifempty\p_strc_sectionblock_page \else
58 \page[\p_strc_sectionblock_page]
59 \fi}
60
61\appendtoks
62 \strc_sectionblock_handle_page
63 \resetallstructuremarks
64 \strc_sectionblock_get_environment\currentsectionblock
65 \sectionblockparameter\c!before
66 \dostarttagged\t!division\currentsectionblock
67\to \everybeforesectionblock
68
69\appendtoks
70 \sectionblockparameter\c!after
71 \strc_sectionblock_handle_page
72 \dostoptagged
73 \resetallstructuremarks
74\to \everyaftersectionblock
75
76\permanent\tolerant\protected\def\setsectionblock[#1]#*[#S#2]
77 {\cdef\currentsectionblock{#1}
78 \setupcurrentsectionblock[#2]
79 \clf_setsectionblock{#1}
80 bookmark {\sectionblockparameter\c!bookmark}
81 \relax}
82
83\mutable\lettonothing\currentsectionblock
84
85\permanent\tolerant\protected\def\startsectionblock[#1]#*[#S#2]
86 {
87 \begingroup
88 \cdef\currentsectionblock{#1}
89 \setupcurrentsectionblock[#2]
90 \clf_pushsectionblock{#1}
91 bookmark {\sectionblockparameter\c!bookmark}
92 \relax
93
94 \setsystemmode\currentsectionblock
95 \expand\everybeforesectionblock\relax
96 \showmessage\m!structures1\currentsectionblock}
97
98\permanent\protected\def\stopsectionblock
99 {\showmessage\m!structures2\currentsectionblock
100 \expand\everyaftersectionblock\relax
101 \clf_popsectionblock
102 \endgroup}
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124\installcorenamespace{sectionblockenvironment}
125
126\protected\def\strc_sectionblock_set_environment#1#2
127 {\defcsname\??sectionblockenvironment#1\endcsname{#2}}
128
129\protected\def\strc_sectionblock_get_environment#1
130 {\csname\??sectionblockenvironment#1\endcsname}
131
132\permanent\tolerant\protected\defcsname\e!start\v!sectionblockenvironment\endcsname[#1]
133 {\grabuntil{\e!stop\v!sectionblockenvironment}{\strc_sectionblock_set_environment{#1}}}
134
135\permanent\protected\expandafter\lettonothing\csname\e!stop\v!sectionblockenvironment\endcsname
136
137\protect \endinput
138 |