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 \usesimpleliststyleandcolor
\c!textstyle\c!textcolor
387 \simplelistparameter
\c!textcommand
{
\currentsynonymmeaning
}
388 \endgroup
389\stopsetups
390
391\startsetups
[
\??simplelistrenderings
:
\v!synonym
:
\v!normal
]
392 \fastsetup
{
\??simplelistrenderings
:
:
\v!synonym
}
393\stopsetups
394
395\startsetups
[
\??simplelistrenderings
:
\v!synonym
:
\v!first
]
396 \fastsetup
{
\??simplelistrenderings
:
:
\v!synonym
}
397 \doifelsecurrentsynonymshown
\donothing
{
398 \simplelistalternativeparameter
\c!inbetween
399 \simplelistalternativeparameter
\c!left
400 \fastsetup
{
\??simplelistrenderings
:
:
\v!text
}
401 \simplelistalternativeparameter
\c!right
402 }
403\stopsetups
404
405\startsetups
[
\??simplelistrenderings
:
\v!synonym
:
\v!last
]
406 \doifelsecurrentsynonymshown
{
407 \fastsetup
{
\??simplelistrenderings
:
:
\v!synonym
}
408 }
{
409 \fastsetup
{
\??simplelistrenderings
:
:
\v!text
}
410 \simplelistalternativeparameter
\c!inbetween
411 \simplelistalternativeparameter
\c!left
412 \fastsetup
{
\??simplelistrenderings
:
:
\v!synonym
}
413 \simplelistalternativeparameter
\c!right
414 }
415\stopsetups
416
417\unexpanded
\def
\placelistofsynonyms
418 {
\dodoubleempty
\strc_synonyms_place_list
}
419
420\def
\strc_synonyms_place_list
[#
1
][#
2
]
421 {
\begingroup
422 \edef
\currentsimplelist
{
#
1
}
423 \doifelsecommandhandler
\??simplelist
\currentsimplelist
424 {
\strc_constructions_initialize
{
#
1
}
425 \setupcurrentsimplelist
[#
2
]
426 \let
\synonymentry
\strc_synonym_normal
427
428 \normalexpanded
{
\simplelistparameter
\c!before
429 \noexpand
\clf_processsynonyms
430 {
#
1
}
431 {
432 criterium
{
\simplelistparameter
\c!criterium
}
433 language
{
\simplelistparameter
\s!language
}
434 method
{
\simplelistparameter
\c!method
}
435 }
436 \relax
437 \simplelistparameter
\c!after
}
438 \relax
}
439 {}
440 \endgroup
}
441
442\def
\completelistofsynonyms
443 {
\dodoubleempty
\strc_synonyms_complete_list
}
444
445\def
\strc_synonyms_complete_list
[#
1
][#
2
]
446 {
\begingroup
447 \edef
\currentsimplelist
{
#
1
}
448 \doifelsecommandhandler
\??simplelist
\currentsimplelist
449 {
\normalexpanded
{
\startnamedsection
[
\v!chapter
][
\c!title
=
{
\headtext
{
\simplelistparameter
\s!multi
}}
,
\c!reference
=#
1
]
}
450 \strc_synonyms_place_list
[#
1
][#
2
]
451 \page
452 \stopnamedsection
}
453 {}
454 \endgroup
}
455
456\unexpanded
\def
\strc_synonym_normal
#
1
#
2
#
3
#
4
457 {
\begingroup
458 \def
\currentsimplelistentry
{
#
3
}
459 \csname
\??constructionstarthandler\v!construction
\endcsname
460 #
4
461 \csname
\??constructionstophandler\v!construction
\endcsname
462 \endgroup
}
463
464
465
466\definesimplelist
467 [
\v!sorting
]
468 [
\c!state
=
\v!start
,
469
470
471
472 \c!before
=
\startpacked
,
473 \c!after
=
\stoppacked
,
474
475 \c!method
=]
476
477\let
\setupsorting
\setupsimplelist
478
479\unexpanded
\def
\definesorting
480 {
\dotripleempty
\strc_sorting_define
}
481
482
483
484\def
\strc_sorting_define
[#
1
][#
2
][#
3
]
485 {
\edef
\currentsorting
{
#
1
}
486 \ifthirdargument
487 \doifnot
{
#
3
}
\v!none
488 {
\ifx
#
3
\relax
\else
489 \unexpanded
\def
#
3
##
1
{
\strc_sorting_insert
{
#
1
}{
##
1
}}
490 \fi
}
491 \setuvalue
{
#
1
}{
\definesort
[
\v!no
][#
1
]
}
492 \else
493 \setuvalue
{
#
1
}{
\definesort
[
\v!yes
][#
1
]
}
494 \fi
495 \setfalse
\c_strc_constructions_define_commands
496 \definesimplelist
497 [
\currentsorting
]
498 [
\v!sorting
]
499 [
\s!single
=
{
#
1
}
,
500 \s!multi
=
{
#
2
}
]
501 \settrue
\c_strc_constructions_define_commands
502
503 \presetheadtext
[#
2
=
\Word
{
#
2
}
]
504
505 \setvalue
{
\e!setup
#
2
\e!endsetup
}{
\setupsorting
[#
1
]
}
506 \setvalue
{
\e!place
\e!listof
#
2
}{
\placelistofsorts
[#
1
]
}
507 \setvalue
{
\e!complete\e!listof
#
2
}{
\completelistofsorts
[#
1
]
}}
508
509\unexpanded
\def
\definesort
510 {
\dotripleempty
\strc_sorting_define_entry
}
511
512\def
\strc_sorting_define_entry
[#
1
][#
2
][#
3
]#
4
513 {
\begingroup
514 \edef
\currentsorting
{
#
2
}
515 \edef
\currentsortingtag
{
#
3
}
516 \let
\currentsimplelist
\currentsimplelist
517 \ifx
\currentsortingtag
\empty
518 \edef
\currentsortingtag
{
#
4
}
519 \fi
520 \ifx
\currentsortingtag
\empty
521
522 \else
523 \edef
\currentsortingexpansion
{
\simplelistparameter
\c!expansion
}
524 \preprocessexpansion
\currentsortingexpansion
\currentsortingtext
\currentsortingcoding
{
#
4
}
525 \clf_registersynonym
526 {
\currentsorting
}
527 {
sorting
}
528 {
529 metadata
{
530 catcodes
\catcodetable
531 coding
{
\currentsortingcoding
}
532 \ifx
\currentsortingcoding
\s!xml
533 xmlroot
{
\xmldocument
}
534 \fi
535 }
536 definition
{
537 tag
{
\currentsortingtag
}
538 synonym
{
\currentsortingtext
}
539
540 }
541 }
542 \relax
543 \doif
{
#
1
}
\v!yes
{
\setuxvalue
\currentsortingtag
{
\strc_sorting_insert
{
\currentsorting
}{
\currentsortingtag
}}}
544 \fi
545 \endgroup
}
546
547\unexpanded
\def
\currentsortingname
{
\clf_synonymname
{
\currentsimplelist
}{
\currentsortingtag
}}
548\unexpanded
\def
\doifelsecurrentsortingused
{
\clf_doifelsesynonymused
{
\currentsimplelist
}{
\currentsortingtag
}}
549\unexpanded
\def
\resetusedsortings
[#
1
]
{
\clf_resetusedsynonyms
{
#
1
}}
550
551\setupsimplelist
552 [
\v!sorting
]
553 [
\c!alternative
=
\v!normal
]
554
555\unexpanded
\def
\strc_sorting_insert
#
1
#
2
556 {
\dontleavehmode
557 \begingroup
558
559 \edef
\currentsorting
{
#
1
}
560 \def
\currentsortingtag
{
#
2
}
561 \let
\currentsimplelist
\currentsorting
562 \edef
\currentsimplelistalternative
{
\simplelistparameter
\c!alternative
}
563 \doifnotcommandhandler
\??simplelistalternative
\currentsimplelistalternative
564 {
\let
\currentsimplelistalternative
\v!normal
}
565 \fastsetup
{
\??simplelistrenderings
:
\v!sorting
:
\currentsimplelistalternative
}
566 \normalexpanded
{
\endgroup
\simplelistparameter
\c!next
}}
567
568
569
570
571
572
573
574\startsetups
[
\??simplelistrenderings
:
\v!sorting
:
\v!normal
]
575 \fastsetup
{
\??simplelistrenderings
:
:
\v!sorting
}
576\stopsetups
577
578\startsetups
[
\??simplelistrenderings
:
:
\v!sorting
]
579 \begingroup
580 \dostarttaggedchained
\t!sorting
\currentsorting
\??simplelist
581 \dotagsorting
582 \usesimpleliststyleandcolor
\c!style\c!color
583 \currentsortingname
584 \dostoptagged
585 \endgroup
586\stopsetups
587
588\unexpanded
\def
\registersort
589 {
\dodoubleargument
\strc_sorting_register
}
590
591\def
\strc_sorting_register
[#
1
][#
2
]
592 {
\clf_registerusedsynonym
{
#
1
}{
#
2
}}
593
594
595
596
597
598\unexpanded
\def
\placelistofsorts
599 {
\dodoubleempty
\strc_sorting_place_list
}
600
601
602\def
\strc_sorting_place_list
[#
1
][#
2
]
603 {
\begingroup
604 \edef
\currentsimplelist
{
#
1
}
605 \strc_constructions_initialize
{
#
1
}
606 \setupcurrentsimplelist
[#
2
]
607 \edef
\p_simplelist_command
{
\simplelistparameter
\c!command
}
608 \ifx
\p_simplelist_command
\empty
609 \let
\synonymentry
\strc_sorting_normal
610 \else
611 \let
\synonymentry
\strc_sorting_command
612 \fi
613
614 \normalexpanded
{
\simplelistparameter
\c!before
615 \noexpand
\clf_processsynonyms
616 {
#
1
}
617 {
618 criterium
{
\simplelistparameter
\c!criterium
}
619 language
{
\simplelistparameter
\s!language
}
620 method
{
\simplelistparameter
\c!method
}
621 }
622 \relax
623 \simplelistparameter
\c!after
}
624 \endgroup
}
625
626\unexpanded
\def
\completelistofsorts
627 {
\dodoubleempty
\strc_sorting_complete_list
}
628
629\def
\strc_sorting_complete_list
[#
1
][#
2
]
630 {
\begingroup
631 \edef
\currentsimplelist
{
#
1
}
632 \normalexpanded
{
\startnamedsection
[
\v!chapter
][
\c!title
=
{
\headtext
{
\simplelistparameter
\s!multi
}}
,
\c!reference
=#
1
]
}
633 \strc_sorting_place_list
[#
1
][#
2
]
634 \page
635 \stopnamedsection
636 \endgroup
}
637
638\def
\strc_sorting_command
#
1
#
2
#
3
#
4
639 {
\p_simplelist_command
{
#
1
}{
#
2
}{
#
3
}}
640
641\def
\strc_sorting_normal
#
1
#
2
#
3
#
4
642 {
\begingroup
643 \usesimpleliststyleandcolor
\c!style\c!color
644 #
3
645 \endgroup
646 \par
}
647
648
649
650
651
652
653
654
655
656
657
658
659\definesynonyms
660 [
\v!abbreviation
]
661 [
\v!abbreviations
]
662 [
\infull
]
663
664\setupsynonyms
665 [
\v!abbreviation
]
666 [
\c!textstyle
=
\v!capital
]
667
668\definesorting
669 [
\v!logo
]
670 [
\v!logos
]
671
672
673\protect
\endinput
674