@retorquere/bibtex-parser 8.0.0 → 8.0.2
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/index.d.ts +1 -1
- package/index.js +35 -4
- package/package.json +4 -4
- package/unabbrev.json +16 -160
- package/verbatim.d.ts +75 -0
- package/verbatim.js +432 -0
package/index.d.ts
CHANGED
|
@@ -169,7 +169,7 @@ export declare const FieldMode: {
|
|
|
169
169
|
literallist: string[];
|
|
170
170
|
};
|
|
171
171
|
type ParseMode = keyof typeof FieldMode | 'literal';
|
|
172
|
-
type unsupportedHandler = (node: Node, tex
|
|
172
|
+
type unsupportedHandler = (node: Node, tex: string, entry: Entry) => string;
|
|
173
173
|
export declare function parse(input: string, options?: Options): Bibliography;
|
|
174
174
|
export declare function parseAsync(input: string, options?: Options): Promise<Bibliography>;
|
|
175
175
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -182,6 +182,7 @@ const FieldAction = {
|
|
|
182
182
|
],
|
|
183
183
|
};
|
|
184
184
|
const narguments = {
|
|
185
|
+
advance: 1,
|
|
185
186
|
ElsevierGlyph: 1,
|
|
186
187
|
bar: 1,
|
|
187
188
|
bibcyr: 1,
|
|
@@ -194,8 +195,11 @@ const narguments = {
|
|
|
194
195
|
emph: 1,
|
|
195
196
|
enquote: 1,
|
|
196
197
|
frac: 2,
|
|
198
|
+
hbox: 1,
|
|
197
199
|
href: 2,
|
|
200
|
+
hskip: 1,
|
|
198
201
|
hspace: 1,
|
|
202
|
+
ht: 1,
|
|
199
203
|
mathrm: 1,
|
|
200
204
|
mbox: 1,
|
|
201
205
|
mkbibbold: 1,
|
|
@@ -205,6 +209,9 @@ const narguments = {
|
|
|
205
209
|
newcommand: 2,
|
|
206
210
|
noopsort: 1,
|
|
207
211
|
ocirc: 1,
|
|
212
|
+
overline: 1,
|
|
213
|
+
ProvideTextCommandDefault: 2,
|
|
214
|
+
rlap: 1,
|
|
208
215
|
sb: 1,
|
|
209
216
|
section: 1,
|
|
210
217
|
sp: 1,
|
|
@@ -225,7 +232,7 @@ const narguments = {
|
|
|
225
232
|
url: 1,
|
|
226
233
|
vphantom: 1,
|
|
227
234
|
vspace: 1,
|
|
228
|
-
|
|
235
|
+
wd: 1,
|
|
229
236
|
// math
|
|
230
237
|
'math\t_': 1,
|
|
231
238
|
'math\t^': 1,
|
|
@@ -409,11 +416,14 @@ class BibTeXParser {
|
|
|
409
416
|
return (_a = this.fallback(node, (0, unified_latex_util_print_raw_1.printRaw)(node), this.current)) !== null && _a !== void 0 ? _a : '';
|
|
410
417
|
switch (node.type) {
|
|
411
418
|
case 'macro':
|
|
412
|
-
|
|
419
|
+
this.bib.errors.push({ error: `unhandled ${node.type} ${node.content} (${(0, unified_latex_util_print_raw_1.printRaw)(node)})`, input: (0, unified_latex_util_print_raw_1.printRaw)(node) });
|
|
420
|
+
break;
|
|
413
421
|
case 'environment':
|
|
414
|
-
|
|
422
|
+
this.bib.errors.push({ error: `unhandled ${node.type} ${node.env} (${(0, unified_latex_util_print_raw_1.printRaw)(node)})`, input: (0, unified_latex_util_print_raw_1.printRaw)(node) });
|
|
423
|
+
break;
|
|
415
424
|
default:
|
|
416
|
-
|
|
425
|
+
this.bib.errors.push({ error: `unhandled ${node.type} (${(0, unified_latex_util_print_raw_1.printRaw)(node)})`, input: (0, unified_latex_util_print_raw_1.printRaw)(node) });
|
|
426
|
+
break;
|
|
417
427
|
}
|
|
418
428
|
}
|
|
419
429
|
wrap(text, tag, wrap = true) {
|
|
@@ -463,15 +473,33 @@ class BibTeXParser {
|
|
|
463
473
|
let resolved;
|
|
464
474
|
switch (node.content) {
|
|
465
475
|
case 'newcommand':
|
|
476
|
+
case 'ProvideTextCommandDefault':
|
|
466
477
|
return this.registercommand(node);
|
|
478
|
+
// too complex to deal with these
|
|
479
|
+
case 'raise':
|
|
480
|
+
case 'accent':
|
|
481
|
+
case 'def':
|
|
482
|
+
case 'hss':
|
|
483
|
+
case 'ifmmode':
|
|
484
|
+
case 'makeatletter':
|
|
485
|
+
case 'makeatother':
|
|
486
|
+
case 'scriptscriptstyle':
|
|
487
|
+
case 'setbox':
|
|
488
|
+
case 'dimen':
|
|
489
|
+
case 'advance':
|
|
490
|
+
return '';
|
|
467
491
|
case 'vphantom':
|
|
468
492
|
case 'noopsort':
|
|
469
493
|
case 'left':
|
|
470
494
|
case 'right':
|
|
495
|
+
case 'ensuremath':
|
|
496
|
+
case 'wd':
|
|
497
|
+
case 'ht':
|
|
471
498
|
return '';
|
|
472
499
|
case 'path':
|
|
473
500
|
return ''; // until https://github.com/siefkenj/unified-latex/issues/94 is fixed
|
|
474
501
|
case 'hspace':
|
|
502
|
+
case 'hskip':
|
|
475
503
|
if (node.args && node.args.length) {
|
|
476
504
|
if ((0, unified_latex_util_print_raw_1.printRaw)(node.args).match(/^[{]?0[a-z]*$/))
|
|
477
505
|
return '';
|
|
@@ -481,12 +509,15 @@ class BibTeXParser {
|
|
|
481
509
|
case 'overline':
|
|
482
510
|
case 'bar':
|
|
483
511
|
return node.args.map(a => this.stringify(a, context)).join('').replace(/[a-z0-9]/ig, m => `${m}\u0305`);
|
|
512
|
+
// accents dealt with by preprocessor
|
|
484
513
|
case 'textup':
|
|
485
514
|
case 'textsc':
|
|
486
515
|
case 'textrm':
|
|
487
516
|
case 'texttt':
|
|
488
517
|
case 'mathrm':
|
|
489
518
|
case 'mbox':
|
|
519
|
+
case 'hbox':
|
|
520
|
+
case 'rlap':
|
|
490
521
|
return node.args.map(n => this.stringify(n, context)).join('');
|
|
491
522
|
case 'href':
|
|
492
523
|
case 'url':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retorquere/bibtex-parser",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.2",
|
|
4
4
|
"description": "BibTeX parser",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "./index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"list": "tar tvf $(npm pack)",
|
|
19
19
|
"prepublishOnly": "npm start",
|
|
20
20
|
"abbr": "./build/abbr.py",
|
|
21
|
-
"preversion": "./console.py r && npm
|
|
21
|
+
"preversion": "./console.py r && npm run abbr && npm run test",
|
|
22
22
|
"postversion": "git push --follow-tags",
|
|
23
23
|
"update-cases": "curl -s https://raw.githubusercontent.com/retorquere/zotero-better-bibtex/master/test/loaded.json | jq -r '.[] | select(test(\"\\\\.bib((la)?tex)?$\"))' | rsync -av --delete -m --files-from=- ../better-bibtex/test/fixtures/ test/better-bibtex/",
|
|
24
24
|
"x-docs": "rm -rf docs temp && typedoc --name 'BibTeX parser' index.ts && touch docs/.nojekyll",
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
"package.json",
|
|
78
78
|
"grammar.js",
|
|
79
79
|
"grammar.d.ts",
|
|
80
|
-
"
|
|
81
|
-
"
|
|
80
|
+
"verbatim.d.ts",
|
|
81
|
+
"verbatim.js",
|
|
82
82
|
"index.d.ts",
|
|
83
83
|
"index.js",
|
|
84
84
|
"jabref.d.ts",
|