@retorquere/bibtex-parser 6.4.13 → 6.4.17

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/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as bibtex from './grammar';
2
2
  import * as chunker from './chunker';
3
3
  import * as jabref from './jabref';
4
4
  import { JabRefMetadata } from './jabref';
5
- export declare function toSentenceCase(text: string, ignoreHTML?: boolean): string;
5
+ export { toSentenceCase } from './sentence-case';
6
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;
7
7
  export interface Name {
8
8
  /**
package/index.js CHANGED
@@ -37,103 +37,9 @@ const jabref_1 = require("./jabref");
37
37
  const unicode2latex_1 = require("unicode2latex");
38
38
  const crossref_json_1 = __importDefault(require("./crossref.json"));
39
39
  const fields_json_1 = __importDefault(require("./fields.json"));
40
- const xregexp_1 = __importDefault(require("xregexp"));
41
- function restore(text, orig, preserve) {
42
- for (const { start, end } of preserve) {
43
- text = text.substring(0, start) + orig.substring(start, end) + text.substring(end);
44
- }
45
- return text;
46
- }
47
- class SentenceCaser {
48
- constructor() {
49
- this.acronym = (0, xregexp_1.default)('^(\\p{Lu}[.])+(?=$|[\\P{L}])');
50
- this.quoted = (0, xregexp_1.default)('^"[^"]+"(?=$|[\\P{L}])');
51
- this.innerCaps = (0, xregexp_1.default)('\\p{Ll}\\p{Lu}');
52
- this.allCaps = (0, xregexp_1.default)('^\\p{Lu}+$');
53
- this.aint = (0, xregexp_1.default)("^\\p{L}n't(?=$|[\\P{L}])"); // isn't
54
- this.word = (0, xregexp_1.default)('^\\p{L}+(-\\p{L}+)*'); // also match gallium-nitride as one word
55
- this.and = (0, xregexp_1.default)('^\\p{Lu}&\\p{Lu}(?=$|[\\P{L}])'); // Q&A
56
- }
57
- convert(text, ignoreHTML = false) {
58
- this.input = text;
59
- this.result = '';
60
- this.sentenceStart = true;
61
- const preserve = [];
62
- if (ignoreHTML) {
63
- let replace = true;
64
- while (replace) {
65
- replace = false;
66
- // always keep the leading char, but skip markup
67
- this.input = this.input.replace(/[^<>]<[^>]+>/, (match, i) => {
68
- preserve.push({ start: i + 1, end: i + match.length });
69
- replace = true;
70
- return match[0].repeat(match.length);
71
- });
72
- }
73
- replace = true;
74
- while (replace) {
75
- replace = false;
76
- // always keep the leading char, but skip markup
77
- this.input = this.input.replace(/<[^>]+>[^<>]/, (match, i) => {
78
- preserve.push({ start: i, end: i + match.length - 1 });
79
- replace = true;
80
- return match[match.length - 1].repeat(match.length);
81
- });
82
- }
83
- }
84
- this.input = this.input.replace(/[;:]\s+A\s/g, match => match.toLowerCase());
85
- this.input = this.input.replace(/[–—]\s*A\s/g, match => match.toLowerCase());
86
- let m;
87
- while (this.input) {
88
- if (m = xregexp_1.default.exec(this.input, this.quoted)) { // "Hello There"
89
- this.add(m[0], undefined, true);
90
- }
91
- else if (m = xregexp_1.default.exec(this.input, this.acronym)) { // U.S.
92
- this.add(m[0], undefined, true);
93
- }
94
- else if (m = xregexp_1.default.exec(this.input, this.aint)) { // isn't
95
- this.add(m[0], undefined, false);
96
- }
97
- else if (m = xregexp_1.default.exec(this.input, this.word)) {
98
- this.add(m[0], '-', false);
99
- }
100
- else if (m = xregexp_1.default.exec(this.input, this.and)) {
101
- this.add(m[0], undefined, true);
102
- }
103
- else {
104
- this.add(this.input[0], undefined, false);
105
- }
106
- }
107
- return restore(this.result, text, preserve);
108
- }
109
- add(word, splitter, keep) {
110
- if (splitter) {
111
- word = word.split(splitter).map((part, i) => {
112
- if ((keep || this.sentenceStart) && i === 0)
113
- return part;
114
- if (xregexp_1.default.exec(part, this.innerCaps))
115
- return part;
116
- if (xregexp_1.default.exec(part, this.allCaps))
117
- return part;
118
- return part.toLowerCase();
119
- }).join(splitter);
120
- }
121
- else {
122
- if (!keep)
123
- word = word.toLowerCase();
124
- }
125
- this.result += word;
126
- this.input = this.input.substr(word.length);
127
- if (!word.match(/^\s+$/)) {
128
- this.sentenceStart = !!word.match(/^[.?!]$/) || (word.length === 2 && word[1] === '.'); // Vitamin A. Vitamin B.
129
- }
130
- }
131
- }
132
- const sentenceCaser = new SentenceCaser;
133
- function toSentenceCase(text, ignoreHTML = false) {
134
- return sentenceCaser.convert(text, ignoreHTML);
135
- }
136
- exports.toSentenceCase = toSentenceCase;
40
+ var sentence_case_1 = require("./sentence-case");
41
+ Object.defineProperty(exports, "toSentenceCase", { enumerable: true, get: function () { return sentence_case_1.toSentenceCase; } });
42
+ const sentence_case_2 = require("./sentence-case");
137
43
  class ParserError extends Error {
138
44
  constructor(message, node) {
139
45
  super(message); // 'Error' breaks prototype chain here
@@ -1451,7 +1357,7 @@ class Parser {
1451
1357
  convertToSentenceCase(text) {
1452
1358
  if (!this.field.preserveRanges)
1453
1359
  return text;
1454
- const sentenceCased = restore(sentenceCaser.convert(text, true), text, this.field.preserveRanges);
1360
+ const sentenceCased = (0, sentence_case_2.restore)((0, sentence_case_2.toSentenceCase)(text, true), text, this.field.preserveRanges);
1455
1361
  if (text !== sentenceCased)
1456
1362
  this.entry.sentenceCased = true;
1457
1363
  return sentenceCased;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retorquere/bibtex-parser",
3
- "version": "6.4.13",
3
+ "version": "6.4.17",
4
4
  "description": "BibTeX parser",
5
5
  "main": "index.js",
6
6
  "typings": "./index.d.ts",
@@ -36,28 +36,28 @@
36
36
  "author": "Emiliano Heyns",
37
37
  "license": "ISC",
38
38
  "devDependencies": {
39
- "@microsoft/api-documenter": "^7.22.3",
40
- "@microsoft/api-extractor": "^7.34.7",
41
- "@types/node": "^18.16.3",
42
- "@typescript-eslint/eslint-plugin": "^5.59.2",
43
- "@typescript-eslint/parser": "^5.59.2",
39
+ "@microsoft/api-documenter": "^7.22.32",
40
+ "@microsoft/api-extractor": "^7.36.3",
41
+ "@types/node": "^20.4.8",
42
+ "@typescript-eslint/eslint-plugin": "^6.2.1",
43
+ "@typescript-eslint/parser": "^6.2.1",
44
44
  "command-line-args": "^5.2.1",
45
- "csv": "^6.2.11",
45
+ "csv": "^6.3.1",
46
46
  "digital-tree": "^2.0.4",
47
47
  "ejs": "^3.1.9",
48
- "eslint": "^8.39.0",
49
- "eslint-plugin-import": "^2.27.5",
48
+ "eslint": "^8.46.0",
49
+ "eslint-plugin-import": "^2.28.0",
50
50
  "eslint-plugin-prefer-arrow": "^1.2.3",
51
- "glob": "^10.2.2",
51
+ "glob": "^10.3.3",
52
52
  "mkdirp": "^3.0.1",
53
- "node-fetch": "^3.3.1",
53
+ "node-fetch": "^3.3.2",
54
54
  "peggy": "^3.0.2",
55
- "piscina": "^3.2.0",
56
- "slug": "^8.2.2",
57
- "tap": "^16.3.4",
55
+ "piscina": "^4.1.0",
56
+ "slug": "^8.2.3",
57
+ "tap": "^16.3.8",
58
58
  "ts-node": "^10.9.1",
59
- "tslib": "^2.5.0",
60
- "typescript": "^5.0.4"
59
+ "tslib": "^2.6.1",
60
+ "typescript": "^5.1.6"
61
61
  },
62
62
  "dependencies": {
63
63
  "unicode2latex": "^3.0.3",
package/unabbrev.json CHANGED
@@ -28015,6 +28015,7 @@
28015
28015
  "EAST BIOL": "Eastern biologist",
28016
28016
  "EAST CENT AFR J SURG": "East and Central African journal of surgery",
28017
28017
  "EAST CENT EUR": "East central Europe. L'Europe du centre-est",
28018
+ "EAST CHINA NORM. UNIV. SCI. REP.": "East China Normal University Scientific Reports",
28018
28019
  "EAST CHRIST STUDIES": "Vladimir Solov'ev: Reconciler and Polemcist",
28019
28020
  "EAST ECON J": "Eastern economic journal",
28020
28021
  "EAST EUR COUNTRYS": "Eastern European Countryside",
@@ -46658,6 +46659,7 @@
46658
46659
  "IRAN. J. RADIAT. RES.": "Iranian Journal of Radiation Research",
46659
46660
  "IRAN. J. RADIOL.": "Iranian Journal of Radiology",
46660
46661
  "IRAN. J. REPROD. MED.": "Iranian Journal of Reproductive Medicine",
46662
+ "IRAN. J. SCI.": "Iranian Journal of Science",
46661
46663
  "IRAN. J. SCI. TECHNOL.": "Iranian Journal of Science and Technology",
46662
46664
  "IRAN. J. SCI. TECHNOL. A.": "Iranian Journal of Science and Technology Transaction A-science",
46663
46665
  "IRAN. J. SCI. TECHNOL. B.": "Iranian Journal of Science and Technology Transaction B-engineering",
@@ -56882,6 +56884,7 @@
56882
56884
  "J. MATH. PHYS.": "Journal of Mathematical Physics",
56883
56885
  "J. MATH. PHYS. (N.Y.)": "Journal of Mathematical Physics (New York)",
56884
56886
  "J. MATH. PHYS. ANAL. GEO.": "Journal of Mathematical Physics Analysis Geometry",
56887
+ "J. MATH. PHYS. ANAL. GEOM.": "Journal of Mathematical Physics, Analysis, Geometry",
56885
56888
  "J. MATH. PHYS. CAMB.": "Journal of Mathematics and Physics",
56886
56889
  "J. MATH. PHYS. SCI.": "Journal of Mathematical and Physical Sciences",
56887
56890
  "J. MATH. PSYCH.": "Journal of Mathematical Psycholog y",
@@ -63404,6 +63407,7 @@
63404
63407
  "MATH. CONTROL SIGNAL.": "Mathematics of Control Signals and Systems",
63405
63408
  "MATH. CONTROL SIGNALS SYSTEMS": "Mathematics of Control, Signals, and Systems",
63406
63409
  "MATH. CULT. ARTS": "Mathematics, Culture, and the Arts",
63410
+ "MATH. DATA": "Mathematics of Data",
63407
63411
  "MATH. ED.": "Mathematical Education",
63408
63412
  "MATH. ED. (SIWAN)": "The Mathematics Education",
63409
63413
  "MATH. ED. LIB.": "Mathematics Education Library",
@@ -92868,6 +92872,7 @@
92868
92872
  "SYNTH. LECT. MATH. STAT.": "Synthesis Lectures on Mathematics and Statistics",
92869
92873
  "SYNTH. LECT. THEOR. COMPUT. SCI.": "Synthesis Lectures on Theoretical Computer Science",
92870
92874
  "SYNTH. LECT. VIS. COMPUT.": "Synthesis Lectures on Visual Computing",
92875
+ "SYNTH. LECT. WAVE PHENOM. PHYS. SCI.": "Synthesis Lectures on Wave Phenomena in the Physical Sciences",
92871
92876
  "SYNTH. LIBR.": "Visualization, Explanation and Reasoning Styles in Mathematics",
92872
92877
  "SYNTH. LUBR.": "Synthetic Lubrication",
92873
92878
  "SYNTH. MET.": "Synthetic Metals",
@@ -96213,6 +96218,7 @@
96213
96218
  "UNDERGRAD. LECT. NOTES PHYS.": "Undergraduate Lecture Notes in Physics",
96214
96219
  "UNDERGRAD. TEXTS COMPUT. SCI.": "Undergraduate Texts in Computer Science",
96215
96220
  "UNDERGRAD. TEXTS MATH.": "Undergraduate Texts in Mathematics",
96221
+ "UNDERGRAD. TEXTS MATH. READ. MATH.": "Undergraduate Texts in Mathematics. Readings in Mathematics",
96216
96222
  "UNDERGRAD. TEXTS PHYS.": "Undergraduate Texts in Physics",
96217
96223
  "UNDERGRAD. TOP. COMPUT. SCI.": "Undergraduate Topics in Computer Science",
96218
96224
  "UNDERS INTERV BROADEN PARTICIP RES CAREERS": "Understanding interventions that broaden participation in research careers",
@@ -99074,6 +99080,7 @@
99074
99080
  "WORLD SCI. LEC. NO. PHY.": "World Scientific Lecture Notes in Physics",
99075
99081
  "WORLD SCI. LECT. NOTES": "World Scientific Lecture Notes in Complex Systems",
99076
99082
  "WORLD SCI. LECT. NOTES ECON. POLICY": "World Scientific Lecture Notes in Economics and Policy",
99083
+ "WORLD SCI. LECT. NOTES FINANCE": "World Scientific Lecture Notes in Finance",
99077
99084
  "WORLD SCI. LECTURE NOTES PHYS.": "World Scientific Lecture Notes in Physics",
99078
99085
  "WORLD SCI. MONOGRAPH": "World Scientific Monograph Series in Mathematics",
99079
99086
  "WORLD SCI. NOW PUBL. SER. BUS.": "World Scientific---Now Publishers Series in Business",