1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Spacing Macros Paragraphs}
15
16\unprotect
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32\def\carryoverpar#1
33 {\normalexpanded
34 {\noexpand#1
35 \hangindent\the\hangindent
36 \hangafter \the\hangafter
37 \parskip \the\parskip
38 \leftskip \the\leftskip
39 \rightskip \the\rightskip
40 \relax}}
41
42\unexpanded\def\pushparagraphproperties
43 {\edef\currentparagraphproperties{\carryoverpar\relax}
44 \pushmacro\currentparagraphproperties}
45
46\unexpanded\def\popparagraphproperties
47 {\popmacro\currentparagraphproperties
48 \currentparagraphproperties}
49
50\unexpanded\def\flushparagraphproperties
51 {\popmacro\currentparagraphproperties}
52
53
54
55\let\freezeparagraphproperties \relax
56\let\defrostparagraphproperties\relax
57\let\setparagraphfreezing \relax
58\let\forgetparagraphfreezing \relax
59\let\updateparagraphproperties \relax
60\let\updateparagraphpenalties \relax
61\let\updateparagraphdemerits \relax
62\let\updateparagraphshapes \relax
63
64\let\updateparwrapper \relax
65\let\forgetparwrapper \relax
66\let\registerparwrapper\gobblethreearguments
67\let\directparwrapper \gobbletwoarguments
68
69\let\spac_paragraph_wrap \relax
70\let\spac_paragraph_freeze\relax
71
72
73
74
75\installcorenamespace{paragraphintro}
76
77\let\insertparagraphintro\relax
78
79\newtoks\t_spac_paragraphs_intro_first
80\newtoks\t_spac_paragraphs_intro_next
81\newtoks\t_spac_paragraphs_intro_each
82
83\newconditional\c_spac_paragraphs_intro_first
84\newconditional\c_spac_paragraphs_intro_next
85\newconditional\c_spac_paragraphs_intro_each
86
87\unexpanded\def\setupparagraphintro
88 {\dodoubleempty\spac_paragraphs_intro}
89
90\unexpanded\def\spac_paragraphs_intro[#1][#2]
91 {\def\spac_paragraphs_intro_step##1
92 {\csname\??paragraphintro\ifcsname\??paragraphintro##1\endcsname##1\fi\endcsname{#2}}
93 \processcommacommand[#1]\spac_paragraphs_intro_step}
94
95\letvalue{\??paragraphintro\empty}\gobbleoneargument
96
97\setvalue{\??paragraphintro\v!reset}#1
98 {\global\setfalse\c_spac_paragraphs_intro_first
99 \global\setfalse\c_spac_paragraphs_intro_next
100 \global\setfalse\c_spac_paragraphs_intro_each
101 \global\t_spac_paragraphs_intro_first\emptytoks
102 \global\t_spac_paragraphs_intro_next \emptytoks
103 \global\t_spac_paragraphs_intro_each \emptytoks
104 \glet\insertparagraphintro\relax}
105
106\setvalue{\??paragraphintro\v!first}#1
107 {\global\settrue\c_spac_paragraphs_intro_first
108 \gtoksapp\t_spac_paragraphs_intro_first{#1}
109 \glet\insertparagraphintro\spac_paragraphs_flush_intro}
110
111\setvalue{\??paragraphintro\v!next}#1
112 {\global\settrue\c_spac_paragraphs_intro_next
113 \gtoksapp\t_spac_paragraphs_intro_next{#1}
114 \glet\insertparagraphintro\spac_paragraphs_flush_intro}
115
116\setvalue{\??paragraphintro\v!each}#1
117 {\global\settrue\c_spac_paragraphs_intro_each
118 \gtoksapp\t_spac_paragraphs_intro_each{#1}
119 \glet\insertparagraphintro\spac_paragraphs_flush_intro}
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157\unexpanded\def\flushatparagraph#1
158 {\global\c_spac_paragraphs_intro_first\plusone
159 \gtoksapp\t_spac_paragraphs_intro_first{#1}
160 \glet\insertparagraphintro\spac_paragraphs_flush_intro}
161
162
163
164
165\unexpanded\def\spac_paragraphs_flush_intro
166 {\normalexpanded{
167 \ifconditional\c_spac_paragraphs_intro_each
168 \ifconditional\c_spac_paragraphs_intro_next
169 \glet\insertparagraphintro\spac_paragraphs_flush_intro_next
170 \else
171 \glet\insertparagraphintro\spac_paragraphs_flush_intro_each
172 \fi
173 \ifconditional\c_spac_paragraphs_intro_first
174 \global\setfalse\c_spac_paragraphs_intro_first
175 \global\t_spac_paragraphs_intro_first\emptytoks
176 \the\t_spac_paragraphs_intro_first
177 \fi
178 \the\t_spac_paragraphs_intro_each
179 \else
180 \ifconditional\c_spac_paragraphs_intro_next
181 \glet\insertparagraphintro\spac_paragraphs_flush_intro_next
182 \fi
183 \ifconditional\c_spac_paragraphs_intro_first
184 \global\setfalse\c_spac_paragraphs_intro_first
185 \global\t_spac_paragraphs_intro_first\emptytoks
186 \the\t_spac_paragraphs_intro_first
187 \fi
188 \fi}}
189
190\unexpanded\def\spac_paragraphs_flush_intro_next
191 {\normalexpanded{
192 \global\setfalse\c_spac_paragraphs_intro_next
193 \global\t_spac_paragraphs_intro_next\emptytoks
194 \ifconditional\c_spac_paragraphs_intro_each
195 \glet\insertparagraphintro\spac_paragraphs_flush_intro_each
196 \the\t_spac_paragraphs_intro_next
197 \the\t_spac_paragraphs_intro_each
198 \else
199 \glet\insertparagraphintro\relax
200 \the\t_spac_paragraphs_intro_next
201 \fi}}
202
203\unexpanded\def\spac_paragraphs_flush_intro_each
204 {\the\t_spac_paragraphs_intro_each}
205
206
207
208
209
210
211
212\let\flushpostponednodedata\relax
213
214\newbox \b_spac_postponed_data
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232\newtoks\everyflushatnextpar
233
234\unexpanded\def\pushpostponednodedata
235 {\globalpushbox\b_spac_postponed_data}
236
237\unexpanded\def\poppostponednodedata
238 {\globalpopbox\b_spac_postponed_data
239 \ifvoid\b_spac_postponed_data\else
240 \glet\flushpostponednodedata\spac_postponed_data_flush
241 \fi}
242
243\unexpanded\def\flushatnextpar
244 {\begingroup
245 \the\everyflushatnextpar
246 \glet\flushpostponednodedata\spac_postponed_data_flush
247 \dowithnextboxcs\spac_postponed_data_finish\hpack}
248
249\def\spac_postponed_data_finish
250 {\global\setbox\b_spac_postponed_data\hpack
251 {\box\b_spac_postponed_data\box\nextbox}
252 \endgroup}
253
254\def\spac_postponed_data_flush
255 {
256 \ifvoid\b_spac_postponed_data\else
257 \hpack{\smashedbox\b_spac_postponed_data}
258 \fi
259 \glet\flushpostponednodedata\relax
260 }
261
262\unexpanded\def\doflushatpar
263 {\ifvmode
264 \expandafter\flushatnextpar
265 \else
266 \expandafter\firstofoneargument
267 \fi}
268
269\protect \endinput
270 |