@retorquere/bibtex-parser 6.3.11 → 6.4.1
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/grammar.js +277 -160
- package/index.d.ts +3 -3
- package/index.js +18 -3
- package/package.json +11 -11
- package/unabbrev.json +975 -33
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as bibtex from './grammar';
|
|
2
2
|
import { JabRefMetadata } from './jabref';
|
|
3
3
|
export declare function toSentenceCase(text: string, ignoreHTML?: boolean): string;
|
|
4
|
-
|
|
4
|
+
type Node = bibtex.Bibliography | bibtex.Math | bibtex.Environment | bibtex.Block | bibtex.RegularCommand | bibtex.DiacriticCommand | bibtex.Entry | bibtex.Field | bibtex.NumberValue | bibtex.StringDeclaration | bibtex.StringReference | bibtex.SubscriptCommand | bibtex.SuperscriptCommand | bibtex.SymbolCommand | bibtex.TextValue | bibtex.PreambleExpression | bibtex.BracedComment | bibtex.LineComment | bibtex.Markup | bibtex.NonEntryText;
|
|
5
5
|
export interface Name {
|
|
6
6
|
/**
|
|
7
7
|
* If the name is a literal (surrounded by braces) it will be in this property, and none of the other properties will be set
|
|
@@ -230,8 +230,8 @@ export interface ParserOptions {
|
|
|
230
230
|
*/
|
|
231
231
|
verbatimCommands?: string[];
|
|
232
232
|
/**
|
|
233
|
-
* In the past many bibtex entries would just always wrap a field in double braces
|
|
234
|
-
* blame them. Fields listed here will either have one outer layer of braces treated as case-preserve, or have the outer braced be ignored completely, if this is detected.
|
|
233
|
+
* In the past many bibtex entries would just always wrap a field in double braces, likely because whomever was writing them couldn't figure out the case meddling rules (and who could
|
|
234
|
+
* blame them). Fields listed here will either have one outer layer of braces treated as case-preserve, or have the outer braced be ignored completely, if this is detected.
|
|
235
235
|
*/
|
|
236
236
|
unnestFields?: string[];
|
|
237
237
|
unnestMode?: 'preserve' | 'unwrap';
|
package/index.js
CHANGED
|
@@ -586,9 +586,16 @@ class Parser {
|
|
|
586
586
|
}
|
|
587
587
|
return false;
|
|
588
588
|
}
|
|
589
|
+
isBreak(node, kind) {
|
|
590
|
+
return node && node.kind === 'RegularCommand' && kind.includes(node.command);
|
|
591
|
+
}
|
|
589
592
|
clean(node) {
|
|
590
|
-
if (Array.isArray(node))
|
|
591
|
-
return node
|
|
593
|
+
if (Array.isArray(node)) {
|
|
594
|
+
return node
|
|
595
|
+
.filter((child, i) => !(this.isBreak(child, ['\\']) && this.isBreak(node[i - 1], ['\\', 'par']))) // condense linebreaks
|
|
596
|
+
.filter((child, i) => !this.isBreak(child, ['par']) || !this.isBreak(node[i - 1], ['par'])) // condense parbreaks
|
|
597
|
+
.map(child => this.clean(child)); // eslint-disable-line @typescript-eslint/no-unsafe-return
|
|
598
|
+
}
|
|
592
599
|
delete node.loc;
|
|
593
600
|
switch (node.kind) {
|
|
594
601
|
case 'InlineMath':
|
|
@@ -623,6 +630,7 @@ class Parser {
|
|
|
623
630
|
case 'Text':
|
|
624
631
|
case 'BracedComment':
|
|
625
632
|
case 'LineComment':
|
|
633
|
+
case 'NonEntryText':
|
|
626
634
|
return node;
|
|
627
635
|
default:
|
|
628
636
|
return this.error(new ParserError(`no cleanup method for ${this.show(node)}`, node), this.text());
|
|
@@ -985,7 +993,8 @@ class Parser {
|
|
|
985
993
|
case 'right':
|
|
986
994
|
return this.text();
|
|
987
995
|
case 'par':
|
|
988
|
-
|
|
996
|
+
case '\\':
|
|
997
|
+
return node;
|
|
989
998
|
case 'cyr':
|
|
990
999
|
if (this.argument(node, 'none'))
|
|
991
1000
|
return this.text();
|
|
@@ -1151,6 +1160,12 @@ class Parser {
|
|
|
1151
1160
|
if (node.kind === 'RegularCommand' && node.command === 'href') {
|
|
1152
1161
|
this.convert_href(node);
|
|
1153
1162
|
}
|
|
1163
|
+
else if (node.kind === 'RegularCommand' && node.command === 'par') {
|
|
1164
|
+
this.field.text += this.field.html ? '<p>\n' : ' ';
|
|
1165
|
+
}
|
|
1166
|
+
else if (node.kind === 'RegularCommand' && node.command === '\\') {
|
|
1167
|
+
this.field.text += this.field.html ? '<b>\n' : ' ';
|
|
1168
|
+
}
|
|
1154
1169
|
else {
|
|
1155
1170
|
return this.error(new ParserError(`no converter for ${node.kind}: ${this.show(node)}`, node));
|
|
1156
1171
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retorquere/bibtex-parser",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.1",
|
|
4
4
|
"description": "BibTeX parser",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,27 +32,27 @@
|
|
|
32
32
|
"author": "Emiliano Heyns",
|
|
33
33
|
"license": "ISC",
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@types/node": "^18.11.
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
37
|
-
"@typescript-eslint/parser": "^5.
|
|
35
|
+
"@types/node": "^18.11.18",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^5.48.0",
|
|
37
|
+
"@typescript-eslint/parser": "^5.48.0",
|
|
38
38
|
"command-line-args": "^5.2.1",
|
|
39
|
-
"csv": "^6.2.
|
|
39
|
+
"csv": "^6.2.5",
|
|
40
40
|
"digital-tree": "^2.0.4",
|
|
41
41
|
"ejs": "^3.1.8",
|
|
42
|
-
"eslint": "^8.
|
|
42
|
+
"eslint": "^8.31.0",
|
|
43
43
|
"eslint-plugin-import": "^2.26.0",
|
|
44
44
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
45
45
|
"glob": "^8.0.3",
|
|
46
46
|
"mkdirp": "^1.0.4",
|
|
47
|
-
"node-fetch": "^3.
|
|
47
|
+
"node-fetch": "^3.3.0",
|
|
48
48
|
"peggy": "^2.0.1",
|
|
49
49
|
"piscina": "^3.2.0",
|
|
50
50
|
"slug": "^8.2.2",
|
|
51
|
-
"tap": "^16.3.
|
|
51
|
+
"tap": "^16.3.2",
|
|
52
52
|
"ts-node": "^10.9.1",
|
|
53
|
-
"tslib": "^2.4.
|
|
54
|
-
"typedoc": "^0.23.
|
|
55
|
-
"typescript": "^4.
|
|
53
|
+
"tslib": "^2.4.1",
|
|
54
|
+
"typedoc": "^0.23.23",
|
|
55
|
+
"typescript": "^4.9.4"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"unicode2latex": "^3.0.0",
|