1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17\writestatus{loading}{ConTeXt Language Macros Compounds}
18
19
20
21
22
23
24\unprotect
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136\ifdefined\compoundhyphen \else
137 \permanent\protected\def\compoundhyphen{\hbox{\kern.10775\emwidth}}
138\fi
139
140
141
142
143
144
145\ifdefined\prewordbreak \else \permanent\protected\def\prewordbreak {\penalty\plustenthousand\hskip\zeroskip\relax} \fi
146\ifdefined\postwordbreak\else \permanent\protected\def\postwordbreak {\penalty\zerocount \hskip\zeroskip\relax} \fi
147\ifdefined\hspaceamount \else \def\hspaceamount#1#2{.16667\emwidth} \fi
148
149\permanent\protected\def\permithyphenation{\ifhmode\wordboundary\fi}
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170\installcorenamespace{discretionaryaction}
171\installcorenamespace{discretionarymode}
172
173\aliased\let\installdiscretionaries\gobbletwoarguments
174\aliased\let\installdiscretionary \gobbletwoarguments
175
176\setnewconstant\discretionarymode\plusone
177
178\permanent\protected\def\ignorediscretionaries{\discretionarymode\zerocount}
179\permanent\protected\def\obeydiscretionaries {\discretionarymode\plusone}
180
181\def\lang_discretionaries_command
182 {\begincsname\??discretionarymode
183 \ifcase\discretionarymode
184 n
185 \else
186 t
187 \fi
188 \endcsname}
189
190
191
192
193\letcatcodecommand\ctxcatcodes\barasciicode\lang_discretionaries_command
194
195
196
197
198
199\newconditional\punctafterdiscretionary
200\newconditional\spaceafterdiscretionary
201
202\def\lang_discretionaries_check_before
203 {\ifvmode
204 \dontleavehmode
205 \fi
206 \ifhmode
207
208
209
210
211
212
213
214
215
216
217 \fi}
218
219\def\lang_discretionaries_check_after
220 {\punctafterdiscretionary\conditionalfalse
221 \spaceafterdiscretionary\conditionalfalse
222 \ifx\blankspace\nexttoken \spaceafterdiscretionary\conditionaltrue \orelse
223 \ifx\space \nexttoken \spaceafterdiscretionary\conditionaltrue \orelse
224 \ifx .\nexttoken \punctafterdiscretionary\conditionaltrue \orelse
225 \ifx ,\nexttoken \punctafterdiscretionary\conditionaltrue \orelse
226 \ifx :\nexttoken \punctafterdiscretionary\conditionaltrue \orelse
227 \ifx ;\nexttoken \punctafterdiscretionary\conditionaltrue \fi}
228
229\edefcsname\??discretionarymode n\endcsname
230 {\detokenize{}}
231
232\defcsname\??discretionarymode t\endcsname#1
233 {\bgroup
234 \def\next{\lang_discretionaries_handle{#1}}
235 \futurelet\nexttoken\next}
236
237\permanent\protected\def\lang_discretionaries_handle#1
238 {\edef\lang_discretionaries_token{\detokenize{#1}}
239 \lang_discretionaries_check_after
240 \ifempty\lang_discretionaries_token
241 \ifx\nexttoken
242 \ifcsname\??discretionaryaction\string\endcsname
243 \lastnamedcs
244 \orelse\ifconditional\spaceafterdiscretionary
245 \wordboundary\hbox{\letterbar}\relax
246 \orelse\ifconditional\punctafterdiscretionary
247 \wordboundary\hbox{\letterbar}\wordboundary
248 \else
249 \wordboundary\hbox{\letterbar}\wordboundary
250 \fi
251 \def\next{\afterassignment\egroup\let\next=}
252 \else
253 \lang_discretionaries_check_before
254 \ifcsname\??discretionaryaction\endcsname
255 \lastnamedcs
256 \orelse\ifconditional\spaceafterdiscretionary
257 \wordboundary\defaultdiscretionaryhyphen\relax
258 \orelse\ifconditional\punctafterdiscretionary
259 \wordboundary\defaultdiscretionaryhyphen\relax
260 \else
261 \wordboundary\defaultdiscretionaryhyphen\wordboundary
262 \fi
263 \let\next\egroup
264 \fi
265 \orelse\ifcsname\??discretionaryaction\lang_discretionaries_token\endcsname
266 \lastnamedcs
267 \let\next\egroup
268 \else
269 \lang_discretionaries_check_before
270 \ifconditional\spaceafterdiscretionary
271 \wordboundary\hbox{#1}\relax
272 \orelse\ifconditional\punctafterdiscretionary
273 \wordboundary\hbox{#1}\relax
274 \else
275 \wordboundary\discretionary{\hbox{#1}}{}{\hbox{#1}}\wordboundary
276
277 \fi
278 \let\next\egroup
279 \fi
280 \next}
281
282
283
284
285
286
287
288\permanent\protected\def\directdiscretionary
289 {\begincsname\??discretionarymode
290 \ifcase\discretionarymode
291 n
292 \else
293 d
294 \fi
295 \endcsname}
296
297\permanent\protected\def\indirectdiscretionary
298 {\begincsname\??discretionarymode
299 \ifcase\discretionarymode
300 n
301 \else
302 i
303 \fi
304 \endcsname}
305
306\protected\defcsname\??discretionarymode d\endcsname#1
307 {\ifcsname\??discretionaryaction\detokenize{#1}\endcsname
308 \expandafter\lastnamedcs
309 \else
310 \expandafter\indirectdiscretionary
311 \fi{#1}}
312
313\protected\defcsname\??discretionarymode i\endcsname#1
314 {\wordboundary\discretionary{\hbox{#1}}{}{\hbox{#1}}\wordboundary}
315
316
317\permanent\protected\def\definetextmodediscretionary #1
318 {\defcsname\??discretionaryaction\detokenize{#1}\endcsname}
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337\def\lang_discretionaries_hyphen_like#1#2
338 {\ifconditional\spaceafterdiscretionary
339 \wordboundary\hbox{#1}\relax
340 \orelse\ifconditional\punctafterdiscretionary
341 \wordboundary\hbox{#1}\relax
342 \else
343 \wordboundary#2\wordboundary
344 \fi}
345
346\definetextmodediscretionary {}
347 {\lang_discretionaries_hyphen_like\textmodehyphen\textmodehyphendiscretionary}
348
349\definetextmodediscretionary
350 {\lang_discretionaries_hyphen_like\normalhyphen\normalhyphendiscretionary}
351
352\definetextmodediscretionary
353 {\lang_discretionaries_hyphen_like\composedhyphen\composedhyphendiscretionary}
354
355\definetextmodediscretionary )
356 {\lang_discretionaries_hyphen_like{)}{\discretionary{)}{}{)}}}
357
358\definetextmodediscretionary (
359 {\ifdim\lastskip>\zeropoint
360 (\wordboundary
361 \else
362 \wordboundary\discretionary{}{(}{(}\wordboundary
363
364 \fi}
365
366\definetextmodediscretionary
367 {\wordboundary\discretionary{}{}{\thinspace}\wordboundary}
368
369
370\definetextmodediscretionary
371 {\wordboundary\discretionary{}{}{}\wordboundary}
372
373
374\definetextmodediscretionary
375 {\wordboundary
376 \discretionary{\hbox{\normalstartimath\normalstopimath}}{}{\hbox{\normalstartimath\normalstopimath}}
377 \wordboundary}
378
379
380\definetextmodediscretionary <
381 {\beginofsubsentence\wordboundary\beginofsubsentencespacing
382 \aftergroup\ignorespaces}
383
384\definetextmodediscretionary >
385 {\removeunwantedspaces
386 \endofsubsentencespacing\wordboundary\endofsubsentence}
387
388\definetextmodediscretionary =
389 {\removeunwantedspaces
390 \wordboundary\midsentence\wordboundary
391 \aftergroup\ignorespaces}
392
393
394
395\definetextmodediscretionary : {\removeunwantedspaces\wordboundary\kern\hspaceamount\empty{:}:}
396\definetextmodediscretionary ; {\removeunwantedspaces\wordboundary\kern\hspaceamount\empty{;};}
397\definetextmodediscretionary ? {\removeunwantedspaces\wordboundary\kern\hspaceamount\empty{?}?}
398\definetextmodediscretionary ! {\removeunwantedspaces\wordboundary\kern\hspaceamount\empty{!}!}
399
400\definetextmodediscretionary * {\wordboundary\discretionary{}{}{\kern.05\emwidth}\wordboundary}
401
402
403
404\definetextmodediscretionary ?? {\wordboundary\questiondown}
405\definetextmodediscretionary !! {\wordboundary\exclamdown}
406
407\permanent\protected\def\defaultdiscretionaryhyphen{\compoundhyphen}
408
409
410
411
412
413
414
415
416
417
418
419
420\permanent\protected\def\fakecompoundhyphen
421 {\enforced\permanent\protected\def\|{\mathortext\vert\lang_compounds_fake_hyphen}}
422
423\def\lang_compounds_fake_hyphen
424 {\enforced\permanent\protected\def##1
425 {\ifempty{##1}\compoundhyphen\else##1\fi
426 \wordboundary
427 \allowbreak}}
428
429
430
431
432
433
434
435
436
437\permanent\protected\def\midworddiscretionary
438 {\futurelet\nexttoken\lang_discretionaries_mid_word}
439
440\def\lang_discretionaries_mid_word
441 {\ifx\nexttoken\blankspace\orelse
442 \ifx\nexttoken\bgroup \orelse
443 \ifx\nexttoken\egroup \orelse
444 \discretionary{}{}{}
445 \fi}
446
447
448
449
450
451
452
453
454
455\aliased\let\disablediscretionaries \ignorediscretionaries
456
457
458
459
460
461
462
463\ifdefined\normalcompound \else \aliased\let\normalcompound= \fi
464
465
466
467
468
469
470
471
472
473
474
475\permanent\protected\gdef\compound#1{#1}
476
477\appendtoks
478 \enforced\permanent\protected\def#1{\ifx#1\empty\empty\else#1\fi}
479\to \everysimplifycommands
480
481
482
483\appendtoks
484
485 \disablediscretionaries
486\to \everycleanupfeatures
487
488
489
490
491
492
493
494
495
496\permanent\protected\def\compounddiscretionary
497 {\discretionary
498 options \plusthree
499 {\ifnum\prehyphenchar >\zerocount\char\prehyphenchar \fi}
500 {\ifnum\posthyphenchar>\zerocount\char\posthyphenchar\fi}
501 {\ifnum\posthyphenchar>\zerocount\char\posthyphenchar\fi}}
502
503
504
505\protect \endinput
506 |