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\ifdefined\compoundhyphen \else
135
136
137
138
139 \permanent\protected\def\compoundhyphen{\hbox{\kern.10775\emwidth}}
140
141\fi
142
143
144
145
146
147
148\ifdefined\prewordbreak \else \permanent\protected\def\prewordbreak {\penalty\plustenthousand\hskip\zeroskip\relax} \fi
149\ifdefined\postwordbreak\else \permanent\protected\def\postwordbreak {\penalty\zerocount \hskip\zeroskip\relax} \fi
150\ifdefined\hspaceamount \else \def\hspaceamount#1#2{.16667\emwidth} \fi
151
152\permanent\protected\def\permithyphenation{\ifhmode\wordboundary\fi}
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173\installcorenamespace{discretionaryaction}
174\installcorenamespace{discretionarymode}
175
176\aliased\let\installdiscretionaries\gobbletwoarguments
177\aliased\let\installdiscretionary \gobbletwoarguments
178
179\setnewconstant\discretionarymode\plusone
180
181\permanent\protected\def\ignorediscretionaries{\discretionarymode\zerocount}
182\permanent\protected\def\obeydiscretionaries {\discretionarymode\plusone}
183
184\def\lang_discretionaries_command
185 {\begincsname\??discretionarymode
186 \ifcase\discretionarymode
187 n
188 \else
189 t
190 \fi
191 \endcsname}
192
193
194
195
196\letcatcodecommand\ctxcatcodes\barasciicode\lang_discretionaries_command
197
198
199
200
201
202\newconditional\punctafterdiscretionary
203\newconditional\spaceafterdiscretionary
204
205\def\lang_discretionaries_check_before
206 {\ifvmode
207 \dontleavehmode
208 \fi
209 \ifhmode
210
211
212
213
214
215
216
217
218
219
220 \fi}
221
222\def\lang_discretionaries_check_after
223 {\punctafterdiscretionary\conditionalfalse
224 \spaceafterdiscretionary\conditionalfalse
225 \ifx\blankspace\nexttoken \spaceafterdiscretionary\conditionaltrue \orelse
226 \ifx\space \nexttoken \spaceafterdiscretionary\conditionaltrue \orelse
227 \ifx .\nexttoken \punctafterdiscretionary\conditionaltrue \orelse
228 \ifx ,\nexttoken \punctafterdiscretionary\conditionaltrue \orelse
229 \ifx :\nexttoken \punctafterdiscretionary\conditionaltrue \orelse
230 \ifx ;\nexttoken \punctafterdiscretionary\conditionaltrue \fi}
231
232\edefcsname\??discretionarymode n\endcsname
233 {\detokenize{}}
234
235\defcsname\??discretionarymode t\endcsname#1
236 {\bgroup
237 \def\next{\lang_discretionaries_handle{#1}}
238 \futurelet\nexttoken\next}
239
240\permanent\protected\def\lang_discretionaries_handle#1
241 {\edef\lang_discretionaries_token{\detokenize{#1}}
242 \lang_discretionaries_check_after
243 \ifempty\lang_discretionaries_token
244 \ifx\nexttoken
245 \ifcsname\??discretionaryaction\string\endcsname
246 \lastnamedcs
247 \orelse\ifconditional\spaceafterdiscretionary
248 \wordboundary\hbox{\letterbar}\relax
249 \orelse\ifconditional\punctafterdiscretionary
250 \wordboundary\hbox{\letterbar}\wordboundary
251 \else
252 \wordboundary\hbox{\letterbar}\wordboundary
253 \fi
254 \def\next{\afterassignment\egroup\let\next=}
255 \else
256 \lang_discretionaries_check_before
257 \ifcsname\??discretionaryaction\endcsname
258 \lastnamedcs
259 \orelse\ifconditional\spaceafterdiscretionary
260 \wordboundary\defaultdiscretionaryhyphen\relax
261 \orelse\ifconditional\punctafterdiscretionary
262 \wordboundary\defaultdiscretionaryhyphen\relax
263 \else
264 \wordboundary\defaultdiscretionaryhyphen\wordboundary
265 \fi
266 \let\next\egroup
267 \fi
268 \orelse\ifcsname\??discretionaryaction\lang_discretionaries_token\endcsname
269 \lastnamedcs
270 \let\next\egroup
271 \else
272 \lang_discretionaries_check_before
273 \ifconditional\spaceafterdiscretionary
274 \wordboundary\hbox{#1}\relax
275 \orelse\ifconditional\punctafterdiscretionary
276 \wordboundary\hbox{#1}\relax
277 \else
278 \wordboundary\discretionary{\hbox{#1}}{}{\hbox{#1}}\wordboundary
279
280 \fi
281 \let\next\egroup
282 \fi
283 \next}
284
285
286
287
288
289
290
291\permanent\protected\def\directdiscretionary
292 {\begincsname\??discretionarymode
293 \ifcase\discretionarymode
294 n
295 \else
296 d
297 \fi
298 \endcsname}
299
300\permanent\protected\def\indirectdiscretionary
301 {\begincsname\??discretionarymode
302 \ifcase\discretionarymode
303 n
304 \else
305 i
306 \fi
307 \endcsname}
308
309\protected\defcsname\??discretionarymode d\endcsname#1
310 {\ifcsname\??discretionaryaction\detokenize{#1}\endcsname
311 \expandafter\lastnamedcs
312 \else
313 \expandafter\indirectdiscretionary
314 \fi{#1}}
315
316\protected\defcsname\??discretionarymode i\endcsname#1
317 {\wordboundary\discretionary{\hbox{#1}}{}{\hbox{#1}}\wordboundary}
318
319
320\permanent\protected\def\definetextmodediscretionary #1
321 {\defcsname\??discretionaryaction\detokenize{#1}\endcsname}
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340\def\lang_discretionaries_hyphen_like#1#2
341 {\ifconditional\spaceafterdiscretionary
342 \wordboundary\hbox{#1}\relax
343 \orelse\ifconditional\punctafterdiscretionary
344 \wordboundary\hbox{#1}\relax
345 \else
346 \wordboundary#2\wordboundary
347 \fi}
348
349\definetextmodediscretionary {}
350 {\lang_discretionaries_hyphen_like\textmodehyphen\textmodehyphendiscretionary}
351
352\definetextmodediscretionary
353 {\lang_discretionaries_hyphen_like\normalhyphen\normalhyphendiscretionary}
354
355\definetextmodediscretionary
356 {\lang_discretionaries_hyphen_like\composedhyphen\composedhyphendiscretionary}
357
358\definetextmodediscretionary )
359 {\lang_discretionaries_hyphen_like{)}{\discretionary{)}{}{)}}}
360
361\definetextmodediscretionary (
362 {\ifdim\lastskip>\zeropoint
363 (\wordboundary
364 \else
365 \wordboundary\discretionary{}{(}{(}\wordboundary
366
367 \fi}
368
369\definetextmodediscretionary
370 {\wordboundary\discretionary{}{}{\thinspace}\wordboundary}
371
372
373\definetextmodediscretionary
374 {\wordboundary\discretionary{}{}{}\wordboundary}
375
376
377\definetextmodediscretionary
378 {\wordboundary
379 \discretionary{\hbox{\normalstartimath\normalstopimath}}{}{\hbox{\normalstartimath\normalstopimath}}
380 \wordboundary}
381
382
383\definetextmodediscretionary <
384 {\beginofsubsentence\wordboundary\beginofsubsentencespacing
385 \aftergroup\ignorespaces}
386
387\definetextmodediscretionary >
388 {\removeunwantedspaces
389 \endofsubsentencespacing\wordboundary\endofsubsentence}
390
391\definetextmodediscretionary =
392 {\removeunwantedspaces
393 \wordboundary\midsentence\wordboundary
394 \aftergroup\ignorespaces}
395
396
397
398\definetextmodediscretionary : {\removeunwantedspaces\wordboundary\kern\hspaceamount\empty{:}:}
399\definetextmodediscretionary ; {\removeunwantedspaces\wordboundary\kern\hspaceamount\empty{;};}
400\definetextmodediscretionary ? {\removeunwantedspaces\wordboundary\kern\hspaceamount\empty{?}?}
401\definetextmodediscretionary ! {\removeunwantedspaces\wordboundary\kern\hspaceamount\empty{!}!}
402
403\definetextmodediscretionary * {\wordboundary\discretionary{}{}{\kern.05\emwidth}\wordboundary}
404
405
406
407\definetextmodediscretionary ?? {\wordboundary\questiondown}
408\definetextmodediscretionary !! {\wordboundary\exclamdown}
409
410\permanent\protected\def\defaultdiscretionaryhyphen{\compoundhyphen}
411
412
413
414
415
416
417
418
419
420
421
422
423\permanent\protected\def\fakecompoundhyphen
424 {\enforced\permanent\protected\def\|{\mathortext\vert\lang_compounds_fake_hyphen}}
425
426\def\lang_compounds_fake_hyphen
427 {\enforced\permanent\protected\def##1
428 {\ifempty{##1}\compoundhyphen\else##1\fi
429 \wordboundary
430 \allowbreak}}
431
432
433
434
435
436
437
438
439
440\permanent\protected\def\midworddiscretionary
441 {\futurelet\nexttoken\lang_discretionaries_mid_word}
442
443\def\lang_discretionaries_mid_word
444 {\ifx\nexttoken\blankspace\orelse
445 \ifx\nexttoken\bgroup \orelse
446 \ifx\nexttoken\egroup \orelse
447 \discretionary{}{}{}
448 \fi}
449
450
451
452
453
454
455
456
457
458\aliased\let\disablediscretionaries \ignorediscretionaries
459
460
461
462
463
464
465
466\ifdefined\normalcompound \else \aliased\let\normalcompound= \fi
467
468
469
470
471
472
473
474
475
476
477
478\permanent\protected\gdef\compound#1{#1}
479
480\appendtoks
481 \enforced\permanent\protected\def#1{\ifx#1\empty\empty\else#1\fi}
482\to \everysimplifycommands
483
484
485
486\appendtoks
487
488 \disablediscretionaries
489\to \everycleanupfeatures
490
491
492
493
494
495
496
497
498
499\permanent\protected\def\compounddiscretionary
500 {\discretionary
501 options \plusthree
502 {\ifnum\prehyphenchar >\zerocount\char\prehyphenchar \fi}
503 {\ifnum\posthyphenchar>\zerocount\char\posthyphenchar\fi}
504 {\ifnum\posthyphenchar>\zerocount\char\posthyphenchar\fi}}
505
506
507
508\protect \endinput
509 |