-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfeatures.js
416 lines (409 loc) · 10.6 KB
/
features.js
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
const FOO = [{ type: 'book', id: 'a', properties: { title: 'foo' } }]
export default {
// ENTRY
'entry with lowercase type': {
input: `@book{a, title = "foo"}`,
output: FOO
},
'entry with mixed-case type': {
input: `@BoOk{a, title = "foo"}`,
output: FOO
},
'entry with uppercase type': {
input: `@BOOK{a, title = "foo"}`,
output: FOO
},
'entry with parentheses': {
input: `@book(a, title = "foo")`,
output: FOO
},
'entry with spacing': {
input: `@
book
{
a
,
title="foo"
}`,
output: FOO
},
'entry with trailing comma': {
input: `@book{a, title = "foo",}`,
output: FOO
},
// KEYS
'string key with colon': {
input: `@string{ a:a = "o" }
@string{ b:b = a:a }
@book{a, title = "f" # a:a # b:b}`,
output: FOO
},
'entry key with colon': {
input: `@book{a, a:a = "foo" }`,
output: [{ type: 'book', id: 'a', properties: { 'a:a': 'foo' } }]
},
'entry value with annotation': {
input: `@MISC{ann1,
AUTHOR = {Last1, First1 and Last2, First2 and Last3, First3},
AUTHOR+an = {1:family=student;2=corresponding}
}`,
output: {
id: 'ann1',
properties: {
author: [
{ family: 'Last1', given: 'First1' },
{ family: 'Last2', given: 'First2' },
{ family: 'Last3', given: 'First3' }
]
},
type: 'misc'
},
only: 'biblatex'
},
// LABELS
'entry label with number': {
input: `@book{a1, title = "foo"}`,
output: [{ type: 'book', id: 'a1', properties: { title: 'foo' } }]
},
'entry label with colon': {
input: `@book{b:b, title = "foo"}`,
output: [{ type: 'book', id: 'b:b', properties: { title: 'foo' } }]
},
'entry label with double quotes': {
input: `@book{"a", title = "foo"}`,
output: [{ type: 'book', id: '"a"', properties: { title: 'foo' } }]
},
// VALUES
'entry value of quoted string': {
input: `@book{a, title = "foo"}`,
output: FOO
},
'entry value of braced string': {
input: `@book{a, title = {foo}}`,
output: FOO
},
'entry value of number': {
input: `@book{a, title = 2020}`,
output: [{ type: 'book', id: 'a', properties: { title: 2020 } }],
gimmick: 'REPRESENTATION'
},
'entry value with mid-and concatenation': {
input: `@book{a, author = "foo an" # "d bar"}`,
output: [{ type: 'book', id: 'a', properties: { author: [
{ family: 'foo' },
{ family: 'bar' }
] } }],
gimmick: 'RARE'
},
'entry value with mid-command concatenation': {
input: `@book{a, title = "foo \\copy" # "right{} bar"}`,
output: [{ type: 'book', id: 'a', properties: { title: 'foo © bar' } }],
gimmick: 'RARE'
},
'entry value with sentence-casing (real title)': {
input: `@article{test, title = {Stability {Analysis} and Optimization}}`,
output: [{
id: 'test',
properties: {
title: 'Stability Analysis and optimization'
},
type: 'article'
}],
gimmick: 'REPRESENTATION'
},
'entry value with sentence-casing (artificial title)': {
input: `@article{test, title = "aa aa {aa} AA {AA} Aa {Aa}"}`,
output: [{
id: 'test',
properties: {
title: 'aa aa <span class="nocase">aa</span> aa AA aa Aa'
},
type: 'article'
}],
gimmick: 'REPRESENTATION'
},
'entry value with sentence-casing (markup)': {
input: `@article{test, title = "A \\emph{A} \\emph{{A}} {\\emph{A}} {\\emph{{A}}} {{\\emph{A}}}"}`,
output: [{
id: 'test',
properties: {
title: 'A <i>A</i> <i>A</i> <i>a</i> <i>a</i> <i>A</i>'
},
type: 'article'
}],
gimmick: 'REPRESENTATION'
},
'entry value with sentence-casing (env markup)': {
input: `@article{test, title = "A {\\em A} \\begin{em}A\\end{em} \\begin{em}{A}\\end{em} {A \\em A}"}`,
output: [{
id: 'test',
properties: {
title: 'A <i>a</i> <i>a</i> <i>A</i> A <i>A</i>'
},
type: 'article'
}],
gimmick: 'REPRESENTATION'
},
'entry value with sentence-casing and nested nocase': {
input: `@article{test, title = "Abc {Def {Ghi jkl} Mno}"}`,
output: [{
id: 'test',
properties: {
title: 'Abc <span class="nocase">Def Ghi jkl Mno</span>'
},
type: 'article'
}],
gimmick: 'REPRESENTATION'
},
'entry value with ignored nocase': {
input: `@article{test, title = "{Abc Def Ghi}"}`,
output: [{
id: 'test',
properties: {
title: 'Abc def ghi'
},
type: 'article'
}],
gimmick: 'REPRESENTATION'
},
'entry value with markup': {
input: `@article{test, title = {Stability analysis and {\\emph{optimization}}}}`,
output: [{
id: 'test',
properties: {
title: 'Stability analysis and <i>optimization</i>'
},
type: 'article'
}],
gimmick: 'REPRESENTATION'
},
'entry value with envs': {
input: `@article{test, title =
"Normal and \\em italics and \\begin{bf}bold \\em and italics\\end{bf} {\\bf and bold} and normal"
}`,
output: [{
id: 'test',
properties: {
title: 'Normal and <i>italics and <b>bold <i>and italics</i></b> <b>and bold</b> and normal</i>'
},
type: 'article'
}],
gimmick: 'REPRESENTATION'
},
'entry value with env overrides': {
input: `@article{test, title = "a{\\em a{\\bf a{\\em a}}}" }`,
output: [{
id: 'test',
properties: {
title: 'a<i>a<b>a<i>a</i></b></i>'
},
type: 'article'
}],
gimmick: 'REPRESENTATION'
},
'entry value with literal names': {
input: `@article{test, author = {Bausch and Lomb and {Bausch and Lomb}}}`,
output: [{
id: 'test',
properties: {
author: [
{ family: 'Bausch' },
{ family: 'Lomb' },
{ family: 'Bausch and Lomb' }
]
},
type: 'article'
}]
},
'entry value with truncated names': {
input: `@article{test, author = {Bausch and Lomb and others}}`,
output: [{
id: 'test',
properties: {
author: [
{ family: 'Bausch' },
{ family: 'Lomb' }
]
},
type: 'article'
}],
gimmick: 'REPRESENTATION'
},
'entry value with extended names (biblatex)': {
input: `@article{test, author = {family=Duchamp, given=Philippe, given-i={Ph}}}`,
output: [{
id: 'test',
properties: {
author: [
{ family: 'Duchamp', given: 'Philippe', 'given-i': 'Ph' }
]
},
type: 'article'
}],
only: 'biblatex'
},
'entry value with verbatim fields': {
input: `@article{test, file = {files/Zuniga:2016jt/A4FA1025_A4E7{}422A-9368-1E1F1B9B0166.pdf}}`,
output: [{
id: 'test',
properties: {
file: 'files/Zuniga:2016jt/A4FA1025_A4E7{}422A-9368-1E1F1B9B0166.pdf'
},
type: 'article'
}],
only: 'biblatex'
},
'entry value with uri fields': {
input: `@article{test, url = {https://example.com/test{thing}}}`,
output: [{
id: 'test',
properties: {
url: 'https://example.com/test%7Bthing%7D'
},
type: 'article'
}],
only: 'biblatex'
},
'entry value with pre-encoded uri fields': {
input: `@article{test, url = {https://example.com/test%7Bthing%7D}}`,
output: [{
id: 'test',
properties: {
url: 'https://example.com/test%7Bthing%7D'
},
type: 'article'
}],
only: 'biblatex'
},
'entry value with diacritics': {
input: `@article{test, publisher = {D{\\u{o}}\\"ead Poet Society}}`,
output: [{
id: 'test',
properties: {
publisher: 'Dŏëad Poet Society'
},
type: 'article'
}]
},
'entry value with escapes': {
input: `@article{test, title={a\\&b\\%c\\$d\\#e\\_f\\textasciitilde{}\\textasciicircum{}\\textbackslash{}}}`,
output: [{
id: 'test',
properties: {
title: 'a&b%c$d#e_f~^\\'
},
type: 'article'
}]
},
'entry value with sub/superscript': {
input: `@article{test, publisher = {Dead Po$_{eee}$t Society}}`,
output: [{
id: 'test',
properties: {
publisher: 'Dead Poₑₑₑt Society'
},
type: 'article'
}]
},
'entry value with multi-argument commands': {
input: `@article{test, title = {$\\frac 1 2$ and $\\frac{n}{2}$}}`,
output: [{ id: 'test', properties: { title: '½ and ⁿ⁄₂' }, type: 'article'}]
},
'entry value with verbatim-argument commands': {
input: `@article{test, title = "\\href{http://example.org/{id}}{url}"}`,
output: [{
id: 'test',
properties: {
title: '<span class="nocase">http://example.org/{id}</span>'
},
type: 'article'
}]
},
'entry value with unbracketed-argument commands': {
input: `@article{test, title = {Stability analysis and \\emph optimization}}`,
output: [{
id: 'test',
properties: {
title: 'Stability analysis and <i>o</i>ptimization'
},
type: 'article'
}],
gimmick: 'REPRESENTATION'
},
// TODO
'TODO': {
only: 'display'
},
// STRING
'string with lowercase type': {
input: `@string{ foo = "foo" }
@book{a, title = foo}`,
output: FOO
},
'string with mixed-case type': {
input: `@StRiNg{ foo = "foo" }
@book{a, title = foo}`,
output: FOO
},
'string with uppercase type': {
input: `@STRING{ foo = "foo" }
@book{a, title = foo}`,
output: FOO
},
'string with parentheses': {
input: `@string( foo = "foo" )
@book{a, title = foo}`,
output: FOO
},
'string value with string': {
input: `@string{ foo = "foo" }
@book{a, title = foo}
@book{b, title = FOO}`,
output: [FOO[0], { ...FOO[0], id: 'b' }]
},
'string value with concatenated string': {
input: `@string{ f = "f" }
@string{ o = "o" }
@string{ fo = f # o }
@book{a, title = fo # o}`,
output: FOO
},
// PREAMBLE
'preamble with quoted string': {
input: `@preamble { "test" }`,
output: []
},
'preamble with string': {
input: `@string{ include = "a" }
@preamble { include }`,
output: []
},
'preamble with concatenated string': {
input: `@string{ include = "a" }
@preamble { include # include }`,
output: []
},
// COMMENT
'comment before entry': {
input: `@comment{This is a comment}`,
output: []
},
'comment before entry': {
input: `@comment{@book{a, title = "foo"}}`,
output: []
},
'comment around entry (natbib)': {
input: `@comment{
@book{a, title = "foo"}
}`,
output: FOO,
only: 'natbib'
},
'comment around entry (biblatex)': {
input: `@comment{
@book{a, title = "foo"}
}`,
output: [],
only: 'natbib'
},
}