@retorquere/bibtex-parser 8.0.7 → 8.0.8
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/index.d.ts +5 -0
- package/index.js +22 -2
- package/package.json +6 -11
- package/grammar.js +0 -5020
package/README.md
CHANGED
|
@@ -8,4 +8,4 @@ While parsing, the parser will apply markup for commands such as `\textbf`, `\te
|
|
|
8
8
|
|
|
9
9
|
BibTeX is a reference management program that makes it easy for users of TeX and LaTeX to generate bibliographies for books and journal articles. When possible, it is usually stylized in the TeX font the way TeX and LaTeX are. LaTeX was first created in 1985 by Leslie Lamport and Oren Patashnik.
|
|
10
10
|
|
|
11
|
-
Documenation is available at [
|
|
11
|
+
Documenation is available at [https://retorque.re/bibtex-parser/](https://retorque.re/bibtex-parser/).
|
package/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Node } from '@unified-latex/unified-latex-types';
|
|
|
2
2
|
import * as bibtex from './verbatim';
|
|
3
3
|
import * as JabRef from './jabref';
|
|
4
4
|
export { JabRefMetadata } from './jabref';
|
|
5
|
+
export { ParseError } from './verbatim';
|
|
5
6
|
export { toSentenceCase } from './sentence-case';
|
|
6
7
|
type CreatorFields = {
|
|
7
8
|
author?: Creator[];
|
|
@@ -36,6 +37,10 @@ export type Entry = {
|
|
|
36
37
|
type: string;
|
|
37
38
|
key: string;
|
|
38
39
|
fields: Fields;
|
|
40
|
+
crossref?: {
|
|
41
|
+
inherited: string[];
|
|
42
|
+
donated: [];
|
|
43
|
+
};
|
|
39
44
|
input: string;
|
|
40
45
|
};
|
|
41
46
|
export interface Bibliography {
|
package/index.js
CHANGED
|
@@ -203,6 +203,9 @@ const FieldAction = {
|
|
|
203
203
|
'year',
|
|
204
204
|
'month',
|
|
205
205
|
],
|
|
206
|
+
noCrossRef: [
|
|
207
|
+
'file',
|
|
208
|
+
],
|
|
206
209
|
};
|
|
207
210
|
const narguments = {
|
|
208
211
|
advance: 1,
|
|
@@ -1052,24 +1055,41 @@ class BibTeXParser {
|
|
|
1052
1055
|
if (!order.includes(key))
|
|
1053
1056
|
order.push(key);
|
|
1054
1057
|
}
|
|
1058
|
+
const add = (obj, kind, field) => {
|
|
1059
|
+
obj[kind] = [...(new Set([...obj[kind], field]))].sort();
|
|
1060
|
+
};
|
|
1055
1061
|
for (const key of order) {
|
|
1056
1062
|
const child = entries[key.toUpperCase()];
|
|
1057
1063
|
const parent = entries[(_a = child.fields.crossref) === null || _a === void 0 ? void 0 : _a.toUpperCase()];
|
|
1058
1064
|
if (!parent)
|
|
1059
1065
|
continue;
|
|
1066
|
+
child.crossref = child.crossref || { donated: [], inherited: [] };
|
|
1067
|
+
parent.crossref = parent.crossref || { donated: [], inherited: [] };
|
|
1060
1068
|
for (const mappings of [crossref_json_1.default[child.type], crossref_json_1.default['*']].filter(m => m)) {
|
|
1061
1069
|
for (const mapping of [mappings[parent.type], mappings['*']].filter(m => m)) {
|
|
1062
1070
|
for (const [childfield, parentfield] of Object.entries(mapping)) {
|
|
1063
|
-
if (!child.fields[childfield] && parent.fields[parentfield])
|
|
1071
|
+
if (!child.fields[childfield] && parent.fields[parentfield]) {
|
|
1064
1072
|
child.fields[childfield] = parent.fields[parentfield];
|
|
1073
|
+
add(child.crossref, 'inherited', childfield);
|
|
1074
|
+
add(parent.crossref, 'donated', parentfield);
|
|
1075
|
+
}
|
|
1065
1076
|
}
|
|
1066
1077
|
for (const field of (fields_json_1.default[child.type] || [])) {
|
|
1067
|
-
if (
|
|
1078
|
+
if (FieldAction.noCrossRef.includes(field))
|
|
1079
|
+
continue;
|
|
1080
|
+
if (!child.fields[field] && parent.fields[field]) {
|
|
1068
1081
|
child.fields[field] = parent.fields[field];
|
|
1082
|
+
add(child.crossref, 'inherited', field);
|
|
1083
|
+
add(parent.crossref, 'donated', field);
|
|
1084
|
+
}
|
|
1069
1085
|
}
|
|
1070
1086
|
}
|
|
1071
1087
|
}
|
|
1072
1088
|
}
|
|
1089
|
+
for (const entry of this.bib.entries) {
|
|
1090
|
+
if (entry.crossref && !entry.crossref.donated.length && !entry.crossref.inherited.length)
|
|
1091
|
+
delete entry.crossref;
|
|
1092
|
+
}
|
|
1073
1093
|
}
|
|
1074
1094
|
const { comments, jabref } = JabRef.parse(base.comments);
|
|
1075
1095
|
this.bib.comments = comments;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retorquere/bibtex-parser",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.8",
|
|
4
4
|
"description": "BibTeX parser",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "./index.d.ts",
|
|
@@ -9,24 +9,21 @@
|
|
|
9
9
|
"lint": "eslint . --ext .ts --cache --cache-location .eslintcache/",
|
|
10
10
|
"prestart": "npm run lint",
|
|
11
11
|
"start": "npm run tsc",
|
|
12
|
-
"tsc": "
|
|
12
|
+
"tsc": "tsc -d",
|
|
13
13
|
"pretest": "npm start",
|
|
14
14
|
"test": "tap --timeout 0 --disable-coverage --allow-empty-coverage",
|
|
15
15
|
"snap": "npm test --snapshot",
|
|
16
16
|
"snap:big": "npm test --snapshot --big",
|
|
17
|
-
"minitest": "
|
|
17
|
+
"minitest": "./build/crossref.py && tsc -d && node i.js",
|
|
18
18
|
"list": "tar tvf $(npm pack)",
|
|
19
19
|
"prepublishOnly": "npm start",
|
|
20
20
|
"abbr": "./build/abbr.py",
|
|
21
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
|
-
"x-docs": "rm -rf docs temp && typedoc --name 'BibTeX parser' index.ts && touch docs/.nojekyll",
|
|
25
24
|
"predocs": "npm start",
|
|
26
|
-
"docs": "
|
|
27
|
-
"ncu": "./build/submodules.py && ./build/crossref.py && ncu -u && npm i && git add package.json package-lock.json && npm audit fix && git commit -m ncu"
|
|
28
|
-
"api-documenter": "api-documenter markdown --input temp --output docs",
|
|
29
|
-
"api-extractor": "api-extractor run --local --verbose"
|
|
25
|
+
"docs": "typedoc",
|
|
26
|
+
"ncu": "./build/submodules.py && ./build/crossref.py && ncu -u && npm i && git add package.json package-lock.json && npm audit fix && git commit -m ncu"
|
|
30
27
|
},
|
|
31
28
|
"repository": {
|
|
32
29
|
"type": "git",
|
|
@@ -38,8 +35,6 @@
|
|
|
38
35
|
"author": "Emiliano Heyns",
|
|
39
36
|
"license": "ISC",
|
|
40
37
|
"devDependencies": {
|
|
41
|
-
"@microsoft/api-documenter": "^7.24.1",
|
|
42
|
-
"@microsoft/api-extractor": "^7.43.0",
|
|
43
38
|
"@types/node": "^20.12.2",
|
|
44
39
|
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
|
45
40
|
"@typescript-eslint/parser": "^7.4.0",
|
|
@@ -54,12 +49,12 @@
|
|
|
54
49
|
"glob": "^10.3.12",
|
|
55
50
|
"mkdirp": "^3.0.1",
|
|
56
51
|
"node-fetch": "^3.3.2",
|
|
57
|
-
"peggy": "^4.0.2",
|
|
58
52
|
"piscina": "^4.4.0",
|
|
59
53
|
"slug": "^9.0.0",
|
|
60
54
|
"tap": "^18.7.2",
|
|
61
55
|
"ts-node": "^10.9.2",
|
|
62
56
|
"tslib": "^2.6.2",
|
|
57
|
+
"typedoc": "^0.25.12",
|
|
63
58
|
"typescript": "^5.4.3"
|
|
64
59
|
},
|
|
65
60
|
"dependencies": {
|