@retorquere/bibtex-parser 5.3.0 → 6.0.0
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/chunker.js +1 -0
- package/grammar.d.ts +2 -2
- package/grammar.js +1780 -2107
- package/index.js +23 -12
- package/jabref.js +1 -1
- package/package.json +16 -16
package/index.js
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.jabref = exports.chunker = exports.promises = exports.ast = exports.parse = exports.fields = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
|
|
6
|
-
const
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
6
|
+
const bibtex = (0, tslib_1.__importStar)(require("./grammar"));
|
|
7
|
+
const chunker = (0, tslib_1.__importStar)(require("./chunker"));
|
|
7
8
|
const jabref_1 = require("./jabref");
|
|
8
9
|
const unicode2latex_1 = require("unicode2latex");
|
|
9
|
-
const crossref_json_1 = tslib_1.__importDefault(require("./crossref.json"));
|
|
10
|
+
const crossref_json_1 = (0, tslib_1.__importDefault)(require("./crossref.json"));
|
|
10
11
|
class ParserError extends Error {
|
|
11
12
|
constructor(message, node) {
|
|
12
13
|
super(message); // 'Error' breaks prototype chain here
|
|
@@ -192,7 +193,7 @@ class Parser {
|
|
|
192
193
|
options.sentenceCase = false;
|
|
193
194
|
options.caseProtection = false;
|
|
194
195
|
}
|
|
195
|
-
this.options = Object.assign({ caseProtection: 'as-needed', verbatimFields: [/^citeulike-linkout-[0-9]+$/, ...exports.fields.verbatim], verbatimCommands: ['url'
|
|
196
|
+
this.options = Object.assign({ caseProtection: 'as-needed', verbatimFields: [/^citeulike-linkout-[0-9]+$/, ...exports.fields.verbatim], verbatimCommands: ['url'], unnestFields: [...exports.fields.title, ...exports.fields.unnest, ...exports.fields.verbatim], unnestMode: 'unwrap', htmlFields: exports.fields.html, guessAlreadySentenceCased: true, applyCrossRef: options.applyCrossRef || typeof options.applyCrossRef === 'undefined', markup: {} }, options);
|
|
196
197
|
const markup_defaults = {
|
|
197
198
|
enquote: { open: '\u201c', close: '\u201d' },
|
|
198
199
|
sub: { open: '<sub>', close: '</sub>' },
|
|
@@ -325,7 +326,7 @@ class Parser {
|
|
|
325
326
|
}
|
|
326
327
|
}
|
|
327
328
|
}
|
|
328
|
-
const { comments, jabref } = jabref_1.parse(this.comments);
|
|
329
|
+
const { comments, jabref } = (0, jabref_1.parse)(this.comments);
|
|
329
330
|
return {
|
|
330
331
|
errors: this.errors,
|
|
331
332
|
entries: this.entries,
|
|
@@ -859,11 +860,9 @@ class Parser {
|
|
|
859
860
|
return this.clean(arg);
|
|
860
861
|
}
|
|
861
862
|
break;
|
|
862
|
-
// just take the URL? Not the label?
|
|
863
863
|
case 'href':
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
break;
|
|
864
|
+
node.arguments.required = node.arguments.required.map(a => this.clean(a));
|
|
865
|
+
return node;
|
|
867
866
|
case 'url':
|
|
868
867
|
if (arg = this.argument(node, 'Text'))
|
|
869
868
|
return this.text(arg);
|
|
@@ -1052,7 +1051,12 @@ class Parser {
|
|
|
1052
1051
|
case 'StringDeclaration':
|
|
1053
1052
|
break;
|
|
1054
1053
|
default:
|
|
1055
|
-
|
|
1054
|
+
if (node.kind === 'RegularCommand' && node.command === 'href') {
|
|
1055
|
+
this.convert_href(node);
|
|
1056
|
+
}
|
|
1057
|
+
else {
|
|
1058
|
+
return this.error(new ParserError(`no converter for ${node.kind}: ${this.show(node)}`, node));
|
|
1059
|
+
}
|
|
1056
1060
|
}
|
|
1057
1061
|
}
|
|
1058
1062
|
splitOnce(s, sep, fromEnd = false) {
|
|
@@ -1344,6 +1348,13 @@ class Parser {
|
|
|
1344
1348
|
this.convert_block(Object.assign(Object.assign({}, node), { kind: 'Block', markup: {} }));
|
|
1345
1349
|
this.field.text += close;
|
|
1346
1350
|
}
|
|
1351
|
+
convert_href(node) {
|
|
1352
|
+
this.field.text += '<a href="';
|
|
1353
|
+
this.convert(node.arguments.required[0]);
|
|
1354
|
+
this.field.text += '">';
|
|
1355
|
+
this.convert(node.arguments.required[1]);
|
|
1356
|
+
this.field.text += '</a>';
|
|
1357
|
+
}
|
|
1347
1358
|
convert_block(node) {
|
|
1348
1359
|
const start = this.field.text.length;
|
|
1349
1360
|
let prefix = '';
|
|
@@ -1426,6 +1437,6 @@ exports.promises = {
|
|
|
1426
1437
|
return await parser.parseAsync(input);
|
|
1427
1438
|
},
|
|
1428
1439
|
};
|
|
1429
|
-
exports.chunker = tslib_1.__importStar(require("./chunker"));
|
|
1430
|
-
exports.jabref = tslib_1.__importStar(require("./jabref"));
|
|
1440
|
+
exports.chunker = (0, tslib_1.__importStar)(require("./chunker"));
|
|
1441
|
+
exports.jabref = (0, tslib_1.__importStar)(require("./jabref"));
|
|
1431
1442
|
//# sourceMappingURL=index.js.map
|
package/jabref.js
CHANGED
|
@@ -53,7 +53,7 @@ function parse(comments) {
|
|
|
53
53
|
return true;
|
|
54
54
|
});
|
|
55
55
|
if (decoded.groupsversion)
|
|
56
|
-
result.groupsversion = parseInt(decoded.groupsversion[0].trim()) || decoded.groupsversion[0];
|
|
56
|
+
result.groupsversion = parseInt(decoded.groupsversion[0].trim()) || decoded.groupsversion[0]; // eslint-disable-line @typescript-eslint/no-unsafe-argument
|
|
57
57
|
if (decoded.fileDirectory)
|
|
58
58
|
result.fileDirectory = decoded.fileDirectory[0];
|
|
59
59
|
if (decoded.databaseType)
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retorquere/bibtex-parser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "BibTeX parser",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"check-env": "node -e 'console.log(process.env)' | grep npm",
|
|
8
8
|
"lint": "eslint . --ext .ts --cache --cache-location .eslintcache/",
|
|
9
|
-
"prestart": "npm run lint &&
|
|
9
|
+
"prestart": "npm run lint && peggy grammar.peggy",
|
|
10
10
|
"start": "tsc -d",
|
|
11
11
|
"poststart": "npm run docs",
|
|
12
12
|
"pretest": "npm start",
|
|
13
13
|
"test": "node test/jest",
|
|
14
14
|
"presnap": "npm start",
|
|
15
15
|
"snap": "node test/jest --updateSnapshot",
|
|
16
|
-
"minitest": "
|
|
16
|
+
"minitest": "peggy grammar.peggy && tsc -d && node i.js",
|
|
17
17
|
"list": "tar tvf $(npm pack)",
|
|
18
18
|
"prepublishOnly": "npm start",
|
|
19
19
|
"abbr": "./build/abbr.py",
|
|
@@ -34,27 +34,27 @@
|
|
|
34
34
|
"author": "Emiliano Heyns",
|
|
35
35
|
"license": "ISC",
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/node": "^16.
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
39
|
-
"@typescript-eslint/parser": "^4.
|
|
37
|
+
"@types/node": "^16.11.10",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
|
39
|
+
"@typescript-eslint/parser": "^5.4.0",
|
|
40
40
|
"command-line-args": "^5.2.0",
|
|
41
|
-
"csv": "^
|
|
41
|
+
"csv": "^6.0.4",
|
|
42
42
|
"digital-tree": "^2.0.3",
|
|
43
43
|
"ejs": "^3.1.6",
|
|
44
|
-
"eslint": "^
|
|
45
|
-
"eslint-plugin-import": "^2.
|
|
44
|
+
"eslint": "^8.3.0",
|
|
45
|
+
"eslint-plugin-import": "^2.25.3",
|
|
46
46
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
47
|
-
"jest": "^27.
|
|
48
|
-
"jest-cli": "^27.
|
|
47
|
+
"jest": "^27.3.1",
|
|
48
|
+
"jest-cli": "^27.3.1",
|
|
49
49
|
"jest-specific-snapshot": "^5.0.0",
|
|
50
50
|
"mkdirp": "^1.0.4",
|
|
51
|
-
"node-fetch": "^
|
|
52
|
-
"
|
|
51
|
+
"node-fetch": "^3.1.0",
|
|
52
|
+
"peggy": "^1.2.0",
|
|
53
53
|
"slug": "^5.1.0",
|
|
54
|
-
"ts-node": "^10.
|
|
54
|
+
"ts-node": "^10.4.0",
|
|
55
55
|
"tslib": "^2.3.1",
|
|
56
|
-
"typedoc": "^0.
|
|
57
|
-
"typescript": "^4.
|
|
56
|
+
"typedoc": "^0.22.9",
|
|
57
|
+
"typescript": "^4.5.2"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"unicode2latex": "^2.1.36",
|