1
2
3
4
5
6\usemodule[presentoverlap,abr02]
7
8\startdocument
9 [title=Sorting,
10 subtitle=registers,
11 location=\ConTeXt\ Meeting 2011]
12
13\startluacode
14
15local function show(t,start,stop)
16 if type(t) == "table" then
17 start = start or 1
18 stop = stop or #t
19 for i=start,stop do
20 if i > start then
21 context.space()
22 end
23 if type(t[i]) == "number" then
24 context(utf.char(t[i]))
25 else
26 context(t[i])
27 end
28 end
29 elseif type(t) == "string" then
30 context(t)
31 elseif type(t) == "number" then
32 context(utf.char(t))
33 end
34end
35
36function context.ShowCharacterData(n)
37 local d = characters.data[n]
38 if d then
39 local bTR, bTD, eTD, eTR = context.bTR, context.bTD, context.eTD, context.eTR
40 context.bTABLE()
41 bTR() bTD() context("unicode") eTD() bTD() show(n) eTD() eTR()
42 bTR() bTD() context("shcode") eTD() bTD() show(characters.shchars [n]) eTD() eTR()
43 bTR() bTD() context("lccode") eTD() bTD() show(characters.lcchars [n]) eTD() eTR()
44 bTR() bTD() context("uccode") eTD() bTD() show(characters.ucchars [n]) eTD() eTR()
45 bTR() bTD() context("fscode") eTD() bTD() show(characters.fschars [n]) eTD() eTR()
46 bTR() bTD() context("specials") eTD() bTD() show(
47 characters.remap_hangul_syllabe(characters.specials[n]),2) eTD() eTR()
48 context.eTABLE()
49 end
50end
51
52\stopluacode
53
54\unexpanded\def\ShowCharacterData#1{\cldcommand{ShowCharacterData("#1")}}
55
56\Topic{The old way}
57
58\StartSteps
59\startitemize
60\startitem in \MKII\ sorting is delegated to \TEXUTIL\ i.e.\ a multipass action \stopitem \FlushStep
61\startitem encoding vectors are passed along \stopitem \FlushStep
62\startitem sort vectors depend on the language \stopitem \FlushStep
63\startitem there are the usual complications with direct characters and commands \stopitem \FlushStep
64\stopitemize
65\StopSteps
66
67\Topic{Moving on}
68
69\StartSteps
70\startitemize
71\startitem in \MKIV\ sorting happens during the run \stopitem \FlushStep
72\startitem we only have to deal with \UNICODE\ (utf) \stopitem \FlushStep
73\startitem sort vectors still depend on the language \stopitem \FlushStep
74\startitem sorting can be controlled by methods \stopitem \FlushStep
75\startitem there is no universal solution (conflicting user demands, mixed languages) \stopitem \FlushStep
76\stopitemize
77\StopSteps
78
79\Topic{Character data}
80
81\setupTABLE[background=color,backgroundcolor=lightgray,rulethickness=.75bp,framecolor=darkgray]
82
83\StartSteps
84\startcombination[5*1]
85 {\definedfont[Normal*none]\ShowCharacterData{a}} {regular\FlushStep}
86 {\definedfont[Normal*none]\ShowCharacterData{ä}} {accent\FlushStep}
87 {\definedfont[Normal*none]\ShowCharacterData{æ}} {ligature\FlushStep}
88 {\definedfont[adobemyungjostdmedium]\ShowCharacterData{그}} {hangul\FlushStep}
89 {\definedfont[adobemyungjostdmedium]\ShowCharacterData{학}} {hangul\FlushStep}
90\stopcombination
91\StopSteps
92
93\Topic{Sorting methods}
94
95\StartSteps
96\starttabulate[llr]
97 \NC ch \NC raw character \NC \FlushStep \NC \NR
98 \NC uc \NC unicode \NC \FlushStep \NC \NR
99 \NC mm \NC mapping \NC minus \FlushStep \NC \NR
100 \NC zm \NC \NC zero \FlushStep \NC \NR
101 \NC pm \NC \NC plus \FlushStep \NC \NR
102 \NC mc \NC lower case \NC minus \FlushStep \NC \NR
103 \NC zc \NC \NC zero \FlushStep \NC \NR
104 \NC pc \NC \NC plus \FlushStep \NC \NR
105\stoptabulate
106\StopSteps
107
108\Topic{Predefined methods}
109
110\StartSteps
111\starttabulate[ll]
112 \NC before \NC mm,mc,uc \NC \NR
113 \NC after \NC pm,mc,uc \NC \NR
114 \NC first \NC pc,mm,uc \NC \NR
115 \NC last \NC mc,mm,uc \NC \NR
116\stoptabulate
117
118\FlushStep
119
120\starttyping
121\enabletrackers[sorters.tests]
122\enabletrackers[sorters.methods]
123\stoptyping
124
125\FlushStep
126\StopSteps
127
128\Topic{An example (1)}
129
130\startbuffer
131àâá\index{àâá}
132aaa\index{aaa}
133aab\index{aab}
134Aaa\index{Aaa}
135Aab\index{Aab}
136\stopbuffer
137
138\StartSteps
139\typebuffer \FlushStep
140
141\startlines \getbuffer \stoplines \FlushStep
142\StopSteps
143
144\Topic{An example (2)}
145
146
147
148
149\setupregister[index][criterium=text,n=1,before=,after=]
150\defineframed[indexframed][align=normal,width=.2\textwidth,strut=no]
151
152\StartSteps
153\startcombination[4*1]
154 {\setupinteraction[state=stop]\indexframed{\placeregister[index][method={mm,mc,uc}]}} {mm,mc,uc\FlushStep}
155 {\setupinteraction[state=stop]\indexframed{\placeregister[index][method={pm,mc,uc}]}} {pm,mc,uc\FlushStep}
156 {\setupinteraction[state=stop]\indexframed{\placeregister[index][method={pc,mm,uc}]}} {pc,mm,uc\FlushStep}
157 {\setupinteraction[state=stop]\indexframed{\placeregister[index][method={mc,mm,uc}]}} {mc,mm,uc\FlushStep}
158\stopcombination
159\StopSteps
160
161\stopdocument
162 |