scholarly-parse 0.1.0 → 0.1.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/CHANGELOG.md +4 -0
- package/README.md +5 -3
- package/changelog/0.1.x/0.1.1.md +41 -0
- package/dist/formats/html/blocks.d.ts.map +1 -1
- package/dist/formats/html/blocks.js +12 -9
- package/dist/formats/html/blocks.js.map +1 -1
- package/dist/formats/html/context.d.ts +3 -0
- package/dist/formats/html/context.d.ts.map +1 -1
- package/dist/formats/html/context.js.map +1 -1
- package/dist/formats/html/inline.d.ts.map +1 -1
- package/dist/formats/html/inline.js +70 -12
- package/dist/formats/html/inline.js.map +1 -1
- package/dist/formats/html/metadata.d.ts.map +1 -1
- package/dist/formats/html/metadata.js +5 -5
- package/dist/formats/html/metadata.js.map +1 -1
- package/dist/formats/html/parse.d.ts.map +1 -1
- package/dist/formats/html/parse.js +2 -0
- package/dist/formats/html/parse.js.map +1 -1
- package/dist/formats/html/references.d.ts.map +1 -1
- package/dist/formats/html/references.js +23 -7
- package/dist/formats/html/references.js.map +1 -1
- package/dist/formats/jats/blocks.d.ts.map +1 -1
- package/dist/formats/jats/blocks.js +9 -6
- package/dist/formats/jats/blocks.js.map +1 -1
- package/dist/formats/jats/context.d.ts +4 -1
- package/dist/formats/jats/context.d.ts.map +1 -1
- package/dist/formats/jats/fragment.d.ts.map +1 -1
- package/dist/formats/jats/fragment.js +2 -0
- package/dist/formats/jats/fragment.js.map +1 -1
- package/dist/formats/jats/parse.d.ts.map +1 -1
- package/dist/formats/jats/parse.js +6 -3
- package/dist/formats/jats/parse.js.map +1 -1
- package/dist/formats/jats/references.d.ts.map +1 -1
- package/dist/formats/jats/references.js +90 -21
- package/dist/formats/jats/references.js.map +1 -1
- package/dist/formats/jats/tables.d.ts.map +1 -1
- package/dist/formats/jats/tables.js +14 -9
- package/dist/formats/jats/tables.js.map +1 -1
- package/dist/formats/latexml/blocks.d.ts.map +1 -1
- package/dist/formats/latexml/blocks.js +20 -13
- package/dist/formats/latexml/blocks.js.map +1 -1
- package/dist/formats/latexml/context.d.ts +4 -1
- package/dist/formats/latexml/context.d.ts.map +1 -1
- package/dist/formats/latexml/context.js.map +1 -1
- package/dist/formats/latexml/parse.d.ts.map +1 -1
- package/dist/formats/latexml/parse.js +11 -6
- package/dist/formats/latexml/parse.js.map +1 -1
- package/dist/formats/pdf/blocks.d.ts +2 -1
- package/dist/formats/pdf/blocks.d.ts.map +1 -1
- package/dist/formats/pdf/blocks.js +43 -16
- package/dist/formats/pdf/blocks.js.map +1 -1
- package/dist/formats/pdf/context.d.ts +15 -0
- package/dist/formats/pdf/context.d.ts.map +1 -0
- package/dist/formats/pdf/context.js +2 -0
- package/dist/formats/pdf/context.js.map +1 -0
- package/dist/formats/pdf/layout.js +7 -9
- package/dist/formats/pdf/layout.js.map +1 -1
- package/dist/formats/pdf/load.d.ts +30 -3
- package/dist/formats/pdf/load.d.ts.map +1 -1
- package/dist/formats/pdf/load.js +120 -46
- package/dist/formats/pdf/load.js.map +1 -1
- package/dist/formats/pdf/parse.d.ts +16 -1
- package/dist/formats/pdf/parse.d.ts.map +1 -1
- package/dist/formats/pdf/parse.js +57 -12
- package/dist/formats/pdf/parse.js.map +1 -1
- package/dist/formats/pdf/references.d.ts.map +1 -1
- package/dist/formats/pdf/references.js +2 -4
- package/dist/formats/pdf/references.js.map +1 -1
- package/dist/formats/pdf/structure.d.ts +1 -5
- package/dist/formats/pdf/structure.d.ts.map +1 -1
- package/dist/formats/pdf/structure.js +2 -2
- package/dist/formats/pdf/structure.js.map +1 -1
- package/dist/formats/tei/inline.d.ts +3 -0
- package/dist/formats/tei/inline.d.ts.map +1 -1
- package/dist/formats/tei/inline.js +14 -8
- package/dist/formats/tei/inline.js.map +1 -1
- package/dist/formats/tei/parse.d.ts.map +1 -1
- package/dist/formats/tei/parse.js +182 -42
- package/dist/formats/tei/parse.js.map +1 -1
- package/dist/html/interstitial.d.ts.map +1 -1
- package/dist/html/interstitial.js +47 -6
- package/dist/html/interstitial.js.map +1 -1
- package/dist/html/tables.d.ts +13 -8
- package/dist/html/tables.d.ts.map +1 -1
- package/dist/html/tables.js +7 -6
- package/dist/html/tables.js.map +1 -1
- package/dist/model/doi.d.ts +22 -0
- package/dist/model/doi.d.ts.map +1 -0
- package/dist/model/doi.js +56 -0
- package/dist/model/doi.js.map +1 -0
- package/dist/model/extremes.d.ts +7 -3
- package/dist/model/extremes.d.ts.map +1 -1
- package/dist/model/extremes.js +10 -3
- package/dist/model/extremes.js.map +1 -1
- package/dist/model/table-grid.d.ts +44 -7
- package/dist/model/table-grid.d.ts.map +1 -1
- package/dist/model/table-grid.js +59 -11
- package/dist/model/table-grid.js.map +1 -1
- package/dist/model/trailing.d.ts +15 -0
- package/dist/model/trailing.d.ts.map +1 -0
- package/dist/model/trailing.js +22 -0
- package/dist/model/trailing.js.map +1 -0
- package/dist/parse.d.ts +6 -0
- package/dist/parse.d.ts.map +1 -1
- package/dist/parse.js +5 -2
- package/dist/parse.js.map +1 -1
- package/dist/render/inline.d.ts +1 -1
- package/dist/render/inline.d.ts.map +1 -1
- package/dist/render/inline.js +6 -4
- package/dist/render/inline.js.map +1 -1
- package/dist/render/markdown.d.ts +35 -6
- package/dist/render/markdown.d.ts.map +1 -1
- package/dist/render/markdown.js +205 -36
- package/dist/render/markdown.js.map +1 -1
- package/dist/render/sections.d.ts +7 -2
- package/dist/render/sections.d.ts.map +1 -1
- package/dist/render/sections.js +20 -6
- package/dist/render/sections.js.map +1 -1
- package/dist/render/text.d.ts +12 -4
- package/dist/render/text.d.ts.map +1 -1
- package/dist/render/text.js +257 -49
- package/dist/render/text.js.map +1 -1
- package/dist/xml/ordered.d.ts.map +1 -1
- package/dist/xml/ordered.js +36 -2
- package/dist/xml/ordered.js.map +1 -1
- package/package.json +1 -1
|
@@ -35,7 +35,13 @@ const SIGNATURES = [
|
|
|
35
35
|
'a bot-check page',
|
|
36
36
|
],
|
|
37
37
|
];
|
|
38
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Every `<meta>` tag's text, each read to its `>` or the next `<`: a tag pattern that
|
|
40
|
+
* reads to the next `>` rereads the rest of the page from each of a run of unclosed tags.
|
|
41
|
+
*/
|
|
42
|
+
const META_TAG = /<meta\b[^<>]*/gi;
|
|
43
|
+
/** A refresh tag's `content`: its delay, then the URL it redirects to. */
|
|
44
|
+
const REFRESH_TARGET = /content=["']?\s*\d+\s*;\s*url=\s*['"]?([^'">\s]+)/i;
|
|
39
45
|
/**
|
|
40
46
|
* Describes the interstitial `html` is, or returns undefined for a real page. A page
|
|
41
47
|
* carrying scholarly citation metadata or substantial text is never an interstitial,
|
|
@@ -44,24 +50,59 @@ const META_REFRESH = /<meta[^>]+http-equiv=["']?refresh["']?[^>]*content=["']?\s
|
|
|
44
50
|
export function interstitialReason(html) {
|
|
45
51
|
if (html.length > MAX_INTERSTITIAL_CHARS)
|
|
46
52
|
return;
|
|
47
|
-
|
|
53
|
+
const metaTags = html.match(META_TAG) ?? [];
|
|
54
|
+
if (metaTags.some((tag) => /name=["']citation_title["']/i.test(tag)))
|
|
48
55
|
return;
|
|
49
56
|
if (visibleText(html).length > MAX_INTERSTITIAL_TEXT)
|
|
50
57
|
return;
|
|
51
58
|
const match = SIGNATURES.find(([pattern]) => pattern.test(html));
|
|
52
59
|
if (match)
|
|
53
60
|
return `The page is ${match[1]}, not the document`;
|
|
54
|
-
const refresh =
|
|
61
|
+
const refresh = metaTags.map(redirectTarget).find(Boolean);
|
|
55
62
|
if (refresh)
|
|
56
63
|
return `The page is a redirect stub to ${refresh.replace(/&/g, '&')}, not the document`;
|
|
57
64
|
return;
|
|
58
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Where a `<meta http-equiv="refresh">` tag redirects to, its attributes in either order.
|
|
68
|
+
* Each attribute is searched for once within the tag, never from every place in it.
|
|
69
|
+
*/
|
|
70
|
+
function redirectTarget(tag) {
|
|
71
|
+
return /http-equiv=["']?refresh/i.test(tag) ? REFRESH_TARGET.exec(tag)?.[1] : undefined;
|
|
72
|
+
}
|
|
59
73
|
/** Text a reader would see: scripts, styles, and tags removed, whitespace collapsed. */
|
|
60
74
|
function visibleText(html) {
|
|
61
|
-
return html
|
|
62
|
-
.replace(/<
|
|
63
|
-
.replace(/<[^>]*>/g, ' ')
|
|
75
|
+
return withoutHiddenElements(html)
|
|
76
|
+
.replace(/<[^<>]*>/g, ' ')
|
|
64
77
|
.replace(/\s+/g, ' ')
|
|
65
78
|
.trim();
|
|
66
79
|
}
|
|
80
|
+
/** Elements whose content a reader never sees. */
|
|
81
|
+
const HIDDEN_ELEMENT = /<(script|style|noscript|template)\b/gi;
|
|
82
|
+
/**
|
|
83
|
+
* `html` with each script, style, noscript, and template element, from its opening tag to
|
|
84
|
+
* the first closing tag of its name, replaced by a space; an opening tag with no closing
|
|
85
|
+
* tag after it stays. Each closing tag is found with one forward search, and a name with
|
|
86
|
+
* no closing tag left is not searched for again, so a run of unclosed openers is read once.
|
|
87
|
+
*/
|
|
88
|
+
function withoutHiddenElements(html) {
|
|
89
|
+
const unclosed = new Set();
|
|
90
|
+
let out = '';
|
|
91
|
+
let copied = 0;
|
|
92
|
+
for (const open of html.matchAll(HIDDEN_ELEMENT)) {
|
|
93
|
+
const name = open[1]?.toLowerCase() ?? '';
|
|
94
|
+
if (open.index < copied || unclosed.has(name))
|
|
95
|
+
continue;
|
|
96
|
+
const close = new RegExp(`</${name}\\s*>`, 'gi');
|
|
97
|
+
close.lastIndex = open.index + open[0].length;
|
|
98
|
+
const end = close.exec(html);
|
|
99
|
+
if (!end) {
|
|
100
|
+
unclosed.add(name);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
out += `${html.slice(copied, open.index)} `;
|
|
104
|
+
copied = end.index + end[0].length;
|
|
105
|
+
}
|
|
106
|
+
return out + html.slice(copied);
|
|
107
|
+
}
|
|
67
108
|
//# sourceMappingURL=interstitial.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interstitial.js","sourceRoot":"","sources":["../../src/html/interstitial.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,gGAAgG;AAChG,MAAM,sBAAsB,GAAG,GAAG,GAAG,IAAI,CAAC;AAE1C,4FAA4F;AAC5F,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC,qFAAqF;AACrF,MAAM,UAAU,GAAuB;IACrC;QACE,gMAAgM;QAChM,6BAA6B;KAC9B;IACD,CAAC,8CAA8C,EAAE,yBAAyB,CAAC;IAC3E,CAAC,wBAAwB,EAAE,2BAA2B,CAAC;IACvD,CAAC,4CAA4C,EAAE,2BAA2B,CAAC;IAC3E,CAAC,mBAAmB,EAAE,kCAAkC,CAAC;IACzD,CAAC,wBAAwB,EAAE,qCAAqC,CAAC;IACjE,CAAC,gCAAgC,EAAE,2BAA2B,CAAC;IAC/D,CAAC,yDAAyD,EAAE,0BAA0B,CAAC;IACvF,CAAC,6DAA6D,EAAE,uBAAuB,CAAC;IACxF,CAAC,yCAAyC,EAAE,iCAAiC,CAAC;IAC9E,CAAC,6BAA6B,EAAE,8BAA8B,CAAC;IAC/D,CAAC,0BAA0B,EAAE,wBAAwB,CAAC;IACtD;QACE,+EAA+E;QAC/E,kBAAkB;KACnB;IACD;QACE,+GAA+G;QAC/G,kBAAkB;KACnB;CACF,CAAC;AAEF,MAAM,
|
|
1
|
+
{"version":3,"file":"interstitial.js","sourceRoot":"","sources":["../../src/html/interstitial.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,gGAAgG;AAChG,MAAM,sBAAsB,GAAG,GAAG,GAAG,IAAI,CAAC;AAE1C,4FAA4F;AAC5F,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC,qFAAqF;AACrF,MAAM,UAAU,GAAuB;IACrC;QACE,gMAAgM;QAChM,6BAA6B;KAC9B;IACD,CAAC,8CAA8C,EAAE,yBAAyB,CAAC;IAC3E,CAAC,wBAAwB,EAAE,2BAA2B,CAAC;IACvD,CAA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,MAAM,CAAC;QAC9C,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACnB,SAAS;QACX,CAAC;QACD,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;QAC5C,MAAM,GAAG,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACrC,CAAC;IACD,OAAO,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/html/tables.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* @fileoverview An HTML table — `<table>` markup, or LaTeXML's `<span>`-based tabular —
|
|
3
|
+
* read into the shared grid. Rows of a table nested inside a cell belong to that cell's
|
|
4
|
+
* text, not to the outer table.
|
|
5
|
+
* @module src/html/tables
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
+
import { type Grid, type GridBudget } from '../model/table-grid.js';
|
|
8
|
+
/**
|
|
9
|
+
* Read a table into a grid, charging the document's `budget`; `cellText` renders one
|
|
10
|
+
* cell's content. With `boldHeaders`, a cell whose text is entirely bold counts as a
|
|
11
|
+
* header cell, so a leading all-bold row becomes the header: LaTeX tables mark their
|
|
12
|
+
* header row that way, with no `<th>`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readHtmlTable(table: Element, cellText: (cell: Element) => string, budget: GridBudget, options?: {
|
|
7
15
|
boldHeaders?: boolean;
|
|
8
|
-
}):
|
|
9
|
-
headerRows: number;
|
|
10
|
-
rows: string[][];
|
|
11
|
-
};
|
|
16
|
+
}): Grid;
|
|
12
17
|
//# sourceMappingURL=tables.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../src/html/tables.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../src/html/tables.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAEL,KAAK,IAAI,EACT,KAAK,UAAU,EAGhB,MAAM,wBAAwB,CAAC;AAwBhC;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,EACnC,MAAM,EAAE,UAAU,EAClB,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACtC,IAAI,CA+BN"}
|
package/dist/html/tables.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* text, not to the outer table.
|
|
5
5
|
* @module src/html/tables
|
|
6
6
|
*/
|
|
7
|
-
import { buildGrid, spanValue } from '../model/table-grid.js';
|
|
7
|
+
import { buildGrid, spanValue, } from '../model/table-grid.js';
|
|
8
8
|
import { childElements, hasClass, tagOf } from './dom.js';
|
|
9
9
|
const SECTION_TAGS = new Set(['thead', 'tbody', 'tfoot']);
|
|
10
10
|
const SECTION_CLASSES = ['ltx_thead', 'ltx_tbody', 'ltx_tfoot'];
|
|
@@ -23,11 +23,12 @@ function isBoldText(text) {
|
|
|
23
23
|
return /^\*\*[^*]+\*\*(?:\s*\*\*[^*]+\*\*)*$/.test(text);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Read a table into a grid
|
|
27
|
-
* a cell whose text is entirely bold counts as a
|
|
28
|
-
* becomes the header: LaTeX tables mark their
|
|
26
|
+
* Read a table into a grid, charging the document's `budget`; `cellText` renders one
|
|
27
|
+
* cell's content. With `boldHeaders`, a cell whose text is entirely bold counts as a
|
|
28
|
+
* header cell, so a leading all-bold row becomes the header: LaTeX tables mark their
|
|
29
|
+
* header row that way, with no `<th>`.
|
|
29
30
|
*/
|
|
30
|
-
export function readHtmlTable(table, cellText, options = {}) {
|
|
31
|
+
export function readHtmlTable(table, cellText, budget, options = {}) {
|
|
31
32
|
const rows = [];
|
|
32
33
|
const collect = (container, inHead) => {
|
|
33
34
|
for (const child of childElements(container)) {
|
|
@@ -57,6 +58,6 @@ export function readHtmlTable(table, cellText, options = {}) {
|
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
60
|
collect(table, false);
|
|
60
|
-
return buildGrid(rows);
|
|
61
|
+
return buildGrid(rows, budget);
|
|
61
62
|
}
|
|
62
63
|
//# sourceMappingURL=tables.js.map
|
package/dist/html/tables.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../src/html/tables.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../src/html/tables.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,SAAS,EAIT,SAAS,GACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAE1D,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAC1D,MAAM,eAAe,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;AAEhE,SAAS,KAAK,CAAC,OAAgB;IAC7B,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,MAAM,CAAC,OAAgB;IAC9B,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,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C,CAAC;wBAChD,IAAI;qBACL,CAAC;gBACJ,CAAC,CAAC,CAAC;gBACL,kEAAkE;gBAClE,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;oBAAE,KAAK,MAAM,IAAI,IAAI,KAAK;wBAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;gBAC3F,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YAC/B,CAAC;iBAAM,IACL,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC9B,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAC/C,CAAC;gBACD,OAAO,CAAC,KAAK,EAAE,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IACF,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACtB,OAAO,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The first DOI in running text, read in one pass over its runs of DOI
|
|
3
|
+
* characters, without the punctuation, quotes, and brackets that close it. PDF, HTML, and
|
|
4
|
+
* LaTeXML references read the DOI in an entry's text here.
|
|
5
|
+
* @module src/model/doi
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The first DOI in `text` whose run of DOI characters ends at whitespace, the end of the
|
|
9
|
+
* text, or a quote closing one opened right before it, without the marks closing it
|
|
10
|
+
* ({@link trimDoi}). A run cut short at `<`, `>`, or any other quote is not a whole DOI,
|
|
11
|
+
* and a run that leaves no suffix is passed over. Each run is read once, so a long run
|
|
12
|
+
* that ends at a quote costs one pass, not one per `10.` inside it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function doiInText(text: string): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* `doi` without the punctuation, quotes, and brackets closing it, or undefined when that
|
|
17
|
+
* leaves no suffix. A `)` or `]` goes only when nothing before it in the DOI opens it, so
|
|
18
|
+
* `10.1002/(SICI)1097-4636(199907)` stays whole. One pass matches the brackets and one
|
|
19
|
+
* walks back from the end.
|
|
20
|
+
*/
|
|
21
|
+
export declare function trimDoi(doi: string): string | undefined;
|
|
22
|
+
//# sourceMappingURL=doi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doi.d.ts","sourceRoot":"","sources":["../../src/model/doi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQ1D;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgBvD"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The first DOI in running text, read in one pass over its runs of DOI
|
|
3
|
+
* characters, without the punctuation, quotes, and brackets that close it. PDF, HTML, and
|
|
4
|
+
* LaTeXML references read the DOI in an entry's text here.
|
|
5
|
+
* @module src/model/doi
|
|
6
|
+
*/
|
|
7
|
+
/** A DOI's `10.` prefix and every character after it that a DOI can hold. */
|
|
8
|
+
const DOI_RUN = /\b10\.\d{4,9}\/[^\s"<>]+/g;
|
|
9
|
+
/** Marks that close a DOI rather than belong to it: a sentence's punctuation, closing quotes. */
|
|
10
|
+
const CLOSING_MARKS = '.,;:"\'”’';
|
|
11
|
+
/**
|
|
12
|
+
* The first DOI in `text` whose run of DOI characters ends at whitespace, the end of the
|
|
13
|
+
* text, or a quote closing one opened right before it, without the marks closing it
|
|
14
|
+
* ({@link trimDoi}). A run cut short at `<`, `>`, or any other quote is not a whole DOI,
|
|
15
|
+
* and a run that leaves no suffix is passed over. Each run is read once, so a long run
|
|
16
|
+
* that ends at a quote costs one pass, not one per `10.` inside it.
|
|
17
|
+
*/
|
|
18
|
+
export function doiInText(text) {
|
|
19
|
+
for (const { 0: run, index } of text.matchAll(DOI_RUN)) {
|
|
20
|
+
const after = text.charAt(index + run.length);
|
|
21
|
+
const whole = !after || /\s/.test(after) || (after === '"' && text.charAt(index - 1) === '"');
|
|
22
|
+
const doi = whole ? trimDoi(run) : undefined;
|
|
23
|
+
if (doi)
|
|
24
|
+
return doi;
|
|
25
|
+
}
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* `doi` without the punctuation, quotes, and brackets closing it, or undefined when that
|
|
30
|
+
* leaves no suffix. A `)` or `]` goes only when nothing before it in the DOI opens it, so
|
|
31
|
+
* `10.1002/(SICI)1097-4636(199907)` stays whole. One pass matches the brackets and one
|
|
32
|
+
* walks back from the end.
|
|
33
|
+
*/
|
|
34
|
+
export function trimDoi(doi) {
|
|
35
|
+
const unmatched = new Set();
|
|
36
|
+
const open = { ')': 0, ']': 0 };
|
|
37
|
+
for (let i = 0; i < doi.length; i++) {
|
|
38
|
+
const char = doi.charAt(i);
|
|
39
|
+
if (char === '(')
|
|
40
|
+
open[')']++;
|
|
41
|
+
else if (char === '[')
|
|
42
|
+
open[']']++;
|
|
43
|
+
else if (char === ')' || char === ']') {
|
|
44
|
+
if (open[char] > 0)
|
|
45
|
+
open[char]--;
|
|
46
|
+
else
|
|
47
|
+
unmatched.add(i);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
let end = doi.length;
|
|
51
|
+
while (end > 0 && (CLOSING_MARKS.includes(doi.charAt(end - 1)) || unmatched.has(end - 1)))
|
|
52
|
+
end--;
|
|
53
|
+
const kept = doi.slice(0, end);
|
|
54
|
+
return kept.length > kept.indexOf('/') + 1 ? kept : undefined;
|
|
55
|
+
}
|
|
56
|
+
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I,IAAI,KAAK,GAAG;YAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;aACzB,IAAI,IAAI,KAAK,GAAG;YAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;aAC9B,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACtC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;gBAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;;gBAC5B,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IACD,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC;IACrB,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QAAE,GAAG,EAAE,CAAC;IACjG,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC/B,OAAO,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAChE,CAAC"}
|
package/dist/model/extremes.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview The largest and smallest of a list of numbers
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* @fileoverview The largest and smallest of a list of numbers, and one list appended to
|
|
3
|
+
* another, without spreading the list into call arguments. `Math.max(...values)` and
|
|
4
|
+
* `target.push(...items)` pass every element as an argument, and a document-sized list —
|
|
5
|
+
* a table's rows, a page's text items, a section's blocks — overflows the call stack
|
|
6
|
+
* (Node rejects a little over a hundred thousand).
|
|
5
7
|
* @module src/model/extremes
|
|
6
8
|
*/
|
|
7
9
|
/** The largest value, or `-Infinity` for none, as `Math.max()` returns. */
|
|
8
10
|
export declare function largest(values: readonly number[]): number;
|
|
9
11
|
/** The smallest value, or `Infinity` for none, as `Math.min()` returns. */
|
|
10
12
|
export declare function smallest(values: readonly number[]): number;
|
|
13
|
+
/** Append every item to `target` in order, as `target.push(...items)` does. */
|
|
14
|
+
export declare function append<T>(target: T[], items: Iterable<T>): void;
|
|
11
15
|
//# sourceMappingURL=extremes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extremes.d.ts","sourceRoot":"","sources":["../../src/model/extremes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"extremes.d.ts","sourceRoot":"","sources":["../../src/model/extremes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,2EAA2E;AAC3E,wBAAgB,OAAO,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAIzD;AAED,2EAA2E;AAC3E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAI1D;AAED,+EAA+E;AAC/E,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAE/D"}
|
package/dist/model/extremes.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview The largest and smallest of a list of numbers
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* @fileoverview The largest and smallest of a list of numbers, and one list appended to
|
|
3
|
+
* another, without spreading the list into call arguments. `Math.max(...values)` and
|
|
4
|
+
* `target.push(...items)` pass every element as an argument, and a document-sized list —
|
|
5
|
+
* a table's rows, a page's text items, a section's blocks — overflows the call stack
|
|
6
|
+
* (Node rejects a little over a hundred thousand).
|
|
5
7
|
* @module src/model/extremes
|
|
6
8
|
*/
|
|
7
9
|
/** The largest value, or `-Infinity` for none, as `Math.max()` returns. */
|
|
@@ -20,4 +22,9 @@ export function smallest(values) {
|
|
|
20
22
|
result = value;
|
|
21
23
|
return result;
|
|
22
24
|
}
|
|
25
|
+
/** Append every item to `target` in order, as `target.push(...items)` does. */
|
|
26
|
+
export function append(target, items) {
|
|
27
|
+
for (const item of items)
|
|
28
|
+
target.push(item);
|
|
29
|
+
}
|
|
23
30
|
//# sourceMappingURL=extremes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extremes.js","sourceRoot":"","sources":["../../src/model/extremes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"extremes.js","sourceRoot":"","sources":["../../src/model/extremes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,2EAA2E;AAC3E,MAAM,UAAU,OAAO,CAAC,MAAyB;IAC/C,IAAI,MAAM,GAAG,CAAC,QAAQ,CAAC;IACvB,KAAK,MAAM,KAAK,IAAI,MAAM;QAAE,IAAI,KAAK,GAAG,MAAM;YAAE,MAAM,GAAG,KAAK,CAAC;IAC/D,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,QAAQ,CAAC,MAAyB;IAChD,IAAI,MAAM,GAAG,QAAQ,CAAC;IACtB,KAAK,MAAM,KAAK,IAAI,MAAM;QAAE,IAAI,KAAK,GAAG,MAAM;YAAE,MAAM,GAAG,KAAK,CAAC;IAC/D,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,MAAM,CAAI,MAAW,EAAE,KAAkB;IACvD,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
* the M−1 rows below, repeating its text: the value belongs to each position it covers,
|
|
8
8
|
* and keeping the source cell count would put values under the wrong headers.
|
|
9
9
|
* (pubmed-mcp-server#111)
|
|
10
|
+
*
|
|
11
|
+
* The grids of one document draw on one {@link GridBudget}: what the tables of a document
|
|
12
|
+
* may repeat and hold is capped where the grid is built, where a parser can still record
|
|
13
|
+
* what it cut.
|
|
10
14
|
* @module src/model/table-grid
|
|
11
15
|
*/
|
|
12
16
|
/**
|
|
@@ -15,6 +19,41 @@
|
|
|
15
19
|
* bounded row instead of an unbounded allocation.
|
|
16
20
|
*/
|
|
17
21
|
export declare const MAX_TABLE_COLUMNS = 512;
|
|
22
|
+
/**
|
|
23
|
+
* Characters the tables of one document may repeat from a spanned cell into the other
|
|
24
|
+
* positions it covers. Past it, a covered position is empty; the cell's own position
|
|
25
|
+
* keeps its text. The most any corpus document repeats is about a thousand.
|
|
26
|
+
*/
|
|
27
|
+
export declare const MAX_SPAN_COPY_CHARS = 1000000;
|
|
28
|
+
/**
|
|
29
|
+
* Grid cells the tables of one document may hold together, padding included. Past it, a
|
|
30
|
+
* table's remaining rows are dropped. The largest corpus document holds under a thousand;
|
|
31
|
+
* a supplementary table of 500,000 rows by two columns fits whole.
|
|
32
|
+
*/
|
|
33
|
+
export declare const MAX_GRID_CELLS = 2000000;
|
|
34
|
+
/** What the tables of one document may still spend. Every grid built for the document draws on it. */
|
|
35
|
+
export interface GridBudget {
|
|
36
|
+
/** Grid cells left. */
|
|
37
|
+
cells: number;
|
|
38
|
+
/** Characters left for copies of spanned cells. */
|
|
39
|
+
copyChars: number;
|
|
40
|
+
}
|
|
41
|
+
/** A fresh budget for one document. */
|
|
42
|
+
export declare function createGridBudget(): GridBudget;
|
|
43
|
+
/**
|
|
44
|
+
* What a warning calls a table: its label when the label names it ("Table 2"), else
|
|
45
|
+
* `Table` and the bare number or the id.
|
|
46
|
+
*/
|
|
47
|
+
export declare function tableName(label: string | undefined, id?: string): string;
|
|
48
|
+
/** The `truncated-input` warning for a grid the budget cut, naming its table. */
|
|
49
|
+
export declare function truncatedGridMessage(name: string): string;
|
|
50
|
+
/** A built grid. */
|
|
51
|
+
export interface Grid {
|
|
52
|
+
headerRows: number;
|
|
53
|
+
rows: string[][];
|
|
54
|
+
/** The budget ran out while this grid was built: some copies are empty, or rows were dropped. */
|
|
55
|
+
truncated: boolean;
|
|
56
|
+
}
|
|
18
57
|
export interface SourceCell {
|
|
19
58
|
colspan: number;
|
|
20
59
|
header: boolean;
|
|
@@ -29,12 +68,10 @@ export interface SourceRow {
|
|
|
29
68
|
/** A span attribute value, clamped to the grid; anything unparseable is 1. */
|
|
30
69
|
export declare function spanValue(raw: string | null | undefined): number;
|
|
31
70
|
/**
|
|
32
|
-
* Build the grid
|
|
33
|
-
* cells; a row the source left short is padded so cells
|
|
34
|
-
* column.
|
|
71
|
+
* Build the grid, charging the document's `budget`. Header rows are head rows plus any
|
|
72
|
+
* leading row made only of header cells; a row the source left short is padded so cells
|
|
73
|
+
* never shift under the wrong column. Rows are kept in order while the grid, padded to
|
|
74
|
+
* its widest row so far, fits the cells left.
|
|
35
75
|
*/
|
|
36
|
-
export declare function buildGrid(sourceRows: SourceRow[]):
|
|
37
|
-
headerRows: number;
|
|
38
|
-
rows: string[][];
|
|
39
|
-
};
|
|
76
|
+
export declare function buildGrid(sourceRows: SourceRow[], budget: GridBudget): Grid;
|
|
40
77
|
//# sourceMappingURL=table-grid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-grid.d.ts","sourceRoot":"","sources":["../../src/model/table-grid.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"table-grid.d.ts","sourceRoot":"","sources":["../../src/model/table-grid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,UAAY,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,cAAc,UAAY,CAAC;AAExC,sGAAsG;AACtG,MAAM,WAAW,UAAU;IACzB,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,uCAAuC;AACvC,wBAAgB,gBAAgB,IAAI,UAAU,CAE7C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAExE;AAED,iFAAiF;AACjF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,oBAAoB;AACpB,MAAM,WAAW,IAAI;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;IACjB,iGAAiG;IACjG,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,kDAAkD;IAClD,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAIhE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CA2D3E"}
|
package/dist/model/table-grid.js
CHANGED
|
@@ -7,15 +7,45 @@
|
|
|
7
7
|
* the M−1 rows below, repeating its text: the value belongs to each position it covers,
|
|
8
8
|
* and keeping the source cell count would put values under the wrong headers.
|
|
9
9
|
* (pubmed-mcp-server#111)
|
|
10
|
+
*
|
|
11
|
+
* The grids of one document draw on one {@link GridBudget}: what the tables of a document
|
|
12
|
+
* may repeat and hold is capped where the grid is built, where a parser can still record
|
|
13
|
+
* what it cut.
|
|
10
14
|
* @module src/model/table-grid
|
|
11
15
|
*/
|
|
12
|
-
import { largest } from './extremes.js';
|
|
13
16
|
/**
|
|
14
17
|
* Widest grid a row may occupy, and the ceiling every declared span is clamped to. The
|
|
15
18
|
* widest real row observed is 15 columns; the cap turns `colspan="99999999"` into a
|
|
16
19
|
* bounded row instead of an unbounded allocation.
|
|
17
20
|
*/
|
|
18
21
|
export const MAX_TABLE_COLUMNS = 512;
|
|
22
|
+
/**
|
|
23
|
+
* Characters the tables of one document may repeat from a spanned cell into the other
|
|
24
|
+
* positions it covers. Past it, a covered position is empty; the cell's own position
|
|
25
|
+
* keeps its text. The most any corpus document repeats is about a thousand.
|
|
26
|
+
*/
|
|
27
|
+
export const MAX_SPAN_COPY_CHARS = 1_000_000;
|
|
28
|
+
/**
|
|
29
|
+
* Grid cells the tables of one document may hold together, padding included. Past it, a
|
|
30
|
+
* table's remaining rows are dropped. The largest corpus document holds under a thousand;
|
|
31
|
+
* a supplementary table of 500,000 rows by two columns fits whole.
|
|
32
|
+
*/
|
|
33
|
+
export const MAX_GRID_CELLS = 2_000_000;
|
|
34
|
+
/** A fresh budget for one document. */
|
|
35
|
+
export function createGridBudget() {
|
|
36
|
+
return { cells: MAX_GRID_CELLS, copyChars: MAX_SPAN_COPY_CHARS };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* What a warning calls a table: its label when the label names it ("Table 2"), else
|
|
40
|
+
* `Table` and the bare number or the id.
|
|
41
|
+
*/
|
|
42
|
+
export function tableName(label, id) {
|
|
43
|
+
return label && /^\p{L}/u.test(label) ? label : `Table ${label ?? id ?? ''}`.trim();
|
|
44
|
+
}
|
|
45
|
+
/** The `truncated-input` warning for a grid the budget cut, naming its table. */
|
|
46
|
+
export function truncatedGridMessage(name) {
|
|
47
|
+
return `${name} exceeds the document's table budget: copies of spanned cells past it are empty, and rows past it dropped`;
|
|
48
|
+
}
|
|
19
49
|
/** A span attribute value, clamped to the grid; anything unparseable is 1. */
|
|
20
50
|
export function spanValue(raw) {
|
|
21
51
|
const declared = Number.parseInt(raw ?? '', 10);
|
|
@@ -24,20 +54,31 @@ export function spanValue(raw) {
|
|
|
24
54
|
return Math.min(declared, MAX_TABLE_COLUMNS);
|
|
25
55
|
}
|
|
26
56
|
/**
|
|
27
|
-
* Build the grid
|
|
28
|
-
* cells; a row the source left short is padded so cells
|
|
29
|
-
* column.
|
|
57
|
+
* Build the grid, charging the document's `budget`. Header rows are head rows plus any
|
|
58
|
+
* leading row made only of header cells; a row the source left short is padded so cells
|
|
59
|
+
* never shift under the wrong column. Rows are kept in order while the grid, padded to
|
|
60
|
+
* its widest row so far, fits the cells left.
|
|
30
61
|
*/
|
|
31
|
-
export function buildGrid(sourceRows) {
|
|
62
|
+
export function buildGrid(sourceRows, budget) {
|
|
32
63
|
const parsed = [];
|
|
33
64
|
const carried = [];
|
|
65
|
+
let truncated = false;
|
|
66
|
+
/** A spanned cell's text for one more position it covers, while the budget lasts. */
|
|
67
|
+
const copy = (text) => {
|
|
68
|
+
if (text.length > budget.copyChars) {
|
|
69
|
+
truncated = true;
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
budget.copyChars -= text.length;
|
|
73
|
+
return text;
|
|
74
|
+
};
|
|
34
75
|
const drainCarried = (row, col) => {
|
|
35
76
|
let at = col;
|
|
36
77
|
while (at < MAX_TABLE_COLUMNS) {
|
|
37
78
|
const carry = carried[at];
|
|
38
79
|
if (!carry)
|
|
39
80
|
return at;
|
|
40
|
-
row[at] = carry.value;
|
|
81
|
+
row[at] = copy(carry.value);
|
|
41
82
|
carry.remaining -= 1;
|
|
42
83
|
if (carry.remaining <= 0)
|
|
43
84
|
carried[at] = undefined;
|
|
@@ -45,14 +86,15 @@ export function buildGrid(sourceRows) {
|
|
|
45
86
|
}
|
|
46
87
|
return at;
|
|
47
88
|
};
|
|
89
|
+
let width = 0;
|
|
48
90
|
for (const source of sourceRows) {
|
|
49
91
|
const row = [];
|
|
50
92
|
let col = 0;
|
|
51
93
|
for (const cell of source.cells) {
|
|
52
94
|
col = drainCarried(row, col);
|
|
53
|
-
const
|
|
54
|
-
for (let i = 0; i <
|
|
55
|
-
row[col] = cell.text;
|
|
95
|
+
const span = Math.min(cell.colspan, MAX_TABLE_COLUMNS - col);
|
|
96
|
+
for (let i = 0; i < span; i++) {
|
|
97
|
+
row[col] = i === 0 ? cell.text : copy(cell.text);
|
|
56
98
|
if (cell.rowspan > 1)
|
|
57
99
|
carried[col] = { remaining: cell.rowspan - 1, value: cell.text };
|
|
58
100
|
col += 1;
|
|
@@ -63,17 +105,23 @@ export function buildGrid(sourceRows) {
|
|
|
63
105
|
col = carried[col] ? drainCarried(row, col) : col + 1;
|
|
64
106
|
if (source.cells.length === 0)
|
|
65
107
|
continue;
|
|
108
|
+
const widest = Math.max(width, row.length);
|
|
109
|
+
if ((parsed.length + 1) * widest > budget.cells) {
|
|
110
|
+
truncated = true;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
width = widest;
|
|
66
114
|
for (let i = 0; i < row.length; i++)
|
|
67
115
|
row[i] ??= '';
|
|
68
116
|
parsed.push({ cells: row, header: source.inHead || source.cells.every((c) => c.header) });
|
|
69
117
|
}
|
|
70
|
-
|
|
118
|
+
budget.cells -= parsed.length * width;
|
|
71
119
|
for (const row of parsed)
|
|
72
120
|
while (row.cells.length < width)
|
|
73
121
|
row.cells.push('');
|
|
74
122
|
let headerRows = 0;
|
|
75
123
|
while (parsed[headerRows]?.header)
|
|
76
124
|
headerRows++;
|
|
77
|
-
return { headerRows, rows: parsed.map((row) => row.cells) };
|
|
125
|
+
return { headerRows, rows: parsed.map((row) => row.cells), truncated };
|
|
78
126
|
}
|
|
79
127
|
//# sourceMappingURL=table-grid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-grid.js","sourceRoot":"","sources":["../../src/model/table-grid.ts"],"names":[],"mappings":"AAAA
|
|
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M,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC;IACtC,KAAK,MAAM,GAAG,IAAI,MAAM;QAAE,OAAO,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK;YAAE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9E,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,OAAO,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM;QAAE,UAAU,EAAE,CAAC;IAChD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The characters a string ends with, found by walking back from its end. A
|
|
3
|
+
* pattern anchored only at the end (`/[.,;]+$/`) is tried from every position of a run it
|
|
4
|
+
* does not end, and each try reads to the end of the run, so its time grows with the
|
|
5
|
+
* square of the run. Walking back reads the run once.
|
|
6
|
+
* @module src/model/trailing
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* How many characters before `end` match `char`, a pattern for one character (without
|
|
10
|
+
* the `g` or `y` flag), counted back from `end`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function trailingLength(text: string, char: RegExp, end?: number): number;
|
|
13
|
+
/** `text` without the characters at its end that `char`, a pattern for one character, matches. */
|
|
14
|
+
export declare function trimTrailing(text: string, char: RegExp): string;
|
|
15
|
+
//# sourceMappingURL=trailing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trailing.d.ts","sourceRoot":"","sources":["../../src/model/trailing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,SAAc,GAAG,MAAM,CAIpF;AAED,kGAAkG;AAClG,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/D"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The characters a string ends with, found by walking back from its end. A
|
|
3
|
+
* pattern anchored only at the end (`/[.,;]+$/`) is tried from every position of a run it
|
|
4
|
+
* does not end, and each try reads to the end of the run, so its time grows with the
|
|
5
|
+
* square of the run. Walking back reads the run once.
|
|
6
|
+
* @module src/model/trailing
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* How many characters before `end` match `char`, a pattern for one character (without
|
|
10
|
+
* the `g` or `y` flag), counted back from `end`.
|
|
11
|
+
*/
|
|
12
|
+
export function trailingLength(text, char, end = text.length) {
|
|
13
|
+
let start = end;
|
|
14
|
+
while (start > 0 && char.test(text.charAt(start - 1)))
|
|
15
|
+
start--;
|
|
16
|
+
return end - start;
|
|
17
|
+
}
|
|
18
|
+
/** `text` without the characters at its end that `char`, a pattern for one character, matches. */
|
|
19
|
+
export function trimTrailing(text, char) {
|
|
20
|
+
return text.slice(0, text.length - trailingLength(text, char));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=trailing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trailing.js","sourceRoot":"","sources":["../../src/model/trailing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,IAAY,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM;IAC1E,IAAI,KAAK,GAAG,GAAG,CAAC;IAChB,OAAO,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAAE,KAAK,EAAE,CAAC;IAC/D,OAAO,GAAG,GAAG,KAAK,CAAC;AACrB,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,IAAY;IACrD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC"}
|
package/dist/parse.d.ts
CHANGED
|
@@ -6,8 +6,14 @@ export interface AutoParseOptions extends ParseOptions {
|
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
/** The format, when the caller knows it: skips detection. */
|
|
8
8
|
format?: SourceFormat;
|
|
9
|
+
/** Read no further page once the pages read hold more than this many operators (PDF). */
|
|
10
|
+
maxOperators?: number;
|
|
9
11
|
/** Read at most this many pages (PDF). */
|
|
10
12
|
maxPages?: number;
|
|
13
|
+
/** Read at most this many characters of text (PDF). */
|
|
14
|
+
maxTextChars?: number;
|
|
15
|
+
/** Read at most this many text items (PDF). */
|
|
16
|
+
maxTextItems?: number;
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
19
|
* Parse a document of any supported format. The format comes from the payload itself
|
package/dist/parse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAU,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhF,2EAA2E;AAC3E,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAU,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhF,2EAA2E;AAC3E,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,yFAAyF;IACzF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAsB,KAAK,CACzB,KAAK,EAAE,MAAM,GAAG,UAAU,EAC1B,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,WAAW,CAAC,CA6BtB"}
|