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