@retorquere/bibtex-parser 12.1.3 → 12.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/cjs/index.js +17 -3
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/index.js +17 -3
- package/dist/esm/index.js.map +2 -2
- package/dist/types/index.d.ts +17 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/wasm/bibtex_parser.d.ts +15 -3
- package/dist/wasm/bibtex_parser.js +177 -6
- package/dist/wasm/bibtex_parser_bg.wasm +0 -0
- package/dist/wasm/bibtex_parser_bg.wasm.d.ts +8 -2
- package/dist/wasm/index.d.ts +119 -99
- package/dist/wasm/index.js +86 -109
- package/dist/wasm/snippets/rq-bibtex-parser-a708c588fcf0dba5/inline0.js +1 -0
- package/package.json +14 -10
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/* @ts-self-types="./bibtex_parser.d.ts" */
|
|
2
|
+
import * as import1 from "./snippets/rq-bibtex-parser-a708c588fcf0dba5/inline0.js"
|
|
3
|
+
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Parse a BibTeX string and return the initial typed result as a JavaScript object.
|
|
@@ -6,16 +8,28 @@
|
|
|
6
8
|
* @param {any | null} [options]
|
|
7
9
|
* @returns {any}
|
|
8
10
|
*/
|
|
9
|
-
export function
|
|
11
|
+
export function parse(input, options) {
|
|
10
12
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
11
13
|
const len0 = WASM_VECTOR_LEN;
|
|
12
|
-
const ret = wasm.
|
|
14
|
+
const ret = wasm.parse(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
|
|
13
15
|
if (ret[2]) {
|
|
14
16
|
throw takeFromExternrefTable0(ret[1]);
|
|
15
17
|
}
|
|
16
18
|
return takeFromExternrefTable0(ret[0]);
|
|
17
19
|
}
|
|
18
20
|
|
|
21
|
+
/**
|
|
22
|
+
* @param {string} input
|
|
23
|
+
* @param {any | null} [options]
|
|
24
|
+
* @returns {Promise<any>}
|
|
25
|
+
*/
|
|
26
|
+
export function parseAsync(input, options) {
|
|
27
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
28
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29
|
+
const ret = wasm.parseAsync(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
|
|
30
|
+
return ret;
|
|
31
|
+
}
|
|
32
|
+
|
|
19
33
|
/**
|
|
20
34
|
* Parse a BibTeX string and return the verbatim result as a JavaScript object.
|
|
21
35
|
* @param {string} input
|
|
@@ -32,6 +46,22 @@ export function parseVerbatim(input, options) {
|
|
|
32
46
|
return takeFromExternrefTable0(ret[0]);
|
|
33
47
|
}
|
|
34
48
|
|
|
49
|
+
/**
|
|
50
|
+
* @param {string} input
|
|
51
|
+
* @param {any | null} [options]
|
|
52
|
+
* @returns {Promise<any>}
|
|
53
|
+
*/
|
|
54
|
+
export function parseVerbatimAsync(input, options) {
|
|
55
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
56
|
+
const len0 = WASM_VECTOR_LEN;
|
|
57
|
+
const ret = wasm.parseVerbatimAsync(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
|
|
58
|
+
return ret;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function start() {
|
|
62
|
+
wasm.start();
|
|
63
|
+
}
|
|
64
|
+
|
|
35
65
|
/**
|
|
36
66
|
* Apply sentence casing with the standalone TypeScript API's defaulted option object.
|
|
37
67
|
* @param {string} input
|
|
@@ -159,6 +189,13 @@ function __wbg_get_imports() {
|
|
|
159
189
|
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
160
190
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
161
191
|
},
|
|
192
|
+
__wbg__wbg_cb_unref_dcc1a90847f04c41: function(arg0) {
|
|
193
|
+
arg0._wbg_cb_unref();
|
|
194
|
+
},
|
|
195
|
+
__wbg_call_187d372bd5fdd4aa: function() { return handleError(function (arg0, arg1, arg2) {
|
|
196
|
+
const ret = arg0.call(arg1, arg2);
|
|
197
|
+
return ret;
|
|
198
|
+
}, arguments); },
|
|
162
199
|
__wbg_call_6137034ef55c9d0f: function() { return handleError(function (arg0, arg1) {
|
|
163
200
|
const ret = arg0.call(arg1);
|
|
164
201
|
return ret;
|
|
@@ -171,6 +208,17 @@ function __wbg_get_imports() {
|
|
|
171
208
|
const ret = Object.entries(arg0);
|
|
172
209
|
return ret;
|
|
173
210
|
},
|
|
211
|
+
__wbg_error_757e9472f8410341: function(arg0, arg1) {
|
|
212
|
+
let deferred0_0;
|
|
213
|
+
let deferred0_1;
|
|
214
|
+
try {
|
|
215
|
+
deferred0_0 = arg0;
|
|
216
|
+
deferred0_1 = arg1;
|
|
217
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
218
|
+
} finally {
|
|
219
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
220
|
+
}
|
|
221
|
+
},
|
|
174
222
|
__wbg_get_658f6698067d9515: function() { return handleError(function (arg0, arg1) {
|
|
175
223
|
const ret = Reflect.get(arg0, arg1);
|
|
176
224
|
return ret;
|
|
@@ -197,6 +245,16 @@ function __wbg_get_imports() {
|
|
|
197
245
|
const ret = result;
|
|
198
246
|
return ret;
|
|
199
247
|
},
|
|
248
|
+
__wbg_instanceof_Map_b2611749102d7ba3: function(arg0) {
|
|
249
|
+
let result;
|
|
250
|
+
try {
|
|
251
|
+
result = arg0 instanceof Map;
|
|
252
|
+
} catch (_) {
|
|
253
|
+
result = false;
|
|
254
|
+
}
|
|
255
|
+
const ret = result;
|
|
256
|
+
return ret;
|
|
257
|
+
},
|
|
200
258
|
__wbg_instanceof_Uint8Array_828cef2aaacafc31: function(arg0) {
|
|
201
259
|
let result;
|
|
202
260
|
try {
|
|
@@ -231,6 +289,10 @@ function __wbg_get_imports() {
|
|
|
231
289
|
const ret = new Uint8Array(arg0);
|
|
232
290
|
return ret;
|
|
233
291
|
},
|
|
292
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
293
|
+
const ret = new Error();
|
|
294
|
+
return ret;
|
|
295
|
+
},
|
|
234
296
|
__wbg_new_28744009d011f847: function() {
|
|
235
297
|
const ret = new Map();
|
|
236
298
|
return ret;
|
|
@@ -243,6 +305,24 @@ function __wbg_get_imports() {
|
|
|
243
305
|
const ret = new Array();
|
|
244
306
|
return ret;
|
|
245
307
|
},
|
|
308
|
+
__wbg_new_typed_b01cb72a8af741a3: function(arg0, arg1) {
|
|
309
|
+
try {
|
|
310
|
+
var state0 = {a: arg0, b: arg1};
|
|
311
|
+
var cb0 = (arg0, arg1) => {
|
|
312
|
+
const a = state0.a;
|
|
313
|
+
state0.a = 0;
|
|
314
|
+
try {
|
|
315
|
+
return wasm_bindgen_d8d66d04887dc00f___convert__closures_____invoke___js_sys_a6b0604181071ff___Function_fn_wasm_bindgen_d8d66d04887dc00f___JsValue_____wasm_bindgen_d8d66d04887dc00f___sys__Undefined___js_sys_a6b0604181071ff___Function_fn_wasm_bindgen_d8d66d04887dc00f___JsValue_____wasm_bindgen_d8d66d04887dc00f___sys__Undefined_______true_(a, state0.b, arg0, arg1);
|
|
316
|
+
} finally {
|
|
317
|
+
state0.a = a;
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
const ret = new Promise(cb0);
|
|
321
|
+
return ret;
|
|
322
|
+
} finally {
|
|
323
|
+
state0.a = 0;
|
|
324
|
+
}
|
|
325
|
+
},
|
|
246
326
|
__wbg_next_33784799010f1bbe: function(arg0) {
|
|
247
327
|
const ret = arg0.next;
|
|
248
328
|
return ret;
|
|
@@ -254,6 +334,17 @@ function __wbg_get_imports() {
|
|
|
254
334
|
__wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
|
|
255
335
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
256
336
|
},
|
|
337
|
+
__wbg_queueMicrotask_9833f9a49df95a49: function(arg0) {
|
|
338
|
+
const ret = arg0.queueMicrotask;
|
|
339
|
+
return ret;
|
|
340
|
+
},
|
|
341
|
+
__wbg_queueMicrotask_a72f977e97f23c5f: function(arg0) {
|
|
342
|
+
queueMicrotask(arg0);
|
|
343
|
+
},
|
|
344
|
+
__wbg_resolve_0076e10020304ede: function(arg0) {
|
|
345
|
+
const ret = Promise.resolve(arg0);
|
|
346
|
+
return ret;
|
|
347
|
+
},
|
|
257
348
|
__wbg_set_6ae97e73113c4f0b: function(arg0, arg1, arg2) {
|
|
258
349
|
const ret = arg0.set(arg1, arg2);
|
|
259
350
|
return ret;
|
|
@@ -264,26 +355,62 @@ function __wbg_get_imports() {
|
|
|
264
355
|
__wbg_set_bea140a88be9b277: function(arg0, arg1, arg2) {
|
|
265
356
|
arg0[arg1 >>> 0] = arg2;
|
|
266
357
|
},
|
|
358
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
359
|
+
const ret = arg1.stack;
|
|
360
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
361
|
+
const len1 = WASM_VECTOR_LEN;
|
|
362
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
363
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
364
|
+
},
|
|
365
|
+
__wbg_static_accessor_GLOBAL_266715b9d96ba635: function() {
|
|
366
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
367
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
368
|
+
},
|
|
369
|
+
__wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179: function() {
|
|
370
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
371
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
372
|
+
},
|
|
373
|
+
__wbg_static_accessor_SELF_0b583911f537483a: function() {
|
|
374
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
375
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
376
|
+
},
|
|
377
|
+
__wbg_static_accessor_WINDOW_d7f903d1508cbdc4: function() {
|
|
378
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
379
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
380
|
+
},
|
|
381
|
+
__wbg_then_c949d5a25a4e78f8: function(arg0, arg1, arg2) {
|
|
382
|
+
const ret = arg0.then(arg1, arg2);
|
|
383
|
+
return ret;
|
|
384
|
+
},
|
|
385
|
+
__wbg_then_e71170d78fcf8954: function(arg0, arg1) {
|
|
386
|
+
const ret = arg0.then(arg1);
|
|
387
|
+
return ret;
|
|
388
|
+
},
|
|
267
389
|
__wbg_value_f3c585ee8f5ba40c: function(arg0) {
|
|
268
390
|
const ret = arg0.value;
|
|
269
391
|
return ret;
|
|
270
392
|
},
|
|
271
|
-
__wbindgen_generic_0000000000000001: function(arg0) {
|
|
393
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
394
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 81, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
395
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_d8d66d04887dc00f___convert__closures_____invoke___wasm_bindgen_d8d66d04887dc00f___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_d8d66d04887dc00f___JsError___true_);
|
|
396
|
+
return ret;
|
|
397
|
+
},
|
|
398
|
+
__wbindgen_generic_0000000000000002: function(arg0) {
|
|
272
399
|
// Cast intrinsic for `F64 -> Externref`.
|
|
273
400
|
const ret = arg0;
|
|
274
401
|
return ret;
|
|
275
402
|
},
|
|
276
|
-
|
|
403
|
+
__wbindgen_generic_0000000000000003: function(arg0) {
|
|
277
404
|
// Cast intrinsic for `I64 -> Externref`.
|
|
278
405
|
const ret = arg0;
|
|
279
406
|
return ret;
|
|
280
407
|
},
|
|
281
|
-
|
|
408
|
+
__wbindgen_generic_0000000000000004: function(arg0, arg1) {
|
|
282
409
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
283
410
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
284
411
|
return ret;
|
|
285
412
|
},
|
|
286
|
-
|
|
413
|
+
__wbindgen_generic_0000000000000005: function(arg0) {
|
|
287
414
|
// Cast intrinsic for `U64 -> Externref`.
|
|
288
415
|
const ret = BigInt.asUintN(64, arg0);
|
|
289
416
|
return ret;
|
|
@@ -301,15 +428,31 @@ function __wbg_get_imports() {
|
|
|
301
428
|
return {
|
|
302
429
|
__proto__: null,
|
|
303
430
|
"./bibtex_parser_bg.js": import0,
|
|
431
|
+
"./snippets/rq-bibtex-parser-a708c588fcf0dba5/inline0.js": import1,
|
|
304
432
|
};
|
|
305
433
|
}
|
|
306
434
|
|
|
435
|
+
function wasm_bindgen_d8d66d04887dc00f___convert__closures_____invoke___wasm_bindgen_d8d66d04887dc00f___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_d8d66d04887dc00f___JsError___true_(arg0, arg1, arg2) {
|
|
436
|
+
const ret = wasm.wasm_bindgen_d8d66d04887dc00f___convert__closures_____invoke___wasm_bindgen_d8d66d04887dc00f___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_d8d66d04887dc00f___JsError___true_(arg0, arg1, arg2);
|
|
437
|
+
if (ret[1]) {
|
|
438
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function wasm_bindgen_d8d66d04887dc00f___convert__closures_____invoke___js_sys_a6b0604181071ff___Function_fn_wasm_bindgen_d8d66d04887dc00f___JsValue_____wasm_bindgen_d8d66d04887dc00f___sys__Undefined___js_sys_a6b0604181071ff___Function_fn_wasm_bindgen_d8d66d04887dc00f___JsValue_____wasm_bindgen_d8d66d04887dc00f___sys__Undefined_______true_(arg0, arg1, arg2, arg3) {
|
|
443
|
+
wasm.wasm_bindgen_d8d66d04887dc00f___convert__closures_____invoke___js_sys_a6b0604181071ff___Function_fn_wasm_bindgen_d8d66d04887dc00f___JsValue_____wasm_bindgen_d8d66d04887dc00f___sys__Undefined___js_sys_a6b0604181071ff___Function_fn_wasm_bindgen_d8d66d04887dc00f___JsValue_____wasm_bindgen_d8d66d04887dc00f___sys__Undefined_______true_(arg0, arg1, arg2, arg3);
|
|
444
|
+
}
|
|
445
|
+
|
|
307
446
|
function addToExternrefTable0(obj) {
|
|
308
447
|
const idx = wasm.__externref_table_alloc();
|
|
309
448
|
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
310
449
|
return idx;
|
|
311
450
|
}
|
|
312
451
|
|
|
452
|
+
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
453
|
+
? { register: () => {}, unregister: () => {} }
|
|
454
|
+
: new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
|
|
455
|
+
|
|
313
456
|
function debugString(val) {
|
|
314
457
|
// primitive types
|
|
315
458
|
const type = typeof val;
|
|
@@ -413,6 +556,34 @@ function isLikeNone(x) {
|
|
|
413
556
|
return x === undefined || x === null;
|
|
414
557
|
}
|
|
415
558
|
|
|
559
|
+
function makeMutClosure(arg0, arg1, f) {
|
|
560
|
+
const state = { a: arg0, b: arg1, cnt: 1 };
|
|
561
|
+
const real = (...args) => {
|
|
562
|
+
|
|
563
|
+
// First up with a closure we increment the internal reference
|
|
564
|
+
// count. This ensures that the Rust closure environment won't
|
|
565
|
+
// be deallocated while we're invoking it.
|
|
566
|
+
state.cnt++;
|
|
567
|
+
const a = state.a;
|
|
568
|
+
state.a = 0;
|
|
569
|
+
try {
|
|
570
|
+
return f(a, state.b, ...args);
|
|
571
|
+
} finally {
|
|
572
|
+
state.a = a;
|
|
573
|
+
real._wbg_cb_unref();
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
real._wbg_cb_unref = () => {
|
|
577
|
+
if (--state.cnt === 0) {
|
|
578
|
+
wasm.__wbindgen_destroy_closure(state.a, state.b);
|
|
579
|
+
state.a = 0;
|
|
580
|
+
CLOSURE_DTORS.unregister(state);
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
CLOSURE_DTORS.register(real, state, state);
|
|
584
|
+
return real;
|
|
585
|
+
}
|
|
586
|
+
|
|
416
587
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
417
588
|
if (realloc === undefined) {
|
|
418
589
|
const buf = cachedTextEncoder.encode(arg);
|
|
Binary file
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const
|
|
4
|
+
export const parse: (a: number, b: number, c: number) => [number, number, number];
|
|
5
|
+
export const parseAsync: (a: number, b: number, c: number) => any;
|
|
5
6
|
export const parseVerbatim: (a: number, b: number, c: number) => [number, number, number];
|
|
7
|
+
export const parseVerbatimAsync: (a: number, b: number, c: number) => any;
|
|
8
|
+
export const start: () => void;
|
|
6
9
|
export const toSentenceCase: (a: number, b: number, c: number) => [number, number, number, number];
|
|
7
10
|
export const tokenize: (a: number, b: number) => [number, number, number];
|
|
11
|
+
export const wasm_bindgen_d8d66d04887dc00f___convert__closures_____invoke___js_sys_a6b0604181071ff___Function_fn_wasm_bindgen_d8d66d04887dc00f___JsValue_____wasm_bindgen_d8d66d04887dc00f___sys__Undefined___js_sys_a6b0604181071ff___Function_fn_wasm_bindgen_d8d66d04887dc00f___JsValue_____wasm_bindgen_d8d66d04887dc00f___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
12
|
+
export const wasm_bindgen_d8d66d04887dc00f___convert__closures_____invoke___wasm_bindgen_d8d66d04887dc00f___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_d8d66d04887dc00f___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
8
13
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
9
14
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
10
15
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
11
16
|
export const __externref_table_alloc: () => number;
|
|
12
17
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
13
|
-
export const __externref_table_dealloc: (a: number) => void;
|
|
14
18
|
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
19
|
+
export const __wbindgen_destroy_closure: (a: number, b: number) => void;
|
|
20
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
15
21
|
export const __wbindgen_start: () => void;
|
package/dist/wasm/index.d.ts
CHANGED
|
@@ -1,122 +1,142 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type { InitInput, InitOutput, SyncInitInput }
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
export type ParseMode = 'creatorlist' | 'title' | 'verbatim' | 'richtext' | 'literallist' | 'literal' | 'verbatimlist'
|
|
9
|
-
|
|
1
|
+
/** @module wasm */
|
|
2
|
+
import init, { initSync } from './bibtex_parser.js';
|
|
3
|
+
export type { InitInput, InitOutput, SyncInitInput } from './bibtex_parser.js';
|
|
4
|
+
/** Initializes the WebAssembly parser; await this before using its exports. */
|
|
5
|
+
export { init, initSync };
|
|
6
|
+
export default init;
|
|
7
|
+
/** Describes how a BibTeX field is interpreted. */
|
|
8
|
+
export type ParseMode = 'creatorlist' | 'title' | 'verbatim' | 'richtext' | 'literallist' | 'literal' | 'verbatimlist';
|
|
9
|
+
/** A parsed personal or organizational name. */
|
|
10
10
|
export interface Creator {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
name?: string;
|
|
12
|
+
lastName?: string;
|
|
13
|
+
firstName?: string;
|
|
14
|
+
prefix?: string;
|
|
15
|
+
suffix?: string;
|
|
16
|
+
initial?: string;
|
|
17
|
+
useprefix?: boolean;
|
|
18
|
+
juniorcomma?: boolean;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
export type FieldValue = string | string[] | Creator[];
|
|
21
|
+
/** A normalized BibTeX entry returned by the parser. */
|
|
23
22
|
export interface Entry {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
type: string;
|
|
24
|
+
key: string;
|
|
25
|
+
fields: Record<string, FieldValue>;
|
|
26
|
+
mode: Record<string, ParseMode>;
|
|
27
|
+
crossref?: Record<string, {
|
|
28
|
+
parent: string;
|
|
29
|
+
field: string;
|
|
30
|
+
}>;
|
|
31
|
+
input: string;
|
|
30
32
|
}
|
|
31
|
-
|
|
33
|
+
/** A parsing diagnostic. */
|
|
32
34
|
export interface ParseError {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
error: string;
|
|
36
|
+
input?: string;
|
|
35
37
|
}
|
|
36
|
-
|
|
38
|
+
/** A group in JabRef's nested group hierarchy. */
|
|
37
39
|
export interface JabRefGroup {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
name: string;
|
|
41
|
+
entries: string[];
|
|
42
|
+
groups: JabRefGroup[];
|
|
41
43
|
}
|
|
42
|
-
|
|
44
|
+
/** JabRef metadata extracted from a BibTeX library. */
|
|
43
45
|
export interface JabRefMetadata {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
root: JabRefGroup[];
|
|
47
|
+
groups: Record<string, JabRefGroup>;
|
|
48
|
+
fileDirectory?: string;
|
|
49
|
+
groupsversion?: number;
|
|
50
|
+
databaseType?: string;
|
|
49
51
|
}
|
|
50
|
-
|
|
52
|
+
/** The parsed contents of a BibTeX library. */
|
|
51
53
|
export interface Library {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
errors: ParseError[];
|
|
55
|
+
entries: Entry[];
|
|
56
|
+
comments: string[];
|
|
57
|
+
strings: Record<string, string>;
|
|
58
|
+
preambles: string[];
|
|
59
|
+
jabref: JabRefMetadata;
|
|
58
60
|
}
|
|
59
|
-
|
|
61
|
+
/** Options controlling title sentence casing. */
|
|
60
62
|
export interface SentenceCaseOptions {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
guess?: boolean;
|
|
64
|
+
subSentence?: boolean;
|
|
65
|
+
preserveQuoted?: boolean;
|
|
64
66
|
}
|
|
65
|
-
|
|
67
|
+
/** A classified text token returned by {@link tokenize}. */
|
|
66
68
|
export interface Token {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
type: 'word' | 'domain' | 'whitespace' | 'number' | 'email' | 'handle' | 'website' | 'markup' | 'other' | 'punctuation';
|
|
70
|
+
subtype: '' | 'preposition' | 'acronym' | 'contraction' | 'ordinal' | 'word' | 'end' | 'colon' | 'ellipsis';
|
|
71
|
+
text: string;
|
|
72
|
+
start: number;
|
|
73
|
+
end: number;
|
|
74
|
+
shape: string;
|
|
75
|
+
sentenceStart: boolean;
|
|
76
|
+
subSentenceStart: boolean;
|
|
77
|
+
hyphenated?: Token[];
|
|
76
78
|
}
|
|
77
|
-
|
|
78
|
-
export interface Options {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
79
|
+
/** Options for normalized BibTeX parsing. */
|
|
80
|
+
export interface Options extends ParserOptions {
|
|
81
|
+
/** Language identifiers treated as English for title casing. */
|
|
82
|
+
english?: string[];
|
|
83
|
+
/** Use the `language` field as a fallback language identifier. */
|
|
84
|
+
languageAsLangid?: boolean;
|
|
85
|
+
/** Configure sentence-casing behavior. */
|
|
86
|
+
sentenceCase?: SentenceCaseOptions;
|
|
87
|
+
/** Control preservation of capitalization inside braces. */
|
|
88
|
+
caseProtection?: 'off' | 'as-needed' | 'strict';
|
|
89
|
+
/** Policy for unsupported TeX commands and environments. */
|
|
90
|
+
unsupported?: 'ignore' | 'keep' | 'throw';
|
|
91
|
+
/** Fields parsed as verbatim text rather than TeX. */
|
|
92
|
+
verbatimFields?: (string | RegExp)[];
|
|
93
|
+
/** Fields for which a redundant outer brace pair is removed. */
|
|
94
|
+
removeOuterBraces?: string[];
|
|
95
|
+
/** Override the default parsing mode for individual fields. */
|
|
96
|
+
fieldMode?: Record<string, ParseMode>;
|
|
97
|
+
/** Return field text without LaTeX-to-Unicode conversion. */
|
|
98
|
+
raw?: boolean;
|
|
99
|
+
/** Inherit missing fields from cross-referenced entries. */
|
|
100
|
+
applyCrossRef?: boolean;
|
|
90
101
|
}
|
|
91
|
-
|
|
102
|
+
/** Options shared by the normalized and verbatim parsers. */
|
|
92
103
|
export interface ParserOptions {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
104
|
+
/** Stop after this many entries have been parsed. */
|
|
105
|
+
maxEntries?: number;
|
|
106
|
+
/** Preload string definitions as a dictionary or BibTeX source. */
|
|
107
|
+
strings?: Record<string, string> | string;
|
|
96
108
|
}
|
|
97
|
-
|
|
109
|
+
/** An entry whose field values retain their original BibTeX text. */
|
|
98
110
|
export interface VerbatimEntry {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
111
|
+
input: string;
|
|
112
|
+
type: string;
|
|
113
|
+
key: string;
|
|
114
|
+
fields: Record<string, string>;
|
|
103
115
|
}
|
|
104
|
-
|
|
116
|
+
/** The library returned by the verbatim parser. */
|
|
105
117
|
export interface VerbatimLibrary {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
118
|
+
entries: VerbatimEntry[];
|
|
119
|
+
strings: Record<string, string>;
|
|
120
|
+
comments: string[];
|
|
121
|
+
errors: ParseError[];
|
|
122
|
+
preambles: string[];
|
|
123
|
+
jabref: JabRefMetadata;
|
|
111
124
|
}
|
|
112
|
-
|
|
113
|
-
export
|
|
114
|
-
|
|
115
|
-
export function
|
|
116
|
-
|
|
117
|
-
export function
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
/** Default language identifiers treated as English. */
|
|
126
|
+
export declare const english: string[];
|
|
127
|
+
/** Parses BibTeX while leaving field contents uninterpreted. */
|
|
128
|
+
export declare function parseVerbatim(input: string, options?: ParserOptions): VerbatimLibrary;
|
|
129
|
+
/** Asynchronous variant of {@link parseVerbatim}. */
|
|
130
|
+
export declare function parseVerbatimAsync(input: string, options?: ParserOptions): Promise<VerbatimLibrary>;
|
|
131
|
+
/** Parses BibTeX or BibLaTeX source into a normalized library. */
|
|
132
|
+
export declare function parse(input: string, options?: Options): Library;
|
|
133
|
+
/** Asynchronous variant of {@link parse}, yielding during large parses. */
|
|
134
|
+
export declare function parseAsync(input: string, options?: Options): Promise<Library>;
|
|
135
|
+
/** Converts a title to sentence case using heuristic token classification. */
|
|
136
|
+
export declare function toSentenceCase(input: string, options?: {
|
|
137
|
+
preserveQuoted?: boolean;
|
|
138
|
+
subSentenceCapitalization?: boolean;
|
|
139
|
+
guess?: boolean;
|
|
140
|
+
}): string;
|
|
141
|
+
/** Splits text into classified tokens with source offsets. */
|
|
142
|
+
export declare function tokenize(input: string, markup?: RegExp): Token[];
|