1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus
{
loading
}
{
ConTeXt
Structure
Macros
Synonyms
and
Sorting
}
15
16\registerctxluafile
{
strc
syn
}
{
}
17
18
19
20
21
22
23
24
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\unprotect
109
110
111
112\def
\preprocessexpansion
#
1
#
2
#
3
#
4
113 {
\ifx
#
1
\s!xml
114 \xmlstartraw
115 \xdef
#
2
{
#
4
}
116 \xmlstopraw
117 \glet
#
3
\s!xml
118 \else
119 \ifx
#
1
\v!yes
120 \xdef
#
2
{
#
4
}
121 \else
122 \xdef
#
2
{
\detokenize
{
#
4
}
}
123 \fi
124 \glet
#
3
\s!tex
125 \fi
}
126
127
128
129\installcorenamespace
{
simplelist
}
130
131\installcommandhandler
\??simplelist
{
simplelist
}
\??simplelist
132
133\let
\setupsimplelists
\setupsimplelist
134
135\setupsimplelists
[
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157 \c!alternative
=
\v!left
,
158 \c!display
=
\v!yes
,
159 \c!width
=
7
\emwidth
,
160 \c!distance
=
\emwidth
,
161 \c!titledistance
=
.
5
\emwidth
,
162
163
164 \c!margin
=
\v!no
,
165 \c!before
=
\startpacked
,
166 \c!inbetween
=
\blank
,
167 \c!after
=
\stoppacked
,
168
169
170
171 \c!expansion
=
\v!no
,
172
173
174 \s!language
=
\currentmainlanguage
,
175]
176
177\appendtoks
178 \setfalse
\c_strc_constructions_define_commands
179 \ifx
\currentsimplelistparent
\empty
180 \defineconstruction
[
\currentsimplelist
]
[
\s!handler
=
\v!simplelist
,
\c!level
=
1
]
181 \else
182 \defineconstruction
[
\currentsimplelist
]
[
\currentsimplelistparent
]
[
\s!handler
=
\v!simplelist
,
\c!level
=
1
]
183 \fi
184 \settrue
\c_strc_constructions_define_commands
185\to
\everydefinesimplelist
186
187\setuvalue
{
\??constructioninitializer
\v!simplelist
}
188 {
\let
\currentsimplelist
\currentconstruction
189 \let
\constructionparameter
\simplelistparameter
190 \let
\constructionnamespace
\??simplelist
191 \let
\detokenizedconstructionparameter
\detokenizedsimplelistparameter
192 \let
\letconstructionparameter
\letsimplelistparameter
193 \let
\useconstructionstyleandcolor
\usesimpleliststyleandcolor
194 \let
\setupcurrentconstruction
\setupcurrentsimplelist
}
195
196\setuvalue
{
\??constructionfinalizer
\v!simplelist
}
197 {
}
198
199\setuvalue
{
\??constructiontexthandler
\v!simplelist
}
200 {
\begingroup
201 \useconstructionstyleandcolor
\c!headstyle
\c!headcolor
202 \the
\everyconstruction
203 \constructionparameter
\c!headcommand
204 {
\strut
205 \currentsimplelistentry
}
206 \endgroup
}
207
208
209
210\ifdefined
\dotagsynonym
\else
\let
\dotagsynonym
\relax
\fi
211\ifdefined
\dotagsorting
\else
\let
\dotagsorting
\relax
\fi
212
213\definesimplelist
214 [
\v!synonym
]
215 [
\c!state
=
\v!start
,
216
217
218
219
220
221 \c!location
=
\v!left
,
222 \c!width
=
5
\emwidth
,
223 \c!distance
=
\zeropoint
,
224
225
226
227
228
229
230 \c!indentnext
=
\v!no
,
231
232 \c!method
=
]
233
234\let
\setupsynonyms
\setupsimplelist
235
236\unexpanded
\def
\definesynonyms
237 {
\doquadrupleempty
\strc_synonyms_define
}
238
239\def
\strc_synonyms_define
[
#
1
]
[
#
2
]
[
#
3
]
[
#
4
]
240 {
\edef
\currentsynonym
{
#
1
}
241 \iffourthargument
242 \unexpanded
\def
#
4
#
#
1
{
\strc_synonyms_insert
{
#
1
}
{
#
#
1
}
}
243 \ifthirdargument
244 \unexpanded
\def
#
3
#
#
1
{
\strc_synonyms_insert_meaning
{
#
1
}
{
#
#
1
}
}
245 \fi
246 \setuvalue
{
#
1
}
{
\definesynonym
[
\v!no
]
[
#
1
]
}
247 \else
248 \ifthirdargument
249 \unexpanded
\def
#
3
#
#
1
{
\strc_synonyms_insert_meaning
{
#
1
}
{
#
#
1
}
}
250 \fi
251 \setuvalue
{
#
1
}
{
\definesynonym
[
\v!yes
]
[
#
1
]
}
252 \fi
253
254
255
256 \setfalse
\c_strc_constructions_define_commands
257 \definesimplelist
258 [
\currentsynonym
]
259 [
\v!sorting
]
260 [
\s!single
=
{
#
1
}
,
261 \s!multi
=
{
#
2
}
]
262 \settrue
\c_strc_constructions_define_commands
263
264 \presetheadtext
[
#
2
=
\Word
{
#
2
}
]
265
266 \setvalue
{
\e!setup
#
2
\e!endsetup
}
{
\setupsynonyms
[
#
1
]
}
267 \setvalue
{
\e!place
\e!listof
#
2
}
{
\placelistofsynonyms
[
#
1
]
}
268 \setvalue
{
\e!complete
\e!listof
#
2
}
{
\completelistofsynonyms
[
#
1
]
}
}
269
270\unexpanded
\def
\definesynonym
271 {
\dotripleempty
\strc_synonyms_define_entry
}
272
273\def
\strc_synonyms_define_entry
[
#
1
]
[
#
2
]
[
#
3
]
#
4
#
5
274 {
\begingroup
275 \edef
\currentsynonym
{
#
2
}
276 \edef
\currentsynonymtag
{
#
3
}
277 \let
\currentsimplelist
\currentsynonym
278 \ifx
\currentsynonymtag
\empty
279 \edef
\currentsynonymtag
{
#
4
}
280 \fi
281 \ifx
\currentsynonymtag
\empty
282
283 \else
284
285 \edef
\currentsynonymexpansion
{
\simplelistparameter
\c!expansion
}
286 \preprocessexpansion
\currentsynonymexpansion
\m_synonyms_text
\currentsynonymcoding
{
#
4
}
287 \preprocessexpansion
\currentsynonymexpansion
\m_synonyms_meaning
\currentsynonymcoding
{
#
5
}
288
289 \clf_registersynonym
290 {
\currentsynonym
}
291 {
synonym
}
292 {
293 metadata
{
294 catcodes
\catcodetable
295 coding
{
\currentsynonymcoding
}
296 \ifx
\currentsynonymcoding
\s!xml
297 xmlroot
{
\xmldocument
}
298 \fi
299 }
300 definition
{
301 tag
{
\currentsynonymtag
}
302 synonym
{
\m_synonyms_text
}
303 meaning
{
\m_synonyms_meaning
}
304
305 }
306 }
307 \relax
308 \doif
{
#
1
}
\v!yes
{
\setuxvalue
\currentsynonymtag
{
\strc_synonyms_insert
{
\currentsynonym
}
{
\currentsynonymtag
}
}
}
309 \fi
310 \endgroup
}
311
312\unexpanded
\def
\registersynonym
313 {
\dodoubleargument
\strc_synonyms_register
}
314
315\def
\strc_synonyms_register
[
#
1
]
[
#
2
]
316 {
\clf_registerusedsynonym
{
#
1
}
{
#
2
}
}
317
318\unexpanded
\def
\currentsynonymname
{
\clf_synonymname
{
\currentsimplelist
}
{
\currentsynonymtag
}
}
319\unexpanded
\def
\currentsynonymmeaning
{
\clf_synonymmeaning
{
\currentsimplelist
}
{
\currentsynonymtag
}
}
320\unexpanded
\def
\doifelsecurrentsynonymused
{
\clf_doifelsesynonymused
{
\currentsimplelist
}
{
\currentsynonymtag
}
}
321\unexpanded
\def
\doifelsecurrentsynonymshown
{
\clf_doifelsesynonymshown
{
\currentsimplelist
}
{
\currentsynonymtag
}
}
322\unexpanded
\def
\resetusedsynonyms
[
#
1
]
{
\clf_resetusedsynonyms
{
#
1
}
}
323\unexpanded
\def
\resetshownsynonyms
[
#
1
]
{
\clf_resetshownsynonyms
{
#
1
}
}
324
325\let
\rawsynonymname
\clf_synonymname
326\let
\rawsynonymmeaning
\clf_synonymmeaning
327
328\installcorenamespace
{
simplelistalternative
}
329\installcorenamespace
{
simplelistrenderings
}
330
331\installcommandhandler
\??simplelistalternative
{
simplelistalternative
}
\??simplelistalternative
332
333\setupsimplelist
334 [
\v!synonym
]
335 [
\c!alternative
=
\v!normal
]
336
337\unexpanded
\def
\strc_synonyms_insert_meaning
#
1
#
2
338 {
\dontleavehmode
339 \begingroup
340 \def
\currentsimplelist
{
#
1
}
341 \def
\currentsynonymtag
{
#
2
}
342 \fastsetup
{
\??simplelistrenderings
:
:
\v!text
}
343 \endgroup
}
344
345\unexpanded
\def
\strc_synonyms_insert
#
1
#
2
346 {
\dontleavehmode
347 \begingroup
348 \edef
\currentsimplelist
{
#
1
}
349 \let
\currentsynonym
\currentsimplelist
350 \def
\currentsynonymtag
{
#
2
}
351 \edef
\currentsimplelistalternative
{
\simplelistparameter
\c!alternative
}
352 \doifnotcommandhandler
\??simplelistalternative
\currentsimplelistalternative
353 {
\let
\currentsimplelistalternative
\v!normal
}
354 \fastsetup
{
\??simplelistrenderings
:
\v!synonym
:
\currentsimplelistalternative
}
355 \normalexpanded
{
\endgroup
\simplelistparameter
\c!next
}
}
356
357
358
359
360\definesimplelistalternative
361 [
\v!normal
]
362 [
\c!inbetween
=
\space
,
363 \c!left
=
(
,
364 \c!right
=
)
]
365
366\definesimplelistalternative
367 [
\v!first
]
368 [
\v!normal
]
369
370\definesimplelistalternative
371 [
\v!last
]
372 [
\v!normal
]
373
374\startsetups
[
\??simplelistrenderings
:
:
\v!synonym
]
375 \begingroup
376 \dostarttaggedchained
\t!synonym
\currentsynonym
\??simplelist
377 \dotagsynonym
378 \usesimpleliststyleandcolor
\c!synonymstyle
\c!synonymcolor
379 \simplelistparameter
\c!synonymcommand
{
\currentsynonymname
}
380 \dostoptagged
381 \endgroup
382\stopsetups
383
384\startsetups
[
\??simplelistrenderings
:
:
\v!text
]
385 \begingroup
386 \usehyphensparameter
\simplelistparameter
387 \usesimpleliststyleandcolor
\c!textstyle
\c!textcolor
388 \simplelistparameter
\c!textcommand
{
\currentsynonymmeaning
}
389 \endgroup
390\stopsetups
391
392\startsetups
[
\??simplelistrenderings
:
\v!synonym
:
\v!normal
]
393 \fastsetup
{
\??simplelistrenderings
:
:
\v!synonym
}
394\stopsetups
395
396\startsetups
[
\??simplelistrenderings
:
\v!synonym
:
\v!first
]
397 \fastsetup
{
\??simplelistrenderings
:
:
\v!synonym
}
398 \doifelsecurrentsynonymshown
\donothing
{
399 \simplelistalternativeparameter
\c!inbetween
400 \simplelistalternativeparameter
\c!left
401 \fastsetup
{
\??simplelistrenderings
:
:
\v!text
}
402 \simplelistalternativeparameter
\c!right
403 }
404\stopsetups
405
406\startsetups
[
\??simplelistrenderings
:
\v!synonym
:
\v!last
]
407 \doifelsecurrentsynonymshown
{
408 \fastsetup
{
\??simplelistrenderings
:
:
\v!synonym
}
409 }
{
410 \fastsetup
{
\??simplelistrenderings
:
:
\v!text
}
411 \simplelistalternativeparameter
\c!inbetween
412 \simplelistalternativeparameter
\c!left
413 \fastsetup
{
\??simplelistrenderings
:
:
\v!synonym
}
414 \simplelistalternativeparameter
\c!right
415 }
416\stopsetups
417
418\unexpanded
\def
\placelistofsynonyms
419 {
\dodoubleempty
\strc_synonyms_place_list
}
420
421\def
\strc_synonyms_place_list
[
#
1
]
[
#
2
]
422 {
\begingroup
423 \edef
\currentsimplelist
{
#
1
}
424 \doifelsecommandhandler
\??simplelist
\currentsimplelist
425 {
\strc_constructions_initialize
{
#
1
}
426 \setupcurrentsimplelist
[
#
2
]
427 \let
\synonymentry
\strc_synonym_normal
428
429 \normalexpanded
{
\simplelistparameter
\c!before
430 \noexpand
\clf_processsynonyms
431 {
#
1
}
432 {
433 criterium
{
\simplelistparameter
\c!criterium
}
434 language
{
\simplelistparameter
\s!language
}
435 method
{
\simplelistparameter
\c!method
}
436 }
437 \relax
438 \simplelistparameter
\c!after
}
439 \relax
}
440 {
}
441 \endgroup
}
442
443\def
\completelistofsynonyms
444 {
\dodoubleempty
\strc_synonyms_complete_list
}
445
446\def
\strc_synonyms_complete_list
[
#
1
]
[
#
2
]
447 {
\begingroup
448 \edef
\currentsimplelist
{
#
1
}
449 \doifelsecommandhandler
\??simplelist
\currentsimplelist
450 {
\normalexpanded
{
\startnamedsection
[
\v!chapter
]
[
\c!title
=
{
\headtext
{
\simplelistparameter
\s!multi
}
}
,
\c!reference
=
#
1
]
}
451 \strc_synonyms_place_list
[
#
1
]
[
#
2
]
452 \page
453 \stopnamedsection
}
454 {
}
455 \endgroup
}
456
457\unexpanded
\def
\strc_synonym_normal
#
1
#
2
#
3
#
4
458 {
\begingroup
459 \def
\currentsimplelistentry
{
#
3
}
460 \csname
\??constructionstarthandler
\v!construction
\endcsname
461 #
4
462 \csname
\??constructionstophandler
\v!construction
\endcsname
463 \endgroup
}
464
465
466
467\definesimplelist
468 [
\v!sorting
]
469 [
\c!state
=
\v!start
,
470
471
472
473 \c!before
=
\startpacked
,
474 \c!after
=
\stoppacked
,
475
476 \c!method
=
]
477
478\let
\setupsorting
\setupsimplelist
479
480\unexpanded
\def
\definesorting
481 {
\dotripleempty
\strc_sorting_define
}
482
483
484
485\def
\strc_sorting_define
[
#
1
]
[
#
2
]
[
#
3
]
486 {
\edef
\currentsorting
{
#
1
}
487 \ifthirdargument
488 \doifnot
{
#
3
}
\v!none
489 {
\ifx
#
3
\relax
\else
490 \unexpanded
\def
#
3
#
#
1
{
\strc_sorting_insert
{
#
1
}
{
#
#
1
}
}
491 \fi
}
492 \setuvalue
{
#
1
}
{
\definesort
[
\v!no
]
[
#
1
]
}
493 \else
494 \setuvalue
{
#
1
}
{
\definesort
[
\v!yes
]
[
#
1
]
}
495 \fi
496 \setfalse
\c_strc_constructions_define_commands
497 \definesimplelist
498 [
\currentsorting
]
499 [
\v!sorting
]
500 [
\s!single
=
{
#
1
}
,
501 \s!multi
=
{
#
2
}
]
502 \settrue
\c_strc_constructions_define_commands
503
504 \presetheadtext
[
#
2
=
\Word
{
#
2
}
]
505
506 \setvalue
{
\e!setup
#
2
\e!endsetup
}
{
\setupsorting
[
#
1
]
}
507 \setvalue
{
\e!place
\e!listof
#
2
}
{
\placelistofsorts
[
#
1
]
}
508 \setvalue
{
\e!complete
\e!listof
#
2
}
{
\completelistofsorts
[
#
1
]
}
}
509
510\unexpanded
\def
\definesort
511 {
\dotripleempty
\strc_sorting_define_entry
}
512
513\def
\strc_sorting_define_entry
[
#
1
]
[
#
2
]
[
#
3
]
#
4
514 {
\begingroup
515 \edef
\currentsorting
{
#
2
}
516 \edef
\currentsortingtag
{
#
3
}
517 \let
\currentsimplelist
\currentsimplelist
518 \ifx
\currentsortingtag
\empty
519 \edef
\currentsortingtag
{
#
4
}
520 \fi
521 \ifx
\currentsortingtag
\empty
522
523 \else
524 \edef
\currentsortingexpansion
{
\simplelistparameter
\c!expansion
}
525 \preprocessexpansion
\currentsortingexpansion
\currentsortingtext
\currentsortingcoding
{
#
4
}
526 \clf_registersynonym
527 {
\currentsorting
}
528 {
sorting
}
529 {
530 metadata
{
531 catcodes
\catcodetable
532 coding
{
\currentsortingcoding
}
533 \ifx
\currentsortingcoding
\s!xml
534 xmlroot
{
\xmldocument
}
535 \fi
536 }
537 definition
{
538 tag
{
\currentsortingtag
}
539 synonym
{
\currentsortingtext
}
540
541 }
542 }
543 \relax
544 \doif
{
#
1
}
\v!yes
{
\setuxvalue
\currentsortingtag
{
\strc_sorting_insert
{
\currentsorting
}
{
\currentsortingtag
}
}
}
545 \fi
546 \endgroup
}
547
548\unexpanded
\def
\currentsortingname
{
\clf_synonymname
{
\currentsimplelist
}
{
\currentsortingtag
}
}
549\unexpanded
\def
\doifelsecurrentsortingused
{
\clf_doifelsesynonymused
{
\currentsimplelist
}
{
\currentsortingtag
}
}
550\unexpanded
\def
\resetusedsortings
[
#
1
]
{
\clf_resetusedsynonyms
{
#
1
}
}
551
552\setupsimplelist
553 [
\v!sorting
]
554 [
\c!alternative
=
\v!normal
]
555
556\unexpanded
\def
\strc_sorting_insert
#
1
#
2
557 {
\dontleavehmode
558 \begingroup
559
560 \edef
\currentsorting
{
#
1
}
561 \def
\currentsortingtag
{
#
2
}
562 \let
\currentsimplelist
\currentsorting
563 \edef
\currentsimplelistalternative
{
\simplelistparameter
\c!alternative
}
564 \doifnotcommandhandler
\??simplelistalternative
\currentsimplelistalternative
565 {
\let
\currentsimplelistalternative
\v!normal
}
566 \fastsetup
{
\??simplelistrenderings
:
\v!sorting
:
\currentsimplelistalternative
}
567 \normalexpanded
{
\endgroup
\simplelistparameter
\c!next
}
}
568
569
570
571
572
573
574
575\startsetups
[
\??simplelistrenderings
:
\v!sorting
:
\v!normal
]
576 \fastsetup
{
\??simplelistrenderings
:
:
\v!sorting
}
577\stopsetups
578
579\startsetups
[
\??simplelistrenderings
:
:
\v!sorting
]
580 \begingroup
581 \dostarttaggedchained
\t!sorting
\currentsorting
\??simplelist
582 \dotagsorting
583 \usesimpleliststyleandcolor
\c!style
\c!color
584 \currentsortingname
585 \dostoptagged
586 \endgroup
587\stopsetups
588
589\unexpanded
\def
\registersort
590 {
\dodoubleargument
\strc_sorting_register
}
591
592\def
\strc_sorting_register
[
#
1
]
[
#
2
]
593 {
\clf_registerusedsynonym
{
#
1
}
{
#
2
}
}
594
595
596
597
598
599\unexpanded
\def
\placelistofsorts
600 {
\dodoubleempty
\strc_sorting_place_list
}
601
602
603\def
\strc_sorting_place_list
[
#
1
]
[
#
2
]
604 {
\begingroup
605 \edef
\currentsimplelist
{
#
1
}
606 \strc_constructions_initialize
{
#
1
}
607 \setupcurrentsimplelist
[
#
2
]
608 \edef
\p_simplelist_command
{
\simplelistparameter
\c!command
}
609 \ifx
\p_simplelist_command
\empty
610 \let
\synonymentry
\strc_sorting_normal
611 \else
612 \let
\synonymentry
\strc_sorting_command
613 \fi
614
615 \normalexpanded
{
\simplelistparameter
\c!before
616 \noexpand
\clf_processsynonyms
617 {
#
1
}
618 {
619 criterium
{
\simplelistparameter
\c!criterium
}
620 language
{
\simplelistparameter
\s!language
}
621 method
{
\simplelistparameter
\c!method
}
622 }
623 \relax
624 \simplelistparameter
\c!after
}
625 \endgroup
}
626
627\unexpanded
\def
\completelistofsorts
628 {
\dodoubleempty
\strc_sorting_complete_list
}
629
630\def
\strc_sorting_complete_list
[
#
1
]
[
#
2
]
631 {
\begingroup
632 \edef
\currentsimplelist
{
#
1
}
633 \normalexpanded
{
\startnamedsection
[
\v!chapter
]
[
\c!title
=
{
\headtext
{
\simplelistparameter
\s!multi
}
}
,
\c!reference
=
#
1
]
}
634 \strc_sorting_place_list
[
#
1
]
[
#
2
]
635 \page
636 \stopnamedsection
637 \endgroup
}
638
639\def
\strc_sorting_command
#
1
#
2
#
3
#
4
640 {
\p_simplelist_command
{
#
1
}
{
#
2
}
{
#
3
}
}
641
642\def
\strc_sorting_normal
#
1
#
2
#
3
#
4
643 {
\begingroup
644 \usesimpleliststyleandcolor
\c!style
\c!color
645 #
3
646 \endgroup
647 \par
}
648
649
650
651
652
653
654
655
656
657
658
659
660\definesynonyms
661 [
\v!abbreviation
]
662 [
\v!abbreviations
]
663 [
\infull
]
664
665\setupsynonyms
666 [
\v!abbreviation
]
667 [
\c!hyphens
=
\v!no
,
668 \c!textstyle
=
\v!capital
]
669
670\definesorting
671 [
\v!logo
]
672 [
\v!logos
]
673
674
675\protect
\endinput
676