-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathtest.typ
More file actions
349 lines (248 loc) · 6 KB
/
test.typ
File metadata and controls
349 lines (248 loc) · 6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
#import "../../themes/default.typ": *
#show: make-glossary
#show link: set text(fill: red)
#let entry-list-0 = (
(
key: "potato",
short: "potato",
long: "long potato",
plural: "potatoes",
longplural: "long potatoes",
description: [#lorem(5)],
),
)
#let entry-list-1 = (
(
key: "potato A",
short: "potato@A",
plural: "potatoes@A",
description: [#lorem(5)],
group: "A",
),
(
key: "potato B",
short: "potato@B",
long: "long potato@B",
plural: "potatoes@B",
longplural: "long potatoes@B",
description: [#lorem(5)],
group: "B",
),
(
key: "hidden potato",
short: "hiddenpotato",
group: "show-all test",
description: [This potato does not appear, unless `print-glossary` is called
with `show-all: true`],
),
)
#let entry-list-2 = (
(
key: "potato C",
short: "potato@C",
long: "long potato@C",
plural: "potatoes@C",
longplural: "long potatoes@C",
description: [#lorem(5)],
group: "C",
),
(
key: "potato D",
short: "potato@D",
long: "long potato@D",
plural: "potatoes@D",
description: [#lorem(5)],
group: "D",
),
(
key: "potato E",
short: "potato@E",
long: "long potato@E",
longplural: "long potatoes@E",
description: [#lorem(5)],
group: "E",
),
(
key: "potato F",
short: "potato@F",
long: "long potato@F",
longplural: "long potatoes@F",
description: [This potato should not appear in the document.],
group: "F",
),
)
#let entry-list-3 = (
(
key: "potato G",
short: "potato@G",
long: "long potato@G",
longplural: "long potatoes@G",
description: [This potato should appear in the document.],
group: "G",
),
)
#let entry-list-4 = (
(
key: "potato H",
short: "potato@H",
description: [This potato only has a short key.],
),
(
key: "potato I",
long: "long potato@I",
description: [This potato only has a long key.],
),
)
#let entry-list-5 = (
(
key: "potato J",
description: [This potato has neither a short nor a long key.],
),
)
#for entries in (
entry-list-0,
entry-list-1,
entry-list-2,
entry-list-3,
entry-list-4,
) {
register-glossary(entries)
}
= Typst Compiler Version: #sys.version, #type(sys.version)
= Normalization
#set text(size: 8pt)
#columns(2)[
== entry-list-0
#entry-list-0
== entry-list-1
#entry-list-1
== entry-list-2
#entry-list-2
#colbreak()
== #repr(__normalize_entry_list) n°0
#__normalize_entry_list(entry-list-0)
== #repr(__normalize_entry_list) n°1
#__normalize_entry_list(entry-list-1)
== #repr(__normalize_entry_list) n°2
#__normalize_entry_list(entry-list-2)
]
#pagebreak()
= User API
== ref
`@potato`: @potato
`@potato:pl`: @potato:pl
== #gls
First: #gls("potato")
Display: #gls("potato", display: "potato text")
Force long: #gls("potato", first: true)
1st ref. when long is empty defaults to short: #gls("potato A")
Force long when empty defaults to short: #gls("potato A", first: true)
2nd ref.: #gls("potato A")
1st ref.: #gls("potato B")
== #glspl
First: #glspl("potato C")
Force long: #glspl("potato", first: true)
Force long when empty defaults to plural: #glspl("potato A", first: true)
2nd ref.: #glspl("potato A")
1st ref. when long is empty defaults to plural: #glspl("potato B")
1st ref. when longplural is empty: #glspl("potato D")
2nd ref. when longplural is empty: #glspl("potato D")
1st ref. when plural is empty: #glspl("potato E")
== #gls-description
#gls-description("potato B")
== #gls-key
#gls-key("potato C")
== #gls-short
#gls-short("potato D")
== #gls-plural
#gls-plural("potato A")
== #gls-longplural
#gls-longplural("potato B")
== `gls-longplural.with(link: true)`
#gls-longplural.with(link: true)("potato B")
== #gls-description
#gls-description("potato C")
== #gls-group
#gls-group("potato D")
== #count-refs
#context count-refs("potato D")
== #count-all-refs
All refs: #context count-all-refs()
Only list 4: #context count-all-refs(entry-list: entry-list-4)
== #there-are-refs
true: #context there-are-refs()
) false: #context there-are-refs(groups: (" ",))
#context if there-are-refs(entry-list: ((key: "potato A"),)) [
There are refs to potato A in the document.
] else [
There are no refs to potato A in the document.
]
== test `__attribute_is_empty` error
// #gls-long("potato A")
== test `__key_not_found` error
// #gls("potato Z")
#pagebreak()
#columns(2)[
== `#print-glossary.with(show-all: true, disable-back-references: true)`
#print-glossary(
entry-list-0,
show-all: true,
disable-back-references: true,
)
#print-glossary(
entry-list-1,
show-all: true,
disable-back-references: true,
)
#colbreak()
== #repr(print-glossary) (show-all: false)
#print-glossary(
entry-list-2,
show-all: false,
disable-back-references: false,
)
#print-glossary(
entry-list-3,
show-all: true,
disable-back-references: false,
user-group-break: colbreak,
)
== Test `#print-glossary(none)` error
// #print-glossary(none)
== Test only short/long
#print-glossary(
entry-list-4,
show-all: true,
disable-back-references: true,
)
#gls("potato I")
#glspl("potato I")
#agls("potato I")
#Gls("potato I")
#Glspl("potato I")
#Agls("potato I")
#gls("potato H")
#glspl("potato H")
#agls("potato H")
#Gls("potato H")
#Glspl("potato H")
#Agls("potato H")
== Test neither short nor long error
// #register-glossary(entry-list-5)
== `#default-print-reference.with(show-all: true)`
Forcibly print nonreference entry.
#context default-print-reference.with(show-all: true)(entry-list-2.last())
== Test use-key-as-short
#let entry-list-6 = ((key: "potato-use-key-as-short"),)
#register-glossary(entry-list-6)
#print-glossary(entry-list-6)
@potato-use-key-as-short
== capitalization
#let entry-list-7 = ((key: "LASER"), (key: "apple"))
#register-glossary(entry-list-7)
#print-glossary(entry-list-7)
@LASER
@LASER:pl
@apple
@Apple
]