@retorquere/bibtex-parser 9.0.21 → 9.0.22
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 +1 -1
- package/package.json +36 -18
- package/crossref.json +0 -186
- package/fields.json +0 -6938
- package/index.d.ts +0 -193
- package/index.js +0 -1191
- package/index.js.map +0 -1
- package/jabref.d.ts +0 -58
- package/jabref.js +0 -110
- package/jabref.js.map +0 -1
- package/merge.d.ts +0 -2
- package/merge.js +0 -11
- package/merge.js.map +0 -1
- package/prepositions.json +0 -88
- package/sentence-case.d.ts +0 -9
- package/sentence-case.js +0 -110
- package/sentence-case.js.map +0 -1
- package/tokenizer.d.ts +0 -13
- package/tokenizer.js +0 -167
- package/tokenizer.js.map +0 -1
- package/verbatim.d.ts +0 -66
- package/verbatim.js +0 -430
- package/verbatim.js.map +0 -1
- package/yield.d.ts +0 -2
- package/yield.js +0 -7
- package/yield.js.map +0 -1
package/tokenizer.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.tokenize = tokenize;
|
|
7
|
-
const moo_1 = __importDefault(require("moo"));
|
|
8
|
-
// const show = (obj: any): string => JSON.stringify(obj, null, 2).replace(/[\u007F-\uFFFF]/g, chr => `\\u${(`0000${chr.charCodeAt(0).toString(16)}`).substr(-4)}`)
|
|
9
|
-
const RE = new class {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.Whitespace = /[ \t\n\r\u00A0]+/u;
|
|
12
|
-
this.ComplexPreposition = /^([^ \t\n\r\u00A0]+)([ \t\n\r\u00A0]+)([^ \t\n\r\u00A0]+)(?:([ \t\n\r\u00A0]+)([^ \t\n\r\u00A0]+))?$/u;
|
|
13
|
-
this.P = /\p{P}/u;
|
|
14
|
-
const B = '(?=(?:[^\\p{L}\\p{N}\\p{M}\\u00AD\\u2060]|$))';
|
|
15
|
-
const LNM = '[\\p{L}\\p{N}\\p{M}\u00AD\u2060]';
|
|
16
|
-
const W = `${LNM}*?\\p{L}${LNM}*`;
|
|
17
|
-
this.Acronym = new RegExp(`(?:(?:(?:[\\p{Lu}\\p{Lt}][.]){2,}${B})|(?:(?:vs?[.])(?=[ \t\n\r\u00A0])))`, 'u');
|
|
18
|
-
this.Word = new RegExp(`${W}${B}`, 'u');
|
|
19
|
-
this.Contraction = new RegExp(`${W}['’]${W}${B}`, 'u');
|
|
20
|
-
this.Ordinal = new RegExp(`\\d+(?:st|nd|rd|th)${B}`, 'u');
|
|
21
|
-
this.Email = new RegExp(`[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:[.][A-Za-z0-9-]+)+${B}`, 'u');
|
|
22
|
-
this.Handle = new RegExp(`@[A-Za-z0-9-]{2,}${B}`, 'u');
|
|
23
|
-
this.IntOrVersion = new RegExp(`v?\\d+(?:\\.\\d+)*${B}`, 'u');
|
|
24
|
-
this.Domain = new RegExp(`${W}(?:[.]${W})+${B}`, 'u');
|
|
25
|
-
this.Website = new RegExp(`https?://${W}(?:[.]${W})+(?:[^.!? \t\n\r\u00A0]+|[.!?]${LNM})+`, 'u');
|
|
26
|
-
const ci = (s) => s
|
|
27
|
-
.replace(/[a-z]/ig, match => `[${match.toUpperCase()}${match.toLowerCase()}]`)
|
|
28
|
-
.replace(' ', this.Whitespace.source);
|
|
29
|
-
const prepositions = require('./prepositions.json').sort().reverse().map(ci).join('|');
|
|
30
|
-
this.Preposition = new RegExp(`(?:${prepositions})${B}`, 'u');
|
|
31
|
-
}
|
|
32
|
-
}();
|
|
33
|
-
const lexer = moo_1.default.compile({
|
|
34
|
-
'word-preposition': RE.Preposition,
|
|
35
|
-
'word-acronym': RE.Acronym,
|
|
36
|
-
'word-contraction': RE.Contraction,
|
|
37
|
-
'word-ordinal': RE.Ordinal,
|
|
38
|
-
email: RE.Email,
|
|
39
|
-
handle: RE.Handle,
|
|
40
|
-
website: RE.Website,
|
|
41
|
-
domain: RE.Domain,
|
|
42
|
-
word: RE.Word,
|
|
43
|
-
number: RE.IntOrVersion, // eslint-disable-line id-blacklist
|
|
44
|
-
'punctuation-end': /[?.!](?=[ \t\n\r\u00A0]|$)/u,
|
|
45
|
-
'punctuation-colon': /:(?=[ \t\n\r\u00A0])/u,
|
|
46
|
-
'punctuation-ellipsis': /[.][.][.]/u,
|
|
47
|
-
punctuation: RE.P,
|
|
48
|
-
whitespace: { match: /[ \t\n\r\u00A0]/u, lineBreaks: true },
|
|
49
|
-
other: { match: /[\s\S]/u, lineBreaks: true },
|
|
50
|
-
});
|
|
51
|
-
const Shape = new class {
|
|
52
|
-
constructor() {
|
|
53
|
-
this.shapes = {};
|
|
54
|
-
this.re = {
|
|
55
|
-
X: /[\p{Lu}\p{Lt}]/u,
|
|
56
|
-
x: /[\p{Ll}\p{Lm}\p{Lo}]/u,
|
|
57
|
-
d: /\p{N}/u,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
match(c) {
|
|
61
|
-
if (c.match(this.re.d))
|
|
62
|
-
return 'd';
|
|
63
|
-
if (c.toLowerCase() === c.toUpperCase())
|
|
64
|
-
return c;
|
|
65
|
-
if (c.match(this.re.X))
|
|
66
|
-
return 'X';
|
|
67
|
-
if (c.match(this.re.x))
|
|
68
|
-
return 'x';
|
|
69
|
-
if (c === '’')
|
|
70
|
-
return "'";
|
|
71
|
-
if (c === '–')
|
|
72
|
-
return '-';
|
|
73
|
-
if (c === '\u2060' || c === '\u00AD')
|
|
74
|
-
return '';
|
|
75
|
-
return c;
|
|
76
|
-
}
|
|
77
|
-
fetch(c) {
|
|
78
|
-
if (typeof this.shapes[c] === 'undefined')
|
|
79
|
-
this.shapes[c] = this.match(c);
|
|
80
|
-
return this.shapes[c];
|
|
81
|
-
}
|
|
82
|
-
shape(t) {
|
|
83
|
-
if (!this.shapes[t])
|
|
84
|
-
this.shapes[t] = Array.from(t).map(c => this.fetch(c)).join('');
|
|
85
|
-
return this.shapes[t];
|
|
86
|
-
}
|
|
87
|
-
}();
|
|
88
|
-
function combine(tokens) {
|
|
89
|
-
const combined = Object.assign({}, tokens[0]);
|
|
90
|
-
for (const t of tokens.slice(1)) {
|
|
91
|
-
combined.text += t.text;
|
|
92
|
-
combined.end = t.end;
|
|
93
|
-
combined.shape += t.shape;
|
|
94
|
-
}
|
|
95
|
-
return combined;
|
|
96
|
-
}
|
|
97
|
-
function hyphenate(t) {
|
|
98
|
-
if (t.type === 'word')
|
|
99
|
-
return 'w';
|
|
100
|
-
if (t.text === '-' || t.text === '–')
|
|
101
|
-
return '-';
|
|
102
|
-
return ' ';
|
|
103
|
-
}
|
|
104
|
-
function tokenize(title, markup) {
|
|
105
|
-
if (markup)
|
|
106
|
-
title = title.replace(markup, match => '\u2060'.repeat(match.length));
|
|
107
|
-
lexer.reset(title);
|
|
108
|
-
const tokens = [];
|
|
109
|
-
let sentenceStart = true;
|
|
110
|
-
let subSentenceStart = false;
|
|
111
|
-
for (const token of lexer) {
|
|
112
|
-
const [type, subtype] = (token.type.includes('-') ? token.type : `${token.type}-`).split('-');
|
|
113
|
-
tokens.push({
|
|
114
|
-
type,
|
|
115
|
-
subtype,
|
|
116
|
-
text: token.text,
|
|
117
|
-
start: token.offset,
|
|
118
|
-
end: token.offset + token.text.length - 1,
|
|
119
|
-
shape: Shape.shape(token.text),
|
|
120
|
-
sentenceStart: type === 'word' && sentenceStart,
|
|
121
|
-
subSentenceStart: type === 'word' && subSentenceStart,
|
|
122
|
-
});
|
|
123
|
-
switch (token.type) {
|
|
124
|
-
case 'punctuation-end':
|
|
125
|
-
sentenceStart = true;
|
|
126
|
-
break;
|
|
127
|
-
case 'punctuation-colon':
|
|
128
|
-
subSentenceStart = true;
|
|
129
|
-
break;
|
|
130
|
-
default:
|
|
131
|
-
if (type.match(/word|number|handle|domain|website/)) {
|
|
132
|
-
sentenceStart = false;
|
|
133
|
-
subSentenceStart = false;
|
|
134
|
-
}
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
const stack = tokens.splice(0);
|
|
139
|
-
let cpt;
|
|
140
|
-
let cps;
|
|
141
|
-
while (stack.length) {
|
|
142
|
-
if (stack[0].subtype === 'preposition' && (cpt = stack[0].text.match(RE.ComplexPreposition)) && (cps = stack[0].shape.match(RE.ComplexPreposition))) {
|
|
143
|
-
const complex = stack.shift();
|
|
144
|
-
let start = complex.start;
|
|
145
|
-
let end;
|
|
146
|
-
for (const i of Array.from({ length: 5 }, (_, n) => n + 1)) {
|
|
147
|
-
if (!cpt[i])
|
|
148
|
-
break;
|
|
149
|
-
end = start + cps[i].length - 1;
|
|
150
|
-
tokens.push(Object.assign(Object.assign({}, complex), { text: cpt[i], shape: cps[i], start,
|
|
151
|
-
end, type: i % 2 ? complex.type : 'whitespace', subtype: i % 2 ? complex.type : '' }));
|
|
152
|
-
start = end + 1;
|
|
153
|
-
}
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
// hyphenated words
|
|
157
|
-
const pat = stack.map(t => hyphenate(t)).join('');
|
|
158
|
-
if (cpt = pat.match(/^w(-w)+(?= |$)/)) {
|
|
159
|
-
const hyphenated = stack.splice(0, cpt[0].length);
|
|
160
|
-
tokens.push(Object.assign(Object.assign({}, combine(hyphenated)), { hyphenated }));
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
tokens.push(stack.shift());
|
|
164
|
-
}
|
|
165
|
-
return markup ? tokens.map(token => (Object.assign(Object.assign({}, token), { text: title.substring(token.start, token.end + 1) }))) : tokens;
|
|
166
|
-
}
|
|
167
|
-
//# sourceMappingURL=tokenizer.js.map
|
package/tokenizer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tokenizer.js","sourceRoot":"","sources":["tokenizer.ts"],"names":[],"mappings":";;;;;AA0HA,4BA6EC;A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CAAC,CAAA;QACjD,IAAI,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC;YACtC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;YACjD,MAAM,CAAC,IAAI,iCAAM,OAAO,CAAC,UAAU,CAAC,KAAE,UAAU,IAAG,CAAA;YACnD,SAAQ;QACV,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAA;IAC5B,CAAC;IAED,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,iCAAM,KAAK,KAAE,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,IAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;AACjH,CAAC"}
|
package/verbatim.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export type Entry = {
|
|
2
|
-
input: string;
|
|
3
|
-
type: string;
|
|
4
|
-
key: string;
|
|
5
|
-
fields: Record<string, string>;
|
|
6
|
-
};
|
|
7
|
-
export interface ParseError {
|
|
8
|
-
error: string;
|
|
9
|
-
input?: string;
|
|
10
|
-
}
|
|
11
|
-
export interface ParserOptions {
|
|
12
|
-
/**
|
|
13
|
-
* stop parsing after `max_entries` entries have been found. Useful for quick detection if a text file is in fact a bibtex file
|
|
14
|
-
*/
|
|
15
|
-
max_entries?: number;
|
|
16
|
-
/**
|
|
17
|
-
* preload these strings
|
|
18
|
-
*/
|
|
19
|
-
strings?: string | Record<string, string>;
|
|
20
|
-
}
|
|
21
|
-
export declare class Library {
|
|
22
|
-
parsing: string;
|
|
23
|
-
entries: Entry[];
|
|
24
|
-
strings: Record<string, string>;
|
|
25
|
-
comments: string[];
|
|
26
|
-
errors: ParseError[];
|
|
27
|
-
preambles: string[];
|
|
28
|
-
private default_strings;
|
|
29
|
-
private pos;
|
|
30
|
-
private linebreaks;
|
|
31
|
-
private input;
|
|
32
|
-
private max_entries;
|
|
33
|
-
constructor(input: string, options?: ParserOptions);
|
|
34
|
-
parse(): void;
|
|
35
|
-
parseAsync(): Promise<void>;
|
|
36
|
-
private isWhitespace;
|
|
37
|
-
private match;
|
|
38
|
-
private tryMatch;
|
|
39
|
-
private skipWhitespace;
|
|
40
|
-
private value_braces;
|
|
41
|
-
private value_quotes;
|
|
42
|
-
private single_value;
|
|
43
|
-
location(): string;
|
|
44
|
-
error(err: ParseError): void;
|
|
45
|
-
private value;
|
|
46
|
-
private key;
|
|
47
|
-
private key_equals_value;
|
|
48
|
-
private entry;
|
|
49
|
-
private directive;
|
|
50
|
-
private string;
|
|
51
|
-
private preamble;
|
|
52
|
-
private comment;
|
|
53
|
-
private hasMore;
|
|
54
|
-
private bibtex;
|
|
55
|
-
private bibtexAsync;
|
|
56
|
-
private matchGuard;
|
|
57
|
-
private parseNext;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Parses a bibtex source in verbatim mode. Good for detection of bibtex and for later LaTeX-reparsing.
|
|
61
|
-
*/
|
|
62
|
-
export declare function parse(input: string, options?: ParserOptions): Library;
|
|
63
|
-
export declare const promises: {
|
|
64
|
-
parse(input: string, options?: ParserOptions): Promise<Library>;
|
|
65
|
-
};
|
|
66
|
-
//# sourceMappingURL=verbatim.d.ts.map
|
package/verbatim.js
DELETED
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
3
|
-
// Original work by Henrik Muehe (c) 2010
|
|
4
|
-
//
|
|
5
|
-
// CommonJS port by Mikola Lysenko 2013
|
|
6
|
-
//
|
|
7
|
-
// error recovery and unicode handling by Emiliano Heyns (c) 2017-2024
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.promises = exports.Library = void 0;
|
|
10
|
-
exports.parse = parse;
|
|
11
|
-
const yield_1 = require("./yield");
|
|
12
|
-
class ParsingError extends Error {
|
|
13
|
-
constructor(message, parser) {
|
|
14
|
-
message += ` at ${parser.location()}`;
|
|
15
|
-
if (parser.parsing)
|
|
16
|
-
message += ` in ${JSON.stringify(parser.parsing)}`;
|
|
17
|
-
super(message);
|
|
18
|
-
this.name = 'ParsingError';
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
const letter = /[\p{Lu}\p{Lt}\p{Ll}\p{Lm}\p{Lo}]/u;
|
|
22
|
-
class Library {
|
|
23
|
-
constructor(input, options = {}) {
|
|
24
|
-
this.entries = [];
|
|
25
|
-
this.strings = {};
|
|
26
|
-
this.comments = [];
|
|
27
|
-
this.errors = [];
|
|
28
|
-
this.preambles = [];
|
|
29
|
-
this.default_strings = {
|
|
30
|
-
JAN: '01',
|
|
31
|
-
JANUARY: '01',
|
|
32
|
-
FEB: '02',
|
|
33
|
-
FEBRUARY: '02',
|
|
34
|
-
MAR: '03',
|
|
35
|
-
MARCH: '03',
|
|
36
|
-
APR: '04',
|
|
37
|
-
APRIL: '04',
|
|
38
|
-
MAY: '05',
|
|
39
|
-
JUN: '06',
|
|
40
|
-
JUNE: '06',
|
|
41
|
-
JUL: '07',
|
|
42
|
-
JULY: '07',
|
|
43
|
-
AUG: '08',
|
|
44
|
-
AUGUST: '08',
|
|
45
|
-
SEP: '09',
|
|
46
|
-
SEPTEMBER: '09',
|
|
47
|
-
OCT: '10',
|
|
48
|
-
OCTOBER: '10',
|
|
49
|
-
NOV: '11',
|
|
50
|
-
NOVEMBER: '11',
|
|
51
|
-
DEC: '12',
|
|
52
|
-
DECEMBER: '12',
|
|
53
|
-
ACMCS: 'ACM Computing Surveys',
|
|
54
|
-
ACTA: 'Acta Informatica',
|
|
55
|
-
CACM: 'Communications of the ACM',
|
|
56
|
-
IBMJRD: 'IBM Journal of Research and Development',
|
|
57
|
-
IBMSJ: 'IBM Systems Journal',
|
|
58
|
-
IEEESE: 'IEEE Transactions on Software Engineering',
|
|
59
|
-
IEEETC: 'IEEE Transactions on Computers',
|
|
60
|
-
IEEETCAD: 'IEEE Transactions on Computer-Aided Design of Integrated Circuits',
|
|
61
|
-
IPL: 'Information Processing Letters',
|
|
62
|
-
JACM: 'Journal of the ACM',
|
|
63
|
-
JCSS: 'Journal of Computer and System Sciences',
|
|
64
|
-
SCP: 'Science of Computer Programming',
|
|
65
|
-
SICOMP: 'SIAM Journal on Computing',
|
|
66
|
-
TOCS: 'ACM Transactions on Computer Systems',
|
|
67
|
-
TODS: 'ACM Transactions on Database Systems',
|
|
68
|
-
TOG: 'ACM Transactions on Graphics',
|
|
69
|
-
TOMS: 'ACM Transactions on Mathematical Software',
|
|
70
|
-
TOOIS: 'ACM Transactions on Office Information Systems',
|
|
71
|
-
TOPLAS: 'ACM Transactions on Programming Languages and Systems',
|
|
72
|
-
TCS: 'Theoretical Computer Science',
|
|
73
|
-
};
|
|
74
|
-
this.pos = 0;
|
|
75
|
-
this.linebreaks = [];
|
|
76
|
-
this.max_entries = options.max_entries || 0;
|
|
77
|
-
this.input = input;
|
|
78
|
-
this.parsing = null;
|
|
79
|
-
if (typeof options.strings === 'string') {
|
|
80
|
-
this.input = options.strings + '\n' + input; // eslint-disable-line prefer-template
|
|
81
|
-
}
|
|
82
|
-
else if (options.strings) {
|
|
83
|
-
for (const [k, v] of Object.entries(options.strings)) {
|
|
84
|
-
this.default_strings[k.toUpperCase()] = v;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
let pos = input.indexOf('\n');
|
|
88
|
-
while (pos !== -1) {
|
|
89
|
-
this.linebreaks.push(pos);
|
|
90
|
-
pos = input.indexOf('\n', pos + 1);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
parse() {
|
|
94
|
-
this.bibtex();
|
|
95
|
-
this.entries.reverse();
|
|
96
|
-
}
|
|
97
|
-
async parseAsync() {
|
|
98
|
-
await this.bibtexAsync();
|
|
99
|
-
this.entries.reverse();
|
|
100
|
-
}
|
|
101
|
-
isWhitespace(s, horizontalOnly = false) {
|
|
102
|
-
return (s === ' ' || s === '\t' || (!horizontalOnly && (s === '\r' || s === '\n')));
|
|
103
|
-
}
|
|
104
|
-
match(s, sws = true) {
|
|
105
|
-
this.skipWhitespace();
|
|
106
|
-
if (this.input.substr(this.pos, s.length) !== s) {
|
|
107
|
-
throw new ParsingError(`Token mismatch, expected ${JSON.stringify(s)}, found ${JSON.stringify(this.input.substr(this.pos, 20))}...`, this);
|
|
108
|
-
}
|
|
109
|
-
this.pos += s.length;
|
|
110
|
-
if (sws)
|
|
111
|
-
this.skipWhitespace();
|
|
112
|
-
}
|
|
113
|
-
tryMatch(s, consume = false) {
|
|
114
|
-
this.skipWhitespace();
|
|
115
|
-
const match = this.input.substr(this.pos, s.length) === s;
|
|
116
|
-
if (match && consume)
|
|
117
|
-
this.pos += s.length;
|
|
118
|
-
return match;
|
|
119
|
-
// this.skipWhitespace()
|
|
120
|
-
}
|
|
121
|
-
skipWhitespace() {
|
|
122
|
-
while (this.pos < this.input.length && this.input[this.pos].match(/[ \t\r\n%]/)) {
|
|
123
|
-
// test for '%' is shady
|
|
124
|
-
if (this.input[this.pos] === '%') {
|
|
125
|
-
while (this.pos < this.input.length && this.input[this.pos] !== '\n')
|
|
126
|
-
this.pos++;
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
this.pos++;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/*
|
|
134
|
-
private fix_path() {
|
|
135
|
-
// workaround for https://github.com/siefkenj/unified-latex/issues/94
|
|
136
|
-
const path = '\\path|'
|
|
137
|
-
const verb = path.replace('path', 'verb')
|
|
138
|
-
if (this.input.substring(this.pos).startsWith(path)) {
|
|
139
|
-
// eslint-disable-next-line prefer-template
|
|
140
|
-
this.input = this.input.substring(0, this.pos) + verb + this.input.substring(this.pos + path.length)
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
*/
|
|
144
|
-
value_braces() {
|
|
145
|
-
let bracecount = 0;
|
|
146
|
-
this.match('{', false);
|
|
147
|
-
const start = this.pos;
|
|
148
|
-
let math = false;
|
|
149
|
-
while (true) {
|
|
150
|
-
// this.fix_path()
|
|
151
|
-
switch (this.input[this.pos]) {
|
|
152
|
-
case '\\':
|
|
153
|
-
this.pos += 1;
|
|
154
|
-
break;
|
|
155
|
-
case '{':
|
|
156
|
-
bracecount++;
|
|
157
|
-
break;
|
|
158
|
-
case '}':
|
|
159
|
-
if (bracecount === 0) {
|
|
160
|
-
if (math)
|
|
161
|
-
throw new ParsingError('Unclosed math section', this);
|
|
162
|
-
this.pos++;
|
|
163
|
-
return this.input.substring(start, this.pos - 1);
|
|
164
|
-
}
|
|
165
|
-
bracecount--;
|
|
166
|
-
break;
|
|
167
|
-
case '$':
|
|
168
|
-
math = !math;
|
|
169
|
-
break;
|
|
170
|
-
}
|
|
171
|
-
this.pos++;
|
|
172
|
-
if (this.pos >= this.input.length) {
|
|
173
|
-
throw new ParsingError(`Unterminated brace-value ${JSON.stringify(this.input.substr(start, 20))}`, this);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
value_quotes() {
|
|
178
|
-
this.match('"', false);
|
|
179
|
-
const start = this.pos;
|
|
180
|
-
let bracecount = 0;
|
|
181
|
-
while (true) {
|
|
182
|
-
// this.fix_path()
|
|
183
|
-
switch (this.input[this.pos]) {
|
|
184
|
-
case '\\':
|
|
185
|
-
this.pos += 1;
|
|
186
|
-
break;
|
|
187
|
-
case '{':
|
|
188
|
-
bracecount++;
|
|
189
|
-
break;
|
|
190
|
-
case '}':
|
|
191
|
-
bracecount--;
|
|
192
|
-
break;
|
|
193
|
-
case '"':
|
|
194
|
-
if (bracecount <= 0) {
|
|
195
|
-
this.pos++;
|
|
196
|
-
return this.input.substring(start, this.pos - 1);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
this.pos++;
|
|
200
|
-
if (this.pos >= this.input.length) {
|
|
201
|
-
throw new ParsingError(`Unterminated quote-value ${JSON.stringify(this.input.substr(start, 20))}`, this);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
single_value() {
|
|
206
|
-
if (this.tryMatch('{')) {
|
|
207
|
-
return this.value_braces();
|
|
208
|
-
}
|
|
209
|
-
else if (this.tryMatch('"')) {
|
|
210
|
-
return this.value_quotes();
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
const bare = this.key();
|
|
214
|
-
if (bare.match(/^\d+$/))
|
|
215
|
-
return bare;
|
|
216
|
-
const u_bare = bare.toUpperCase();
|
|
217
|
-
const resolved = this.strings[u_bare] || this.default_strings[u_bare];
|
|
218
|
-
if (typeof resolved === 'undefined') {
|
|
219
|
-
this.error({
|
|
220
|
-
error: `Unresolved @string reference ${JSON.stringify(bare)}`,
|
|
221
|
-
input: '',
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
return resolved || `{{${bare}}}`;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
location() {
|
|
228
|
-
const lines = this.input.substring(0, this.pos).split('\n');
|
|
229
|
-
return `line ${lines.length}, column ${lines[lines.length - 1].length + 1}`;
|
|
230
|
-
}
|
|
231
|
-
error(err) {
|
|
232
|
-
if (this.errors.find(e => e.error === err.error))
|
|
233
|
-
return;
|
|
234
|
-
this.errors.push(err);
|
|
235
|
-
}
|
|
236
|
-
value() {
|
|
237
|
-
const values = [];
|
|
238
|
-
values.push(this.single_value());
|
|
239
|
-
while (this.tryMatch('#')) {
|
|
240
|
-
this.match('#');
|
|
241
|
-
values.push(this.single_value());
|
|
242
|
-
}
|
|
243
|
-
return values.join('');
|
|
244
|
-
}
|
|
245
|
-
key(allow = '') {
|
|
246
|
-
const start = this.pos;
|
|
247
|
-
while (true) {
|
|
248
|
-
if (this.pos === this.input.length) {
|
|
249
|
-
throw new ParsingError('Runaway key', this);
|
|
250
|
-
}
|
|
251
|
-
if (this.input[this.pos].match(/[+'a-zA-Z0-9&;_:\\./-]/) || this.input[this.pos].match(letter) || allow.includes(this.input[this.pos])) {
|
|
252
|
-
this.pos++;
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
return this.input.substring(start, this.pos);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
key_equals_value(key) {
|
|
260
|
-
key = key || this.key();
|
|
261
|
-
if (!key)
|
|
262
|
-
return; // no key found, stray comma
|
|
263
|
-
if (!this.tryMatch('=')) {
|
|
264
|
-
throw new ParsingError(`${key} = value expected, equals sign missing: ${JSON.stringify(this.input.substr(this.pos, 20))}...`, this);
|
|
265
|
-
}
|
|
266
|
-
this.match('=');
|
|
267
|
-
const val = this.value();
|
|
268
|
-
if (this.parsing === 'string') {
|
|
269
|
-
this.strings[key.toUpperCase()] = val;
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
const bare = key.toLowerCase();
|
|
273
|
-
let postfix = 0;
|
|
274
|
-
while (typeof this.entries[0].fields[key = postfix ? `${bare}+duplicate-${postfix}` : bare] === 'string') {
|
|
275
|
-
postfix++;
|
|
276
|
-
}
|
|
277
|
-
this.entries[0].fields[key] = val;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
entry(d, guard) {
|
|
281
|
-
if (this.tryMatch(guard))
|
|
282
|
-
return; // empty entry
|
|
283
|
-
let key;
|
|
284
|
-
// mendeley end endnote can output entries without key... sure...
|
|
285
|
-
if (this.tryMatch(',')) {
|
|
286
|
-
// mendeley absurdity which outputs keyless entries, but at least have the decency to put a comma there
|
|
287
|
-
key = '';
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
// so maybe a real key?
|
|
291
|
-
key = this.key('[]*"');
|
|
292
|
-
}
|
|
293
|
-
if (this.tryMatch('=')) {
|
|
294
|
-
// nope; endnote just skips the comma; we can infer we're in this moronic situation because we've been dumped into field-parsing
|
|
295
|
-
this.key_equals_value(key);
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
// so we did find the real key earlier
|
|
299
|
-
this.entries[0].key = key;
|
|
300
|
-
}
|
|
301
|
-
this.tryMatch(',', true);
|
|
302
|
-
if (this.tryMatch(guard))
|
|
303
|
-
return; // no fields
|
|
304
|
-
this.key_equals_value();
|
|
305
|
-
while (this.tryMatch(',', true)) {
|
|
306
|
-
// fixes problems with commas at the end of a list
|
|
307
|
-
if (this.tryMatch(guard))
|
|
308
|
-
return;
|
|
309
|
-
this.key_equals_value();
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
directive() {
|
|
313
|
-
this.match('@');
|
|
314
|
-
return this.key().toLowerCase();
|
|
315
|
-
}
|
|
316
|
-
string() {
|
|
317
|
-
this.key_equals_value();
|
|
318
|
-
}
|
|
319
|
-
preamble() {
|
|
320
|
-
this.preambles.push(this.value());
|
|
321
|
-
}
|
|
322
|
-
comment() {
|
|
323
|
-
while (this.isWhitespace(this.input[this.pos], true))
|
|
324
|
-
this.pos++;
|
|
325
|
-
if (this.input[this.pos] === '{') {
|
|
326
|
-
this.comments.push(this.value_braces());
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
const start = this.pos;
|
|
330
|
-
while (this.input[this.pos] !== '\n' && this.pos < this.input.length)
|
|
331
|
-
this.pos++;
|
|
332
|
-
this.comments.push(this.input.substring(start, this.pos));
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
hasMore() {
|
|
336
|
-
if (this.max_entries && this.entries.length >= this.max_entries)
|
|
337
|
-
return false;
|
|
338
|
-
return (this.pos < this.input.length);
|
|
339
|
-
}
|
|
340
|
-
bibtex() {
|
|
341
|
-
while (this.hasMore()) {
|
|
342
|
-
this.parseNext();
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
async bibtexAsync() {
|
|
346
|
-
let n = 1;
|
|
347
|
-
while (this.hasMore()) {
|
|
348
|
-
this.parseNext();
|
|
349
|
-
if ((n++ % 1000) === 0)
|
|
350
|
-
await (0, yield_1.playnice)();
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
matchGuard() {
|
|
354
|
-
for (const guard of ['{}', '()']) {
|
|
355
|
-
if (this.tryMatch(guard[0])) {
|
|
356
|
-
this.match(guard[0]);
|
|
357
|
-
return guard[1];
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
throw new ParsingError(`Token mismatch, expected '{' or '(', found ${JSON.stringify(this.input.substr(this.pos, 20))}...`, this);
|
|
361
|
-
}
|
|
362
|
-
parseNext() {
|
|
363
|
-
this.skipWhitespace();
|
|
364
|
-
while (this.pos < this.input.length && this.input[this.pos] !== '@') {
|
|
365
|
-
if (this.input[this.pos] === '%') {
|
|
366
|
-
while (this.pos < this.input.length && this.input[this.pos] !== '\n')
|
|
367
|
-
this.pos++;
|
|
368
|
-
}
|
|
369
|
-
else {
|
|
370
|
-
this.pos++;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
if (this.pos >= this.input.length)
|
|
374
|
-
return;
|
|
375
|
-
let guard = '';
|
|
376
|
-
const start = this.pos;
|
|
377
|
-
try {
|
|
378
|
-
const d = this.parsing = this.directive();
|
|
379
|
-
switch (d) {
|
|
380
|
-
case 'string':
|
|
381
|
-
guard = this.matchGuard();
|
|
382
|
-
this.string();
|
|
383
|
-
this.match(guard);
|
|
384
|
-
break;
|
|
385
|
-
case 'preamble':
|
|
386
|
-
this.preamble();
|
|
387
|
-
break;
|
|
388
|
-
case 'comment':
|
|
389
|
-
this.comment();
|
|
390
|
-
break;
|
|
391
|
-
default:
|
|
392
|
-
guard = this.matchGuard();
|
|
393
|
-
this.entries.unshift({ input: '', type: d, key: '', fields: {} });
|
|
394
|
-
this.entry(d, guard);
|
|
395
|
-
this.match(guard);
|
|
396
|
-
this.entries[0].input = this.input.substring(start, this.pos).trim();
|
|
397
|
-
break;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
catch (err) {
|
|
401
|
-
if (err.name !== 'ParsingError')
|
|
402
|
-
throw err;
|
|
403
|
-
// skip ahead to the next @ and try again
|
|
404
|
-
this.pos = start + 1;
|
|
405
|
-
while (this.pos < this.input.length && this.input[this.pos] !== '@')
|
|
406
|
-
this.pos++;
|
|
407
|
-
this.error({
|
|
408
|
-
error: err.message,
|
|
409
|
-
input: this.input.substring(start, this.pos),
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
exports.Library = Library;
|
|
415
|
-
/**
|
|
416
|
-
* Parses a bibtex source in verbatim mode. Good for detection of bibtex and for later LaTeX-reparsing.
|
|
417
|
-
*/
|
|
418
|
-
function parse(input, options = {}) {
|
|
419
|
-
const parser = new Library(input, options);
|
|
420
|
-
parser.parse();
|
|
421
|
-
return parser;
|
|
422
|
-
}
|
|
423
|
-
exports.promises = {
|
|
424
|
-
async parse(input, options = {}) {
|
|
425
|
-
const parser = new Library(input, options);
|
|
426
|
-
await parser.parseAsync();
|
|
427
|
-
return parser;
|
|
428
|
-
},
|
|
429
|
-
};
|
|
430
|
-
//# sourceMappingURL=verbatim.js.map
|