@retorquere/bibtex-parser 6.4.2 → 6.4.3

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.d.ts CHANGED
@@ -47,3 +47,4 @@ export declare function parse(input: string, options?: ParserOptions): Chunk[];
47
47
  export declare const promises: {
48
48
  parse(input: string, options?: ParserOptions): Promise<Chunk[]>;
49
49
  };
50
+ //# sourceMappingURL=chunker.d.ts.map
package/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import * as bibtex from './grammar';
2
+ import * as chunker from './chunker';
3
+ import * as jabref from './jabref';
2
4
  import { JabRefMetadata } from './jabref';
3
5
  export declare function toSentenceCase(text: string, ignoreHTML?: boolean): string;
4
6
  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;
@@ -208,7 +210,7 @@ export interface ParserOptions {
208
210
  */
209
211
  caseProtection?: 'as-needed' | 'strict' | boolean;
210
212
  /**
211
- * The parser can change TeX markup (\textsc, \emph, etc) to a text equivalent. The defaults are HTML-oriented, but you can pass in your own configuration here
213
+ * The parser can change TeX markup (\\textsc, \\emph, etc) to a text equivalent. The defaults are HTML-oriented, but you can pass in your own configuration here
212
214
  */
213
215
  markup?: MarkupMapping;
214
216
  /**
@@ -264,5 +266,6 @@ export declare function ast(input: string, options?: ParserOptions, clean?: bool
264
266
  export declare const promises: {
265
267
  parse(input: string, options?: ParserOptions): Promise<Bibliography>;
266
268
  };
267
- export * as chunker from './chunker';
268
- export * as jabref from './jabref';
269
+ export { chunker };
270
+ export { jabref };
271
+ //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -5,6 +5,9 @@ const tslib_1 = require("tslib");
5
5
  /* eslint-disable @typescript-eslint/no-unsafe-argument */
6
6
  const bibtex = tslib_1.__importStar(require("./grammar"));
7
7
  const chunker = tslib_1.__importStar(require("./chunker"));
8
+ exports.chunker = chunker;
9
+ const jabref = tslib_1.__importStar(require("./jabref"));
10
+ exports.jabref = jabref;
8
11
  const jabref_1 = require("./jabref");
9
12
  const unicode2latex_1 = require("unicode2latex");
10
13
  const crossref_json_1 = tslib_1.__importDefault(require("./crossref.json"));
@@ -409,21 +412,26 @@ class Parser {
409
412
  }, {});
410
413
  for (const entry of this.entries) {
411
414
  if (entry.fields.crossref) {
415
+ let applied;
412
416
  for (const parent_key of entry.fields.crossref) {
413
417
  const parent = entries[parent_key];
414
- const mapping = parent && crossref_json_1.default.find(xref => xref.source.includes(parent.type) && xref.target.includes(entry.type));
415
- if (parent && mapping) {
418
+ if (!parent)
419
+ continue;
420
+ for (const mapping of crossref_json_1.default.filter(xref => xref.source.includes(parent.type) && xref.target.includes(entry.type))) {
416
421
  for (const { source, target } of mapping.fields) {
417
422
  if (parent.fields[source] && !entry.fields[target]) {
423
+ applied = true;
418
424
  entry.fields[target] = JSON.parse(JSON.stringify(parent.fields[source]));
419
425
  }
420
426
  }
421
427
  }
422
428
  }
429
+ if (applied)
430
+ delete entry.fields.crossref;
423
431
  }
424
432
  }
425
433
  }
426
- const { comments, jabref } = (0, jabref_1.parse)(this.comments);
434
+ const { comments, jabref } = (0, jabref_1.parse)(this.comments); // eslint-disable-line @typescript-eslint/no-shadow
427
435
  return {
428
436
  errors: this.errors,
429
437
  entries: this.entries,
@@ -1538,6 +1546,4 @@ exports.promises = {
1538
1546
  return await parser.parseAsync(input);
1539
1547
  },
1540
1548
  };
1541
- exports.chunker = tslib_1.__importStar(require("./chunker"));
1542
- exports.jabref = tslib_1.__importStar(require("./jabref"));
1543
1549
  //# sourceMappingURL=index.js.map
package/jabref.d.ts CHANGED
@@ -55,3 +55,4 @@ export declare function parse(comments: string[]): {
55
55
  comments: string[];
56
56
  jabref: JabRefMetadata;
57
57
  };
58
+ //# sourceMappingURL=jabref.d.ts.map
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@retorquere/bibtex-parser",
3
- "version": "6.4.2",
3
+ "version": "6.4.3",
4
4
  "description": "BibTeX parser",
5
5
  "main": "index.js",
6
+ "typings": "./index.d.ts",
6
7
  "scripts": {
7
8
  "lint": "eslint . --ext .ts --cache --cache-location .eslintcache/",
8
9
  "prestart": "npm run lint && peggy grammar.peggy",
@@ -19,8 +20,11 @@
19
20
  "preversion": "npm test && npm run abbr",
20
21
  "postversion": "git push --follow-tags",
21
22
  "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/",
22
- "docs": "rm -rf docs && typedoc --name 'BibTeX parser' index.ts && touch docs/.nojekyll",
23
- "ncu": "./build/submodules.py && ncu -u && npm i && git add package.json package-lock.json && npm audit fix && git commit -m ncu"
23
+ "x-docs": "rm -rf docs temp && typedoc --name 'BibTeX parser' index.ts && touch docs/.nojekyll",
24
+ "docs": "mkdir -p etc temp && npm run api-extractor && npm run api-documenter",
25
+ "ncu": "./build/submodules.py && ncu -u && npm i && git add package.json package-lock.json && npm audit fix && git commit -m ncu",
26
+ "api-documenter": "api-documenter markdown --input temp --output docs",
27
+ "api-extractor": "api-extractor run --local --verbose"
24
28
  },
25
29
  "repository": {
26
30
  "type": "git",
@@ -32,6 +36,8 @@
32
36
  "author": "Emiliano Heyns",
33
37
  "license": "ISC",
34
38
  "devDependencies": {
39
+ "@microsoft/api-documenter": "^7.19.27",
40
+ "@microsoft/api-extractor": "^7.33.7",
35
41
  "@types/node": "^18.11.18",
36
42
  "@typescript-eslint/eslint-plugin": "^5.48.0",
37
43
  "@typescript-eslint/parser": "^5.48.0",
@@ -51,7 +57,6 @@
51
57
  "tap": "^16.3.2",
52
58
  "ts-node": "^10.9.1",
53
59
  "tslib": "^2.4.1",
54
- "typedoc": "^0.23.23",
55
60
  "typescript": "^4.9.4"
56
61
  },
57
62
  "dependencies": {