scholarly-parse 0.2.0 → 0.2.2
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 +8 -0
- package/README.md +4 -4
- package/changelog/0.2.x/0.2.1.md +45 -0
- package/changelog/0.2.x/0.2.2.md +41 -0
- package/dist/detect.d.ts +2 -2
- package/dist/detect.js +2 -2
- package/dist/formats/html/metadata.d.ts +0 -8
- package/dist/formats/html/metadata.d.ts.map +1 -1
- package/dist/formats/html/metadata.js +18 -7
- package/dist/formats/html/metadata.js.map +1 -1
- package/dist/formats/html/parse.js +12 -15
- 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 +4 -18
- 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 +57 -28
- package/dist/formats/jats/blocks.js.map +1 -1
- package/dist/formats/jats/fragment.d.ts +8 -2
- package/dist/formats/jats/fragment.d.ts.map +1 -1
- package/dist/formats/jats/fragment.js +187 -7
- package/dist/formats/jats/fragment.js.map +1 -1
- package/dist/formats/jats/front.d.ts +0 -5
- package/dist/formats/jats/front.d.ts.map +1 -1
- package/dist/formats/jats/front.js +49 -34
- package/dist/formats/jats/front.js.map +1 -1
- package/dist/formats/jats/inline.d.ts +3 -3
- package/dist/formats/jats/inline.d.ts.map +1 -1
- package/dist/formats/jats/inline.js +96 -40
- package/dist/formats/jats/inline.js.map +1 -1
- package/dist/formats/jats/parse.js +33 -5
- package/dist/formats/jats/parse.js.map +1 -1
- package/dist/formats/jats/references.d.ts +0 -5
- package/dist/formats/jats/references.d.ts.map +1 -1
- package/dist/formats/jats/references.js +190 -54
- 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 +19 -10
- package/dist/formats/jats/tables.js.map +1 -1
- package/dist/formats/jats/text.d.ts +16 -0
- package/dist/formats/jats/text.d.ts.map +1 -1
- package/dist/formats/jats/text.js +77 -1
- package/dist/formats/jats/text.js.map +1 -1
- package/dist/formats/latexml/parse.d.ts +7 -1
- package/dist/formats/latexml/parse.d.ts.map +1 -1
- package/dist/formats/latexml/parse.js +46 -17
- package/dist/formats/latexml/parse.js.map +1 -1
- package/dist/formats/pdf/layout.d.ts +10 -1
- package/dist/formats/pdf/layout.d.ts.map +1 -1
- package/dist/formats/pdf/layout.js +266 -31
- package/dist/formats/pdf/layout.js.map +1 -1
- package/dist/formats/pdf/references.d.ts +0 -6
- package/dist/formats/pdf/references.d.ts.map +1 -1
- package/dist/formats/pdf/references.js +46 -7
- package/dist/formats/pdf/references.js.map +1 -1
- package/dist/formats/pdf/structure.d.ts.map +1 -1
- package/dist/formats/pdf/structure.js +6 -3
- package/dist/formats/pdf/structure.js.map +1 -1
- package/dist/formats/tei/parse.d.ts.map +1 -1
- package/dist/formats/tei/parse.js +54 -38
- package/dist/formats/tei/parse.js.map +1 -1
- package/dist/html/interstitial.d.ts +18 -7
- package/dist/html/interstitial.d.ts.map +1 -1
- package/dist/html/interstitial.js +37 -13
- package/dist/html/interstitial.js.map +1 -1
- package/dist/html/tables.d.ts +6 -3
- package/dist/html/tables.d.ts.map +1 -1
- package/dist/html/tables.js +23 -10
- package/dist/html/tables.js.map +1 -1
- package/dist/model/arxiv.d.ts +59 -0
- package/dist/model/arxiv.d.ts.map +1 -0
- package/dist/model/arxiv.js +181 -0
- package/dist/model/arxiv.js.map +1 -0
- package/dist/model/document.d.ts +23 -4
- package/dist/model/document.d.ts.map +1 -1
- package/dist/model/identifiers.d.ts +32 -0
- package/dist/model/identifiers.d.ts.map +1 -0
- package/dist/model/identifiers.js +61 -0
- package/dist/model/identifiers.js.map +1 -0
- package/dist/model/result.d.ts +11 -8
- package/dist/model/result.d.ts.map +1 -1
- package/dist/model/result.js +30 -2
- package/dist/model/result.js.map +1 -1
- package/dist/model/table-grid.d.ts +16 -7
- package/dist/model/table-grid.d.ts.map +1 -1
- package/dist/model/table-grid.js +56 -38
- package/dist/model/table-grid.js.map +1 -1
- package/dist/parse.d.ts +6 -2
- package/dist/parse.d.ts.map +1 -1
- package/dist/parse.js +2 -1
- package/dist/parse.js.map +1 -1
- package/dist/render/bare-url.d.ts +29 -0
- package/dist/render/bare-url.d.ts.map +1 -0
- package/dist/render/bare-url.js +207 -0
- package/dist/render/bare-url.js.map +1 -0
- package/dist/render/escape.d.ts +61 -9
- package/dist/render/escape.d.ts.map +1 -1
- package/dist/render/escape.js +223 -16
- package/dist/render/escape.js.map +1 -1
- package/dist/render/inline.d.ts +41 -55
- package/dist/render/inline.d.ts.map +1 -1
- package/dist/render/inline.js +748 -150
- package/dist/render/inline.js.map +1 -1
- package/dist/render/markdown.d.ts.map +1 -1
- package/dist/render/markdown.js +18 -6
- package/dist/render/markdown.js.map +1 -1
- package/dist/render/read-inline.d.ts +70 -0
- package/dist/render/read-inline.d.ts.map +1 -0
- package/dist/render/read-inline.js +376 -0
- package/dist/render/read-inline.js.map +1 -0
- package/dist/render/scan.d.ts +54 -0
- package/dist/render/scan.d.ts.map +1 -0
- package/dist/render/scan.js +145 -0
- package/dist/render/scan.js.map +1 -0
- package/dist/render/text.d.ts +3 -9
- package/dist/render/text.d.ts.map +1 -1
- package/dist/render/text.js +5 -160
- package/dist/render/text.js.map +1 -1
- package/dist/xml/ordered.d.ts.map +1 -1
- package/dist/xml/ordered.js +110 -14
- package/dist/xml/ordered.js.map +1 -1
- package/dist/xml/well-formed.d.ts +11 -3
- package/dist/xml/well-formed.d.ts.map +1 -1
- package/dist/xml/well-formed.js +25 -7
- package/dist/xml/well-formed.js.map +1 -1
- package/package.json +15 -11
package/dist/model/result.js
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The value every parser returns. Expected failures (malformed input,
|
|
3
|
+
* the wrong format, an empty body, a page standing in for the document, input over
|
|
4
|
+
* budget) are results, not exceptions;
|
|
5
|
+
* a missing optional peer dependency is a setup error and throws.
|
|
6
|
+
* @module src/model/result
|
|
7
|
+
*/
|
|
8
|
+
import { arxivFromDoi } from './arxiv.js';
|
|
9
|
+
/**
|
|
10
|
+
* Build a successful result. An arXiv ID the article's identifiers or a reference leaves
|
|
11
|
+
* empty is filled from the arXiv DataCite DOI beside it (`10.48550/arXiv.2105.00001` →
|
|
12
|
+
* `2105.00001`), on copies, so the document passed in is never changed: every parser
|
|
13
|
+
* returns through here after setting the IDs its source types, prints, or links, so one
|
|
14
|
+
* of those always wins, and no other field changes.
|
|
15
|
+
*/
|
|
2
16
|
export function parsed(document) {
|
|
3
|
-
|
|
17
|
+
const { identifiers } = document.metadata;
|
|
18
|
+
const filled = identifiers && withArxiv(identifiers);
|
|
19
|
+
const references = document.references.map(withArxiv);
|
|
20
|
+
const unchanged = filled === identifiers && references.every((ref, at) => ref === document.references[at]);
|
|
21
|
+
if (unchanged)
|
|
22
|
+
return { document, ok: true };
|
|
23
|
+
const metadata = filled ? { ...document.metadata, identifiers: filled } : document.metadata;
|
|
24
|
+
return { document: { ...document, metadata, references }, ok: true };
|
|
25
|
+
}
|
|
26
|
+
/** `holder`, or a copy with its empty `arxiv` set to the ID an arXiv DOI in `doi` names. */
|
|
27
|
+
function withArxiv(holder) {
|
|
28
|
+
if (holder.arxiv)
|
|
29
|
+
return holder;
|
|
30
|
+
const arxiv = arxivFromDoi(holder.doi);
|
|
31
|
+
return arxiv ? { ...holder, arxiv } : holder;
|
|
4
32
|
}
|
|
5
33
|
/** Build a failed result. */
|
|
6
34
|
export function failed(reason, message) {
|
package/dist/model/result.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/model/result.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/model/result.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,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,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;AACnD,CAAC;AAED,mGAAmG;AACnG,MAAM,OAAO,gBAAiB,SAAQ,KAAK;CAAG;AAE9C;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,KAAwB;IAC5C,IAAI,CAAC;QACH,OAAO,KAAK,EAAE,CAAC;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,4DAA4D;AAC5D,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,KAAiC;IAChE,IAAI,CAAC;QACH,OAAO,MAAM,KAAK,EAAE,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,KAAK,YAAY,gBAAgB;QAAE,MAAM,KAAK,CAAC;IACnD,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC,WAAW,EAAE,mCAAmC,MAAM,EAAE,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Source table rows → a rectangular grid of cell text with `colspan` and
|
|
3
|
-
* `rowspan` expanded. Every format's table reader maps its markup into
|
|
4
|
-
* lets this build the grid, so span handling is written once.
|
|
3
|
+
* `rowspan` expanded. Every format's table reader maps its markup into row groups of
|
|
4
|
+
* `SourceRow`s and lets this build the grid, so span handling is written once.
|
|
5
5
|
*
|
|
6
6
|
* A cell covering N columns fills N entries and one covering M rows fills its column in
|
|
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
|
-
* (pubmed-mcp-server#111)
|
|
9
|
+
* (pubmed-mcp-server#111) As in HTML, a rowspan never reaches past its row group, and a
|
|
10
|
+
* rowspan of 0 covers the rest of the group.
|
|
10
11
|
*
|
|
11
12
|
* The grids of one document draw on one {@link GridBudget}: what the tables of a document
|
|
12
13
|
* may repeat and hold is capped where the grid is built, where a parser can still record
|
|
@@ -57,6 +58,7 @@ export interface Grid {
|
|
|
57
58
|
export interface SourceCell {
|
|
58
59
|
colspan: number;
|
|
59
60
|
header: boolean;
|
|
61
|
+
/** Rows the cell covers, its own included; 0 covers the rest of its row group. */
|
|
60
62
|
rowspan: number;
|
|
61
63
|
text: string;
|
|
62
64
|
}
|
|
@@ -68,10 +70,17 @@ export interface SourceRow {
|
|
|
68
70
|
/** A span attribute value, clamped to the grid; anything unparseable is 1. */
|
|
69
71
|
export declare function spanValue(raw: string | null | undefined): number;
|
|
70
72
|
/**
|
|
71
|
-
*
|
|
73
|
+
* A `rowspan` attribute value: 0, read as HTML reads a non-negative integer, spans the
|
|
74
|
+
* rest of the row group; anything else is a {@link spanValue}.
|
|
75
|
+
*/
|
|
76
|
+
export declare function rowspanValue(raw: string | null | undefined): number;
|
|
77
|
+
/**
|
|
78
|
+
* Build the grid from a table's row groups, in the order they are shown, charging the
|
|
79
|
+
* document's `budget`. A rowspan ends with its group. Header rows are head rows plus any
|
|
72
80
|
* leading row made only of header cells; a row the source left short is padded so cells
|
|
73
|
-
* never shift under the wrong column
|
|
74
|
-
*
|
|
81
|
+
* never shift under the wrong column, and a row with no cells only counts among the rows
|
|
82
|
+
* a rowspan covers. Rows are kept in order while the grid, padded to its widest row so
|
|
83
|
+
* far, fits the cells left.
|
|
75
84
|
*/
|
|
76
|
-
export declare function buildGrid(
|
|
85
|
+
export declare function buildGrid(groups: SourceRow[][], budget: GridBudget): Grid;
|
|
77
86
|
//# 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;;;;;;;;;;;;;;;GAeG;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,kFAAkF;IAClF,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;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAEnE;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAqEzE"}
|
package/dist/model/table-grid.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Source table rows → a rectangular grid of cell text with `colspan` and
|
|
3
|
-
* `rowspan` expanded. Every format's table reader maps its markup into
|
|
4
|
-
* lets this build the grid, so span handling is written once.
|
|
3
|
+
* `rowspan` expanded. Every format's table reader maps its markup into row groups of
|
|
4
|
+
* `SourceRow`s and lets this build the grid, so span handling is written once.
|
|
5
5
|
*
|
|
6
6
|
* A cell covering N columns fills N entries and one covering M rows fills its column in
|
|
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
|
-
* (pubmed-mcp-server#111)
|
|
9
|
+
* (pubmed-mcp-server#111) As in HTML, a rowspan never reaches past its row group, and a
|
|
10
|
+
* rowspan of 0 covers the rest of the group.
|
|
10
11
|
*
|
|
11
12
|
* The grids of one document draw on one {@link GridBudget}: what the tables of a document
|
|
12
13
|
* may repeat and hold is capped where the grid is built, where a parser can still record
|
|
@@ -54,14 +55,24 @@ export function spanValue(raw) {
|
|
|
54
55
|
return Math.min(declared, MAX_TABLE_COLUMNS);
|
|
55
56
|
}
|
|
56
57
|
/**
|
|
57
|
-
*
|
|
58
|
+
* A `rowspan` attribute value: 0, read as HTML reads a non-negative integer, spans the
|
|
59
|
+
* rest of the row group; anything else is a {@link spanValue}.
|
|
60
|
+
*/
|
|
61
|
+
export function rowspanValue(raw) {
|
|
62
|
+
return Number.parseInt(raw ?? '', 10) === 0 ? 0 : spanValue(raw);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Build the grid from a table's row groups, in the order they are shown, charging the
|
|
66
|
+
* document's `budget`. A rowspan ends with its group. Header rows are head rows plus any
|
|
58
67
|
* leading row made only of header cells; a row the source left short is padded so cells
|
|
59
|
-
* never shift under the wrong column
|
|
60
|
-
*
|
|
68
|
+
* never shift under the wrong column, and a row with no cells only counts among the rows
|
|
69
|
+
* a rowspan covers. Rows are kept in order while the grid, padded to its widest row so
|
|
70
|
+
* far, fits the cells left.
|
|
61
71
|
*/
|
|
62
|
-
export function buildGrid(
|
|
72
|
+
export function buildGrid(groups, budget) {
|
|
63
73
|
const parsed = [];
|
|
64
|
-
|
|
74
|
+
/** Per column, the cell a rowspan carries down into it and the row of its group it ends before. */
|
|
75
|
+
let carried = [];
|
|
65
76
|
let truncated = false;
|
|
66
77
|
/** A spanned cell's text for one more position it covers, while the budget lasts. */
|
|
67
78
|
const copy = (text) => {
|
|
@@ -72,48 +83,55 @@ export function buildGrid(sourceRows, budget) {
|
|
|
72
83
|
budget.copyChars -= text.length;
|
|
73
84
|
return text;
|
|
74
85
|
};
|
|
75
|
-
|
|
86
|
+
/** Whether a rowspan covers column `col` at row `r` of the group. */
|
|
87
|
+
const covered = (col, r) => (carried[col]?.end ?? 0) > r;
|
|
88
|
+
/** Fill `row` with the carried cells from `col` on, up to the first column none covers. */
|
|
89
|
+
const drainCarried = (row, col, r) => {
|
|
76
90
|
let at = col;
|
|
77
91
|
while (at < MAX_TABLE_COLUMNS) {
|
|
78
92
|
const carry = carried[at];
|
|
79
|
-
if (!carry)
|
|
93
|
+
if (!carry || carry.end <= r)
|
|
80
94
|
return at;
|
|
81
95
|
row[at] = copy(carry.value);
|
|
82
|
-
carry.remaining -= 1;
|
|
83
|
-
if (carry.remaining <= 0)
|
|
84
|
-
carried[at] = undefined;
|
|
85
96
|
at += 1;
|
|
86
97
|
}
|
|
87
98
|
return at;
|
|
88
99
|
};
|
|
89
100
|
let width = 0;
|
|
90
|
-
for (const
|
|
91
|
-
|
|
92
|
-
let
|
|
93
|
-
for (const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
build: for (const group of groups) {
|
|
102
|
+
carried = [];
|
|
103
|
+
let r = -1;
|
|
104
|
+
for (const source of group) {
|
|
105
|
+
r += 1;
|
|
106
|
+
// Nothing is carried into a row with no cells: it would be dropped.
|
|
107
|
+
if (source.cells.length === 0)
|
|
108
|
+
continue;
|
|
109
|
+
const row = [];
|
|
110
|
+
let col = 0;
|
|
111
|
+
for (const cell of source.cells) {
|
|
112
|
+
col = drainCarried(row, col, r);
|
|
113
|
+
const span = Math.min(cell.colspan, MAX_TABLE_COLUMNS - col);
|
|
114
|
+
const end = cell.rowspan === 0 ? Number.POSITIVE_INFINITY : r + cell.rowspan;
|
|
115
|
+
for (let i = 0; i < span; i++) {
|
|
116
|
+
row[col] = i === 0 ? cell.text : copy(cell.text);
|
|
117
|
+
if (cell.rowspan !== 1)
|
|
118
|
+
carried[col] = { end, value: cell.text };
|
|
119
|
+
col += 1;
|
|
120
|
+
}
|
|
101
121
|
}
|
|
122
|
+
const rightmost = carried.findLastIndex((_, at) => covered(at, r));
|
|
123
|
+
while (col <= rightmost)
|
|
124
|
+
col = covered(col, r) ? drainCarried(row, col, r) : col + 1;
|
|
125
|
+
const widest = Math.max(width, row.length);
|
|
126
|
+
if ((parsed.length + 1) * widest > budget.cells) {
|
|
127
|
+
truncated = true;
|
|
128
|
+
break build;
|
|
129
|
+
}
|
|
130
|
+
width = widest;
|
|
131
|
+
for (let i = 0; i < row.length; i++)
|
|
132
|
+
row[i] ??= '';
|
|
133
|
+
parsed.push({ cells: row, header: source.inHead || source.cells.every((c) => c.header) });
|
|
102
134
|
}
|
|
103
|
-
const rightmost = carried.findLastIndex(Boolean);
|
|
104
|
-
while (col <= rightmost)
|
|
105
|
-
col = carried[col] ? drainCarried(row, col) : col + 1;
|
|
106
|
-
if (source.cells.length === 0)
|
|
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;
|
|
114
|
-
for (let i = 0; i < row.length; i++)
|
|
115
|
-
row[i] ??= '';
|
|
116
|
-
parsed.push({ cells: row, header: source.inHead || source.cells.every((c) => c.header) });
|
|
117
135
|
}
|
|
118
136
|
budget.cells -= parsed.length * width;
|
|
119
137
|
for (const row of parsed)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-grid.js","sourceRoot":"","sources":["../../src/model/table-grid.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"table-grid.js","sourceRoot":"","sources":["../../src/model/table-grid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAErC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AAUxC,uCAAuC;AACvC,MAAM,UAAU,gBAAgB;IAC9B,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,KAAyB,EAAE,EAAW;IAC9D,OAAO,KAAK,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,KAAK,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;AACtF,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,OAAO,GAAG,IAAI,2GAA2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I,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;QAC5F,CAAC;IACH,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"}
|
package/dist/parse.d.ts
CHANGED
|
@@ -2,7 +2,10 @@ import type { SourceFormat } from './model/document.js';
|
|
|
2
2
|
import { type ParseOptions, type ParseResult } from './model/result.js';
|
|
3
3
|
/** Options for {@link parse}. Each applies to the formats that read it. */
|
|
4
4
|
export interface AutoParseOptions extends ParseOptions {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Where the document was retrieved, so relative links and images resolve (HTML, LaTeXML).
|
|
7
|
+
* An arXiv HTML URL goes without a trailing slash; see `LatexmlOptions.baseUrl`.
|
|
8
|
+
*/
|
|
6
9
|
baseUrl?: string;
|
|
7
10
|
/** The format, when the caller knows it: skips detection. */
|
|
8
11
|
format?: SourceFormat;
|
|
@@ -19,7 +22,8 @@ export interface AutoParseOptions extends ParseOptions {
|
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
21
24
|
* Parse a document of any supported format. The format comes from the payload itself
|
|
22
|
-
* (see `detect`); a challenge
|
|
25
|
+
* (see `detect`); a challenge, access-denied, or HTTP error page is HTML and fails as
|
|
26
|
+
* `blocked`, and arXiv's page for a paper with no HTML fails as `empty`.
|
|
23
27
|
* PDF needs its bytes: PDF passed as a string fails as `wrong-format`.
|
|
24
28
|
*/
|
|
25
29
|
export declare function parse(input: string | Uint8Array, options?: AutoParseOptions): Promise<ParseResult>;
|
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
|
|
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;;;OAGG;IACH,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;IACtB,wFAAwF;IACxF,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,KAAK,CACzB,KAAK,EAAE,MAAM,GAAG,UAAU,EAC1B,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,WAAW,CAAC,CA6BtB"}
|
package/dist/parse.js
CHANGED
|
@@ -8,7 +8,8 @@ import { detect } from './detect.js';
|
|
|
8
8
|
import { failed } from './model/result.js';
|
|
9
9
|
/**
|
|
10
10
|
* Parse a document of any supported format. The format comes from the payload itself
|
|
11
|
-
* (see `detect`); a challenge
|
|
11
|
+
* (see `detect`); a challenge, access-denied, or HTTP error page is HTML and fails as
|
|
12
|
+
* `blocked`, and arXiv's page for a paper with no HTML fails as `empty`.
|
|
12
13
|
* PDF needs its bytes: PDF passed as a string fails as `wrong-format`.
|
|
13
14
|
*/
|
|
14
15
|
export async function parse(input, options = {}) {
|
package/dist/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,MAAM,EAAuC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,MAAM,EAAuC,MAAM,mBAAmB,CAAC;AAuBhF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,KAA0B,EAC1B,OAAO,GAAqB,EAAE;IAE9B,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,GAAG,SAAS,EAAE,GAAG,OAAO,CAAC;IACjF,MAAM,MAAM,GAAG,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC;IACpE,MAAM,OAAO,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,CAAC;IACxE,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,MAAM;YACT,OAAO,CAAC,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC5E,KAAK,KAAK;YACR,OAAO,CAAC,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC1E,KAAK,SAAS;YACZ,OAAO,CAAC,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACnF,KAAK,MAAM;YACT,OAAO,CAAC,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC7E,KAAK,KAAK;YACR,IAAI,OAAO,KAAK,KAAK,QAAQ;gBAC3B,OAAO,MAAM,CACX,cAAc,EACd,qEAAqE,CACtE,CAAC;YACJ,OAAO,CAAC,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE;gBAC9D,GAAG,MAAM;gBACT,GAAG,SAAS;aACb,CAAC,CAAC;QACL,KAAK,SAAS;YACZ,OAAO,MAAM,CACX,cAAc,EACd,kFAAkF,CACnF,CAAC;IACN,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Where GFM links a bare URL (an autolink literal: `https://…`, `http://…`,
|
|
3
|
+
* `www.…`) in Markdown, read as micromark's GFM extension reads it, so the escaping can
|
|
4
|
+
* tell whether a backslash or a marker it writes would land inside one.
|
|
5
|
+
* @module src/render/bare-url
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* True when a URL starts at `start` of `text`: `http://` or `https://` not right after an
|
|
9
|
+
* ASCII letter, or `www.` at the start or after a space, `(`, `[`, `]`, or an emphasis
|
|
10
|
+
* marker. Brackets around the start are the caller's to weigh: GFM links no bare URL
|
|
11
|
+
* inside a link's text.
|
|
12
|
+
*/
|
|
13
|
+
export declare function bareUrlStarts(text: string, start: number): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The end of the URL GFM links at `start` of `text`, where {@link bareUrlStarts} holds,
|
|
16
|
+
* or -1 when what follows is no domain. The URL runs to a space or `<`, less any trailing
|
|
17
|
+
* punctuation, an unbalanced `)`, or a character reference (`&`) at its end. Reading
|
|
18
|
+
* stops at `limit`: a URL that runs on past it ends at `limit + 1`. Each character is read
|
|
19
|
+
* a bounded number of times.
|
|
20
|
+
*/
|
|
21
|
+
export declare function bareUrlEnd(text: string, start: number, limit?: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* The end of the autolink literal GFM forms around `at` in `text`, outside link text — a
|
|
24
|
+
* bare URL ({@link bareUrlEnd}) or an email address — or -1 when none holds it. A literal
|
|
25
|
+
* starts no earlier than `from`, where the last one GFM formed ends, and no earlier than
|
|
26
|
+
* the space or `<` before `at`, so only that stretch is read back.
|
|
27
|
+
*/
|
|
28
|
+
export declare function literalEnd(text: string, at: number, from?: number): number;
|
|
29
|
+
//# sourceMappingURL=bare-url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bare-url.d.ts","sourceRoot":"","sources":["../../src/render/bare-url.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAQlE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,SAAc,GAAG,MAAM,CA8CnF;AAaD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,SAAI,GAAG,MAAM,CAiBrE"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Where GFM links a bare URL (an autolink literal: `https://…`, `http://…`,
|
|
3
|
+
* `www.…`) in Markdown, read as micromark's GFM extension reads it, so the escaping can
|
|
4
|
+
* tell whether a backslash or a marker it writes would land inside one.
|
|
5
|
+
* @module src/render/bare-url
|
|
6
|
+
*/
|
|
7
|
+
/** Characters a URL gives back to the text around it when only such characters follow, up to a space, `<`, or the end. */
|
|
8
|
+
const TRAIL = new Set(['!', '"', "'", ')', '*', ',', '.', ':', ';', '?', '_', '~']);
|
|
9
|
+
/** Characters at which a URL's path checks whether the rest is a trail it gives back. */
|
|
10
|
+
const PATH_TRAIL = new Set([...TRAIL, '&', '<', ']']);
|
|
11
|
+
/** Characters after which `www.` can start a URL. */
|
|
12
|
+
const BEFORE_WWW = new Set(['', '(', '*', '_', '[', ']', '~', ' ', '\t', '\n', '\r']);
|
|
13
|
+
const PROTOCOL = /https?:\/\//iy;
|
|
14
|
+
const WWW = /www\./iy;
|
|
15
|
+
const ASCII_ALPHA = /^[A-Za-z]$/;
|
|
16
|
+
const SPACE = /^\s$/;
|
|
17
|
+
const PUNCTUATION = /^[\p{P}\p{S}]$/u;
|
|
18
|
+
/**
|
|
19
|
+
* True when a URL starts at `start` of `text`: `http://` or `https://` not right after an
|
|
20
|
+
* ASCII letter, or `www.` at the start or after a space, `(`, `[`, `]`, or an emphasis
|
|
21
|
+
* marker. Brackets around the start are the caller's to weigh: GFM links no bare URL
|
|
22
|
+
* inside a link's text.
|
|
23
|
+
*/
|
|
24
|
+
export function bareUrlStarts(text, start) {
|
|
25
|
+
const before = text.charAt(start - 1);
|
|
26
|
+
if (/[Hh]/.test(text.charAt(start))) {
|
|
27
|
+
PROTOCOL.lastIndex = start;
|
|
28
|
+
return !ASCII_ALPHA.test(before) && PROTOCOL.test(text);
|
|
29
|
+
}
|
|
30
|
+
WWW.lastIndex = start;
|
|
31
|
+
return BEFORE_WWW.has(before) && WWW.test(text) && WWW.lastIndex < text.length;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The end of the URL GFM links at `start` of `text`, where {@link bareUrlStarts} holds,
|
|
35
|
+
* or -1 when what follows is no domain. The URL runs to a space or `<`, less any trailing
|
|
36
|
+
* punctuation, an unbalanced `)`, or a character reference (`&`) at its end. Reading
|
|
37
|
+
* stops at `limit`: a URL that runs on past it ends at `limit + 1`. Each character is read
|
|
38
|
+
* a bounded number of times.
|
|
39
|
+
*/
|
|
40
|
+
export function bareUrlEnd(text, start, limit = text.length) {
|
|
41
|
+
PROTOCOL.lastIndex = start;
|
|
42
|
+
const protocol = PROTOCOL.test(text);
|
|
43
|
+
const domainStart = protocol ? PROTOCOL.lastIndex : start;
|
|
44
|
+
if (protocol) {
|
|
45
|
+
const first = text.charAt(domainStart);
|
|
46
|
+
if (!first || first < ' ' || first === '\u007f' || SPACE.test(first) || PUNCTUATION.test(first))
|
|
47
|
+
return -1;
|
|
48
|
+
}
|
|
49
|
+
const trail = trailReader(text);
|
|
50
|
+
let at = domainStart;
|
|
51
|
+
let seen = false;
|
|
52
|
+
let underscoreInLast = false;
|
|
53
|
+
let underscoreInLastButOne = false;
|
|
54
|
+
for (let c = text.charAt(at);; c = text.charAt(at)) {
|
|
55
|
+
if (c === '.' || c === '_') {
|
|
56
|
+
if (trail(at))
|
|
57
|
+
break;
|
|
58
|
+
if (c === '_') {
|
|
59
|
+
underscoreInLast = true;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
underscoreInLastButOne = underscoreInLast;
|
|
63
|
+
underscoreInLast = false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if (!c || SPACE.test(c) || (c !== '-' && PUNCTUATION.test(c))) {
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
seen = true;
|
|
71
|
+
}
|
|
72
|
+
at++;
|
|
73
|
+
}
|
|
74
|
+
if (!seen || underscoreInLast || underscoreInLastButOne)
|
|
75
|
+
return -1;
|
|
76
|
+
let opened = 0;
|
|
77
|
+
let closed = 0;
|
|
78
|
+
for (let c = text.charAt(at); c && !SPACE.test(c); c = text.charAt(at)) {
|
|
79
|
+
if (at === limit)
|
|
80
|
+
return PATH_TRAIL.has(c) && trail(at) ? at : limit + 1;
|
|
81
|
+
if (c === '(') {
|
|
82
|
+
opened++;
|
|
83
|
+
}
|
|
84
|
+
else if (c === ')' && closed < opened) {
|
|
85
|
+
closed++;
|
|
86
|
+
}
|
|
87
|
+
else if (PATH_TRAIL.has(c)) {
|
|
88
|
+
if (trail(at))
|
|
89
|
+
break;
|
|
90
|
+
if (c === ')')
|
|
91
|
+
closed++;
|
|
92
|
+
}
|
|
93
|
+
at++;
|
|
94
|
+
}
|
|
95
|
+
return at;
|
|
96
|
+
}
|
|
97
|
+
/** Where a bare URL can start, for a search. */
|
|
98
|
+
const URL_START = /https?:\/\/|www\./gi;
|
|
99
|
+
/** A character an email literal's local part holds. */
|
|
100
|
+
const ATEXT = /^[A-Za-z0-9+\-._]$/;
|
|
101
|
+
/** A character an email literal's domain holds, besides its dots. */
|
|
102
|
+
const DOMAIN = /^[A-Za-z0-9\-_]$/;
|
|
103
|
+
const ALPHANUMERIC = /^[A-Za-z0-9]$/;
|
|
104
|
+
/**
|
|
105
|
+
* The end of the autolink literal GFM forms around `at` in `text`, outside link text — a
|
|
106
|
+
* bare URL ({@link bareUrlEnd}) or an email address — or -1 when none holds it. A literal
|
|
107
|
+
* starts no earlier than `from`, where the last one GFM formed ends, and no earlier than
|
|
108
|
+
* the space or `<` before `at`, so only that stretch is read back.
|
|
109
|
+
*/
|
|
110
|
+
export function literalEnd(text, at, from = 0) {
|
|
111
|
+
let wordStart = at;
|
|
112
|
+
while (wordStart > from &&
|
|
113
|
+
!SPACE.test(text.charAt(wordStart - 1)) &&
|
|
114
|
+
text.charAt(wordStart - 1) !== '<')
|
|
115
|
+
wordStart--;
|
|
116
|
+
const start = new RegExp(URL_START);
|
|
117
|
+
start.lastIndex = wordStart;
|
|
118
|
+
for (let found = start.exec(text); found && found.index <= at; found = start.exec(text)) {
|
|
119
|
+
if (!bareUrlStarts(text, found.index))
|
|
120
|
+
continue;
|
|
121
|
+
const end = bareUrlEnd(text, found.index);
|
|
122
|
+
if (end > at)
|
|
123
|
+
return end;
|
|
124
|
+
if (end !== -1)
|
|
125
|
+
start.lastIndex = end;
|
|
126
|
+
}
|
|
127
|
+
return emailEnd(text, at, wordStart);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The end of the email literal GFM forms around `at`, starting no earlier than `from`, or
|
|
131
|
+
* -1: a local part of {@link ATEXT} characters after anything but such a character or a
|
|
132
|
+
* `/`, an `@`, and a domain of {@link DOMAIN} characters holding a dot that an alphanumeric
|
|
133
|
+
* follows, ending in a letter.
|
|
134
|
+
*/
|
|
135
|
+
function emailEnd(text, at, from) {
|
|
136
|
+
let atSign = at;
|
|
137
|
+
while (ATEXT.test(text.charAt(atSign)))
|
|
138
|
+
atSign++;
|
|
139
|
+
if (text.charAt(atSign) !== '@') {
|
|
140
|
+
let domain = at;
|
|
141
|
+
while (domain > from &&
|
|
142
|
+
(DOMAIN.test(text.charAt(domain - 1)) || text.charAt(domain - 1) === '.'))
|
|
143
|
+
domain--;
|
|
144
|
+
if (domain === from || text.charAt(domain - 1) !== '@')
|
|
145
|
+
return -1;
|
|
146
|
+
atSign = domain - 1;
|
|
147
|
+
}
|
|
148
|
+
let local = atSign;
|
|
149
|
+
while (local > from && ATEXT.test(text.charAt(local - 1)))
|
|
150
|
+
local--;
|
|
151
|
+
const before = text.charAt(local - 1);
|
|
152
|
+
if (local === atSign || before === '/' || ATEXT.test(before))
|
|
153
|
+
return -1;
|
|
154
|
+
let end = atSign + 1;
|
|
155
|
+
let dot = false;
|
|
156
|
+
for (;;) {
|
|
157
|
+
const c = text.charAt(end);
|
|
158
|
+
if (c === '.' && ALPHANUMERIC.test(text.charAt(end + 1)))
|
|
159
|
+
dot = true;
|
|
160
|
+
else if (!DOMAIN.test(c))
|
|
161
|
+
break;
|
|
162
|
+
end++;
|
|
163
|
+
}
|
|
164
|
+
return dot && /[A-Za-z]/.test(text.charAt(end - 1)) && end > at ? end : -1;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* A reader of `text` answering whether the characters from a position on are a trail a URL
|
|
168
|
+
* gives back: trailing punctuation and character references up to a space, `<`, or the
|
|
169
|
+
* end, or a `]` before one of those or `(` or `[`. A trail that fails fails from every
|
|
170
|
+
* position up to where it failed, so that stretch is not read again.
|
|
171
|
+
*/
|
|
172
|
+
function trailReader(text) {
|
|
173
|
+
let failedBefore = -1;
|
|
174
|
+
return (from) => {
|
|
175
|
+
if (from < failedBefore)
|
|
176
|
+
return false;
|
|
177
|
+
let at = from;
|
|
178
|
+
for (;;) {
|
|
179
|
+
const c = text.charAt(at);
|
|
180
|
+
if (TRAIL.has(c)) {
|
|
181
|
+
at++;
|
|
182
|
+
}
|
|
183
|
+
else if (c === '&') {
|
|
184
|
+
let end = at + 1;
|
|
185
|
+
while (ASCII_ALPHA.test(text.charAt(end)))
|
|
186
|
+
end++;
|
|
187
|
+
if (end === at + 1 || text.charAt(end) !== ';')
|
|
188
|
+
break;
|
|
189
|
+
at = end + 1;
|
|
190
|
+
}
|
|
191
|
+
else if (c === ']') {
|
|
192
|
+
at++;
|
|
193
|
+
const next = text.charAt(at);
|
|
194
|
+
if (!next || next === '(' || next === '[' || SPACE.test(next))
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
if (!c || c === '<' || SPACE.test(c))
|
|
199
|
+
return true;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
failedBefore = at;
|
|
204
|
+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