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/html/tables.d.ts
CHANGED
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
import { type Grid, type GridBudget } from '../model/table-grid.js';
|
|
8
8
|
/**
|
|
9
9
|
* Read a table into a grid, charging the document's `budget`; `cellText` renders one
|
|
10
|
-
* cell's content.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* cell's content. Its row groups are each section (`<thead>`, `<tbody>`, `<tfoot>`, or
|
|
11
|
+
* their `ltx_` classes), and each run of rows outside a section, a section nested in
|
|
12
|
+
* another included; footer sections come after the rest, in source order, as HTML shows
|
|
13
|
+
* them. With `boldHeaders`, a cell whose text is entirely bold counts as a header cell,
|
|
14
|
+
* so a leading all-bold row becomes the header: LaTeX tables mark their header row that
|
|
15
|
+
* way, with no `<th>`.
|
|
13
16
|
*/
|
|
14
17
|
export declare function readHtmlTable(table: Element, cellText: (cell: Element) => string, budget: GridBudget, options?: {
|
|
15
18
|
boldHeaders?: boolean;
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAIhB,MAAM,wBAAwB,CAAC;AA4BhC;;;;;;;;GAQG;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,CAsCN"}
|
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, rowspanValue, 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'];
|
|
@@ -18,19 +18,27 @@ function isCell(element) {
|
|
|
18
18
|
function isHead(element) {
|
|
19
19
|
return tagOf(element) === 'thead' || hasClass(element, 'ltx_thead');
|
|
20
20
|
}
|
|
21
|
+
function isFoot(element) {
|
|
22
|
+
return tagOf(element) === 'tfoot' || hasClass(element, 'ltx_tfoot');
|
|
23
|
+
}
|
|
21
24
|
/** A cell whose whole text is bold Markdown (`**Model**`, `**Active** **Params**`). */
|
|
22
25
|
function isBoldText(text) {
|
|
23
26
|
return /^\*\*[^*]+\*\*(?:\s*\*\*[^*]+\*\*)*$/.test(text);
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
26
29
|
* Read a table into a grid, charging the document's `budget`; `cellText` renders one
|
|
27
|
-
* cell's content.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
+
* cell's content. Its row groups are each section (`<thead>`, `<tbody>`, `<tfoot>`, or
|
|
31
|
+
* their `ltx_` classes), and each run of rows outside a section, a section nested in
|
|
32
|
+
* another included; footer sections come after the rest, in source order, as HTML shows
|
|
33
|
+
* them. With `boldHeaders`, a cell whose text is entirely bold counts as a header cell,
|
|
34
|
+
* so a leading all-bold row becomes the header: LaTeX tables mark their header row that
|
|
35
|
+
* way, with no `<th>`.
|
|
30
36
|
*/
|
|
31
37
|
export function readHtmlTable(table, cellText, budget, options = {}) {
|
|
32
|
-
const
|
|
33
|
-
const
|
|
38
|
+
const groups = [];
|
|
39
|
+
const feet = [];
|
|
40
|
+
const collect = (container, inHead, into) => {
|
|
41
|
+
let rows;
|
|
34
42
|
for (const child of childElements(container)) {
|
|
35
43
|
if (isRow(child)) {
|
|
36
44
|
const cells = childElements(child)
|
|
@@ -41,7 +49,7 @@ export function readHtmlTable(table, cellText, budget, options = {}) {
|
|
|
41
49
|
return {
|
|
42
50
|
colspan: spanValue(cell.getAttribute('colspan')),
|
|
43
51
|
header: markedHeader || (options.boldHeaders === true && (text === '' || isBoldText(text))),
|
|
44
|
-
rowspan:
|
|
52
|
+
rowspan: rowspanValue(cell.getAttribute('rowspan')),
|
|
45
53
|
text,
|
|
46
54
|
};
|
|
47
55
|
});
|
|
@@ -49,15 +57,20 @@ export function readHtmlTable(table, cellText, budget, options = {}) {
|
|
|
49
57
|
if (cells.every((cell) => cell.text === ''))
|
|
50
58
|
for (const cell of cells)
|
|
51
59
|
cell.header = false;
|
|
60
|
+
if (!rows) {
|
|
61
|
+
rows = [];
|
|
62
|
+
into.push(rows);
|
|
63
|
+
}
|
|
52
64
|
rows.push({ cells, inHead });
|
|
53
65
|
}
|
|
54
66
|
else if (SECTION_TAGS.has(tagOf(child)) ||
|
|
55
67
|
SECTION_CLASSES.some((c) => hasClass(child, c))) {
|
|
56
|
-
|
|
68
|
+
rows = undefined;
|
|
69
|
+
collect(child, inHead || isHead(child), isFoot(child) ? feet : into);
|
|
57
70
|
}
|
|
58
71
|
}
|
|
59
72
|
};
|
|
60
|
-
collect(table, false);
|
|
61
|
-
return buildGrid(
|
|
73
|
+
collect(table, false, groups);
|
|
74
|
+
return buildGrid([...groups, ...feet], budget);
|
|
62
75
|
}
|
|
63
76
|
//# 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,EACL,SAAS,
|
|
1
|
+
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../src/html/tables.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,SAAS,EAGT,YAAY,EAEZ,SAAS,GACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAE1D,MAAM,YAAY,GAAG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AAE,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAC/C,CAAC;gBACD,IAAI,GAAG,SAAS,CAAC;gBACjB,OAAO,CAAC,KAAK,EAAE,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IACF,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAC9B,OAAO,SAAS,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview arXiv IDs as the model holds them, in arXiv's preferred external form: a
|
|
3
|
+
* new-style `YYMM.NNNNN` or an old-style `archive/YYMMNNN` without the subject class an
|
|
4
|
+
* old-style ID may carry (`math.GT/0309136` → `math/0309136`), with any version the
|
|
5
|
+
* source prints kept (`2105.00001v2`). One grammar serves every format: the LaTeXML,
|
|
6
|
+
* HTML, and PDF references read the ID an `arXiv` label, an arxiv.org link, or an
|
|
7
|
+
* old-style form in an entry's text gives, the JATS and TEI references the ID an arxiv.org
|
|
8
|
+
* link names, the LaTeXML watermark and page URL read the paper's own ID here, and a field
|
|
9
|
+
* the source types as an arXiv ID (JATS `pub-id-type` or `ext-link-type` `arxiv`, TEI
|
|
10
|
+
* `<idno type="arXiv">`, HTML `citation_arxiv_id`) is read here too. An arXiv DataCite
|
|
11
|
+
* DOI (`10.48550/arXiv.2105.00001`) names the ID that fills one still empty.
|
|
12
|
+
* @module src/model/arxiv
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* `value` as an arXiv ID in the model's form, when the whole of it is one: a new-style ID
|
|
16
|
+
* whose month exists and whose number has the four digits of 0704–1412 or the five from
|
|
17
|
+
* 1501, or an old-style ID whose archive arXiv used before April 2007 and whose YYMM falls
|
|
18
|
+
* in 9107–0703, its subject class dropped. A version is kept, and must be `v1` or later.
|
|
19
|
+
* Undefined otherwise.
|
|
20
|
+
*/
|
|
21
|
+
export declare function arxivId(value: string): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* The arXiv ID a link to a paper names in its `/abs/` or `/pdf/` path on arxiv.org,
|
|
24
|
+
* ar5iv.org, or a subdomain of either (`https://arxiv.org/pdf/2105.00001v1.pdf` →
|
|
25
|
+
* `2105.00001v1`, `https://export.arxiv.org/abs/hep-th/9711200`), read as
|
|
26
|
+
* {@link arxivId} reads one. A link to any other host or path, or whose path holds more
|
|
27
|
+
* than the ID, names none.
|
|
28
|
+
*/
|
|
29
|
+
export declare function arxivFromUrl(url: string | undefined): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* A field the source types as an arXiv ID, as the model holds it: the ID read as
|
|
32
|
+
* {@link arxivId} reads one, or the one an arxiv.org link names, without an `arXiv`
|
|
33
|
+
* label or a bracketed subject class after it (`arXiv:math.GT/0309136v1 [math.GT]` →
|
|
34
|
+
* `math/0309136v1`, `https://arxiv.org/abs/2105.00001v3` → `2105.00001v3`). Undefined
|
|
35
|
+
* for anything else (`pending`, `n/a`, `hep-th/0805123`), so every format reads the same
|
|
36
|
+
* value from the same field.
|
|
37
|
+
*/
|
|
38
|
+
export declare function normalizeArxiv(value: string | undefined): string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The arXiv ID an arXiv DataCite DOI names: what follows `10.48550/arXiv.`, in any case,
|
|
41
|
+
* read as {@link arxivId} reads one (`10.48550/arXiv.2105.00001` → `2105.00001`,
|
|
42
|
+
* `10.48550/arxiv.hep-th/9711200` → `hep-th/9711200`). Any other DOI names none.
|
|
43
|
+
*/
|
|
44
|
+
export declare function arxivFromDoi(doi: string | undefined): string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* The arXiv ID of the page a LaTeXML render was served at: an arxiv.org or ar5iv
|
|
47
|
+
* `/html/` or `/abs/` URL (`https://ar5iv.labs.arxiv.org/html/math.GT/0309136` →
|
|
48
|
+
* `math/0309136`), read as {@link arxivId} reads one.
|
|
49
|
+
*/
|
|
50
|
+
export declare function arxivFromPageUrl(url: string | undefined): string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* The first arXiv ID in `text`, read as {@link arxivId} reads one: after an `arXiv`
|
|
53
|
+
* label in any case (`arXiv:hep-th/9711200`, `arXiv 1706.03762`), in an arxiv.org link
|
|
54
|
+
* (`https://arxiv.org/abs/2105.00001v3`), or bare in the old style (`…, hep-th/9711200.`).
|
|
55
|
+
* A bare new-style number (`1999.12345`) could be anything, so it needs the label or
|
|
56
|
+
* link. Each candidate is read once, so the text is read in one pass.
|
|
57
|
+
*/
|
|
58
|
+
export declare function arxivInText(text: string): string | undefined;
|
|
59
|
+
//# sourceMappingURL=arxiv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arxiv.d.ts","sourceRoot":"","sources":["../../src/model/arxiv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAmFH;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAoBzD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAExE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAG5E;AAKD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAIxE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAE5E;AAUD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQ5D"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview arXiv IDs as the model holds them, in arXiv's preferred external form: a
|
|
3
|
+
* new-style `YYMM.NNNNN` or an old-style `archive/YYMMNNN` without the subject class an
|
|
4
|
+
* old-style ID may carry (`math.GT/0309136` → `math/0309136`), with any version the
|
|
5
|
+
* source prints kept (`2105.00001v2`). One grammar serves every format: the LaTeXML,
|
|
6
|
+
* HTML, and PDF references read the ID an `arXiv` label, an arxiv.org link, or an
|
|
7
|
+
* old-style form in an entry's text gives, the JATS and TEI references the ID an arxiv.org
|
|
8
|
+
* link names, the LaTeXML watermark and page URL read the paper's own ID here, and a field
|
|
9
|
+
* the source types as an arXiv ID (JATS `pub-id-type` or `ext-link-type` `arxiv`, TEI
|
|
10
|
+
* `<idno type="arXiv">`, HTML `citation_arxiv_id`) is read here too. An arXiv DataCite
|
|
11
|
+
* DOI (`10.48550/arXiv.2105.00001`) names the ID that fills one still empty.
|
|
12
|
+
* @module src/model/arxiv
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The archives an old-style ID could name: every archive arXiv used before the April 2007
|
|
16
|
+
* scheme change (`econ`, `eess`, `q-fin`, and `stat` started later), so a path-like
|
|
17
|
+
* `and/1234567` is not read as one.
|
|
18
|
+
*/
|
|
19
|
+
const OLD_ARCHIVES = new Set([
|
|
20
|
+
'acc-phys',
|
|
21
|
+
'adap-org',
|
|
22
|
+
'alg-geom',
|
|
23
|
+
'ao-sci',
|
|
24
|
+
'astro-ph',
|
|
25
|
+
'atom-ph',
|
|
26
|
+
'bayes-an',
|
|
27
|
+
'chao-dyn',
|
|
28
|
+
'chem-ph',
|
|
29
|
+
'cmp-lg',
|
|
30
|
+
'comp-gas',
|
|
31
|
+
'cond-mat',
|
|
32
|
+
'cs',
|
|
33
|
+
'dg-ga',
|
|
34
|
+
'funct-an',
|
|
35
|
+
'gr-qc',
|
|
36
|
+
'hep-ex',
|
|
37
|
+
'hep-lat',
|
|
38
|
+
'hep-ph',
|
|
39
|
+
'hep-th',
|
|
40
|
+
'math',
|
|
41
|
+
'math-ph',
|
|
42
|
+
'mtrl-th',
|
|
43
|
+
'nlin',
|
|
44
|
+
'nucl-ex',
|
|
45
|
+
'nucl-th',
|
|
46
|
+
'patt-sol',
|
|
47
|
+
'physics',
|
|
48
|
+
'plasm-ph',
|
|
49
|
+
'q-alg',
|
|
50
|
+
'q-bio',
|
|
51
|
+
'quant-ph',
|
|
52
|
+
'solv-int',
|
|
53
|
+
'supr-con',
|
|
54
|
+
]);
|
|
55
|
+
/**
|
|
56
|
+
* An ID's shape before its parts are checked: a new-style `YYMM.NNNN(N)`, or an old-style
|
|
57
|
+
* archive, optional two-letter subject class, `/`, and `YYMMNNN`; then an optional
|
|
58
|
+
* version. A digit right after the number is not part of an ID.
|
|
59
|
+
*/
|
|
60
|
+
const ID_SHAPE = String.raw `(?:\d{4}\.\d{4,5}|[a-z]+(?:-[a-z]+)?(?:\.[a-z]{2})?\/\d{7})(?!\d)(?:v\d+)?`;
|
|
61
|
+
/**
|
|
62
|
+
* An exact ID, its parts captured: new-style YYMM and number, or archive, YYMM, and serial;
|
|
63
|
+
* then the version, which arXiv numbers from 1.
|
|
64
|
+
*/
|
|
65
|
+
const ID_PARTS = /^(?:(\d{4})\.(\d{4,5})|([a-z]+(?:-[a-z]+)?)(?:\.[A-Z]{2})?\/(\d{4})(\d{3}))(?:[vV]([1-9]\d*))?$/;
|
|
66
|
+
/**
|
|
67
|
+
* A field typed as an arXiv ID: an optional `arXiv` label, the ID or a link to it, and an
|
|
68
|
+
* optional bracketed subject class (`arXiv:1706.03762 [cs.CL]`, as arXiv prints a
|
|
69
|
+
* citation and Grobid keeps it). Anchored, and the body stops at whitespace or a bracket,
|
|
70
|
+
* so a value is read in one pass.
|
|
71
|
+
*/
|
|
72
|
+
const FIELD = /^(?:arxiv(?:\s*:\s*|\s+))?([^\s[\]]+)(?:\s*\[[^\]]*\])?$/i;
|
|
73
|
+
/**
|
|
74
|
+
* Where an ID starts in running text: after an `arXiv` label (`arXiv:`, `arXiv `,
|
|
75
|
+
* `arXiv :`), even one a PDF's text runs into the word before it (`preprintarXiv:`), after
|
|
76
|
+
* an arxiv.org `/abs/` or `/pdf/` path, or bare, where nothing that continues a word or a
|
|
77
|
+
* path comes before it. A bare ID counts only in the old style (see {@link arxivInText}).
|
|
78
|
+
*/
|
|
79
|
+
const IN_TEXT = new RegExp(String.raw `(?:arxiv(?:\s{0,8}:\s{0,8}|\s{1,8})|(?<![\w-])arxiv\.org\/(?:abs|pdf)\/|(?<![\w./-]))(${ID_SHAPE})`, 'gi');
|
|
80
|
+
/** A web link: its host, its path's first segment, and the rest of the path. */
|
|
81
|
+
const WEB_URL = /^(?:https?:)?\/\/([^/?#]*)\/(\w+)\/([^?#]*)/i;
|
|
82
|
+
/** arxiv.org or ar5iv.org, or a subdomain of either, with an optional port. */
|
|
83
|
+
const ARXIV_HOST = /(?:^|\.)(?:arxiv|ar5iv)\.org(?::\d+)?$/i;
|
|
84
|
+
/**
|
|
85
|
+
* `value` as an arXiv ID in the model's form, when the whole of it is one: a new-style ID
|
|
86
|
+
* whose month exists and whose number has the four digits of 0704–1412 or the five from
|
|
87
|
+
* 1501, or an old-style ID whose archive arXiv used before April 2007 and whose YYMM falls
|
|
88
|
+
* in 9107–0703, its subject class dropped. A version is kept, and must be `v1` or later.
|
|
89
|
+
* Undefined otherwise.
|
|
90
|
+
*/
|
|
91
|
+
export function arxivId(value) {
|
|
92
|
+
const parts = ID_PARTS.exec(value);
|
|
93
|
+
if (!parts)
|
|
94
|
+
return;
|
|
95
|
+
const [, newYymm, number, archive, oldYymm, serial, versionNumber] = parts;
|
|
96
|
+
const version = versionNumber === undefined ? '' : `v${versionNumber}`;
|
|
97
|
+
if (newYymm !== undefined && number !== undefined) {
|
|
98
|
+
const yymm = Number(newYymm);
|
|
99
|
+
const month = yymm % 100;
|
|
100
|
+
const digits = yymm >= 704 && yymm <= 1412 ? 4 : yymm >= 1501 ? 5 : 0;
|
|
101
|
+
return month >= 1 && month <= 12 && number.length === digits
|
|
102
|
+
? `${newYymm}.${number}${version}`
|
|
103
|
+
: undefined;
|
|
104
|
+
}
|
|
105
|
+
if (!archive || !oldYymm || !serial || !OLD_ARCHIVES.has(archive))
|
|
106
|
+
return;
|
|
107
|
+
const month = Number(oldYymm.slice(2));
|
|
108
|
+
const year = Number(oldYymm.slice(0, 2));
|
|
109
|
+
const inRange = year >= 91 ? Number(oldYymm) >= 9107 : Number(oldYymm) <= 703;
|
|
110
|
+
return month >= 1 && month <= 12 && inRange
|
|
111
|
+
? `${archive}/${oldYymm}${serial}${version}`
|
|
112
|
+
: undefined;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The arXiv ID a link to a paper names in its `/abs/` or `/pdf/` path on arxiv.org,
|
|
116
|
+
* ar5iv.org, or a subdomain of either (`https://arxiv.org/pdf/2105.00001v1.pdf` →
|
|
117
|
+
* `2105.00001v1`, `https://export.arxiv.org/abs/hep-th/9711200`), read as
|
|
118
|
+
* {@link arxivId} reads one. A link to any other host or path, or whose path holds more
|
|
119
|
+
* than the ID, names none.
|
|
120
|
+
*/
|
|
121
|
+
export function arxivFromUrl(url) {
|
|
122
|
+
return idInPath(url, /^(?:abs|pdf)$/i);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* A field the source types as an arXiv ID, as the model holds it: the ID read as
|
|
126
|
+
* {@link arxivId} reads one, or the one an arxiv.org link names, without an `arXiv`
|
|
127
|
+
* label or a bracketed subject class after it (`arXiv:math.GT/0309136v1 [math.GT]` →
|
|
128
|
+
* `math/0309136v1`, `https://arxiv.org/abs/2105.00001v3` → `2105.00001v3`). Undefined
|
|
129
|
+
* for anything else (`pending`, `n/a`, `hep-th/0805123`), so every format reads the same
|
|
130
|
+
* value from the same field.
|
|
131
|
+
*/
|
|
132
|
+
export function normalizeArxiv(value) {
|
|
133
|
+
const [, body = ''] = FIELD.exec(value?.trim() ?? '') ?? [];
|
|
134
|
+
return arxivId(body) ?? arxivFromUrl(body);
|
|
135
|
+
}
|
|
136
|
+
/** The prefix of the DataCite DOI arXiv registers for every paper, lowercased. */
|
|
137
|
+
const ARXIV_DOI = '10.48550/arxiv.';
|
|
138
|
+
/**
|
|
139
|
+
* The arXiv ID an arXiv DataCite DOI names: what follows `10.48550/arXiv.`, in any case,
|
|
140
|
+
* read as {@link arxivId} reads one (`10.48550/arXiv.2105.00001` → `2105.00001`,
|
|
141
|
+
* `10.48550/arxiv.hep-th/9711200` → `hep-th/9711200`). Any other DOI names none.
|
|
142
|
+
*/
|
|
143
|
+
export function arxivFromDoi(doi) {
|
|
144
|
+
return doi?.slice(0, ARXIV_DOI.length).toLowerCase() === ARXIV_DOI
|
|
145
|
+
? arxivId(doi.slice(ARXIV_DOI.length))
|
|
146
|
+
: undefined;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The arXiv ID of the page a LaTeXML render was served at: an arxiv.org or ar5iv
|
|
150
|
+
* `/html/` or `/abs/` URL (`https://ar5iv.labs.arxiv.org/html/math.GT/0309136` →
|
|
151
|
+
* `math/0309136`), read as {@link arxivId} reads one.
|
|
152
|
+
*/
|
|
153
|
+
export function arxivFromPageUrl(url) {
|
|
154
|
+
return idInPath(url, /^(?:abs|html)$/i);
|
|
155
|
+
}
|
|
156
|
+
/** The ID an arxiv.org or ar5iv.org URL names after a first path segment `kind` matches. */
|
|
157
|
+
function idInPath(url, kind) {
|
|
158
|
+
const [, host = '', segment = '', path = ''] = WEB_URL.exec(url?.trim() ?? '') ?? [];
|
|
159
|
+
return ARXIV_HOST.test(host) && kind.test(segment)
|
|
160
|
+
? arxivId(path.replace(/\/$/, '').replace(/\.pdf$/i, ''))
|
|
161
|
+
: undefined;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The first arXiv ID in `text`, read as {@link arxivId} reads one: after an `arXiv`
|
|
165
|
+
* label in any case (`arXiv:hep-th/9711200`, `arXiv 1706.03762`), in an arxiv.org link
|
|
166
|
+
* (`https://arxiv.org/abs/2105.00001v3`), or bare in the old style (`…, hep-th/9711200.`).
|
|
167
|
+
* A bare new-style number (`1999.12345`) could be anything, so it needs the label or
|
|
168
|
+
* link. Each candidate is read once, so the text is read in one pass.
|
|
169
|
+
*/
|
|
170
|
+
export function arxivInText(text) {
|
|
171
|
+
for (const { 0: whole, 1: candidate = '' } of text.matchAll(IN_TEXT)) {
|
|
172
|
+
const bare = whole.length === candidate.length;
|
|
173
|
+
if (bare && !candidate.includes('/'))
|
|
174
|
+
continue;
|
|
175
|
+
const id = arxivId(candidate);
|
|
176
|
+
if (id)
|
|
177
|
+
return id;
|
|
178
|
+
}
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=arxiv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arxiv.js","sourceRoot":"","sources":["../../src/model/arxiv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;GAIG;AACH,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC;IAChD,UAAU;IACV,UAAU;IACV,UAAU;IACV,QAAQ;IACR,UAAU;IACV,SAAS;IACT,UAAU;IACV,UAAU;IACV,SAAS;IACT,QAAQ;IACR,UAAU;IACV,UAAU;IACV,IAAI;IACJ,OAAO;IACP,UAAU;IACV,OAAO;IACP,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,SAAS;IACT,SAAS;IACT,MAAM;IACN,SAAS;IACT,SAAS;IACT,UAAU;IACV,SAAS;IACT,UAAU;IACV,OAAO;IACP,OAAO;IACP,UAAU;IACV,UAAU;IACV,UAAU;CACX,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAA,4EAA4E,CAAC;AAEx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AAO,EAAE,CAAC;IACpB,CAAC;IACD,OAAO;AACT,CAAC"}
|
package/dist/model/document.d.ts
CHANGED
|
@@ -36,19 +36,25 @@ export interface Author {
|
|
|
36
36
|
given?: string;
|
|
37
37
|
/** Display name as the source prints it, or `given family` when only parts are given. */
|
|
38
38
|
name: string;
|
|
39
|
-
/** Bare ORCID iD, e.g. `0000-0002-
|
|
39
|
+
/** Bare hyphenated ORCID iD with an uppercase check character, e.g. `0000-0002-1694-233X`. */
|
|
40
40
|
orcid?: string;
|
|
41
41
|
}
|
|
42
42
|
/** Identifiers the source carries for the work itself. */
|
|
43
43
|
export interface Identifiers {
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* arXiv ID without an `arXiv:` label or an old-style ID's subject class
|
|
46
|
+
* (`math.GT/0309136` → `math/0309136`), version kept when the source prints one. With no
|
|
47
|
+
* ID of its own, the one an arXiv DataCite DOI in `doi` names (`10.48550/arxiv.2105.00001`
|
|
48
|
+
* → `2105.00001`).
|
|
49
|
+
*/
|
|
45
50
|
arxiv?: string;
|
|
46
51
|
/** Lowercased DOI without a resolver prefix. */
|
|
47
52
|
doi?: string;
|
|
48
53
|
/** Publisher-assigned identifiers keyed by the source's own type label. */
|
|
49
54
|
other?: Record<string, string>;
|
|
50
|
-
/** PMC ID with
|
|
55
|
+
/** PMC ID with an uppercase `PMC` prefix, e.g. `PMC123456`. */
|
|
51
56
|
pmcid?: string;
|
|
57
|
+
/** PubMed ID: digits only, without a label or link. */
|
|
52
58
|
pmid?: string;
|
|
53
59
|
}
|
|
54
60
|
/** Journal or venue details. */
|
|
@@ -76,8 +82,9 @@ export interface License {
|
|
|
76
82
|
export interface RelatedWork {
|
|
77
83
|
/** Lowercased DOI without a resolver prefix. */
|
|
78
84
|
doi?: string;
|
|
79
|
-
/** PMC ID with
|
|
85
|
+
/** PMC ID with an uppercase `PMC` prefix, e.g. `PMC123456`. */
|
|
80
86
|
pmcid?: string;
|
|
87
|
+
/** PubMed ID: digits only, without a label or link. */
|
|
81
88
|
pmid?: string;
|
|
82
89
|
/**
|
|
83
90
|
* The relation as the source names it, e.g. JATS `@related-article-type`
|
|
@@ -228,6 +235,16 @@ export interface SupplementBlock {
|
|
|
228
235
|
export type Block = ParagraphBlock | ListBlock | TableBlock | FigureBlock | FormulaBlock | CodeBlock | QuoteBlock | BoxBlock | SupplementBlock;
|
|
229
236
|
/** One entry in the reference list. */
|
|
230
237
|
export interface Reference {
|
|
238
|
+
/**
|
|
239
|
+
* arXiv ID without the `arXiv:` prefix, version kept when the entry prints one
|
|
240
|
+
* (`2105.00001v2`). LaTeXML, HTML, and PDF references read it from an `arXiv` label, an
|
|
241
|
+
* arxiv.org `/abs/` or `/pdf/` link, or a bare old-style ID, dropping an old-style ID's
|
|
242
|
+
* subject class (`math.GT/0309136` → `math/0309136`). JATS and TEI references read it
|
|
243
|
+
* from a typed field (`pub-id-type` or `ext-link-type` `arxiv`, `<idno type="arXiv">`),
|
|
244
|
+
* else an arxiv.org link (`<ext-link>`, `<uri>`, `<ptr target>`). A reference with no ID
|
|
245
|
+
* of its own takes the one an arXiv DataCite DOI in `doi` names
|
|
246
|
+
* (`10.48550/arxiv.hep-th/9711200` → `hep-th/9711200`).
|
|
247
|
+
*/
|
|
231
248
|
arxiv?: string;
|
|
232
249
|
/** Author names as printed. */
|
|
233
250
|
authors?: string[];
|
|
@@ -236,7 +253,9 @@ export interface Reference {
|
|
|
236
253
|
id?: string;
|
|
237
254
|
/** Printed label without brackets or a trailing period: `12` for `[12]` or `12.`. */
|
|
238
255
|
label?: string;
|
|
256
|
+
/** PMC ID with an uppercase `PMC` prefix, e.g. `PMC123456`. */
|
|
239
257
|
pmcid?: string;
|
|
258
|
+
/** PubMed ID: digits only, without a label or link. */
|
|
240
259
|
pmid?: string;
|
|
241
260
|
/** Journal, book, or proceedings title. */
|
|
242
261
|
source?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/model/document.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,oDAAoD;AACpD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;AAE7D,iDAAiD;AACjD,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,iCAAiC;AACjC,MAAM,WAAW,MAAM;IACrB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,kFAAkF;IAClF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yFAAyF;IACzF,IAAI,EAAE,MAAM,CAAC;IACb,
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/model/document.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,oDAAoD;AACpD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;AAE7D,iDAAiD;AACjD,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,iCAAiC;AACjC,MAAM,WAAW,MAAM;IACrB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,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,CAAC;CAC1B;AAED,mCAAmC;AACnC,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,8EAA8E;IAC9E,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,WAAW,EAAE,WAAW,CAAC;IACzB,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wFAAwF;IACxF,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview PMC IDs, PMIDs, and ORCID iDs as the model holds them. A field the source
|
|
3
|
+
* types as one of these holds it in whatever form its producer wrote: a `PMCID:` or
|
|
4
|
+
* `PMID:` label, a link to PMC, PubMed, or orcid.org, a lowercase `pmc` or check
|
|
5
|
+
* character. Each normalizer reads that form to the canonical one, or to nothing when
|
|
6
|
+
* the value is not an identifier (`pending`, `n/a`, a PubMed search query). JATS, TEI,
|
|
7
|
+
* and HTML identifier fields normalize here, beside `normalizeDoi`.
|
|
8
|
+
* @module src/model/identifiers
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* A PMC ID field's value as the model holds it: `PMC` and the article number, whatever
|
|
12
|
+
* the case of the prefix, with or without it, without a `PMCID:` label, the PMC page URL
|
|
13
|
+
* around it, or the version PMC's versioned form adds (`pmc123456`, `123456`,
|
|
14
|
+
* `PMC123456.1`, `https://pmc.ncbi.nlm.nih.gov/articles/PMC123456/` → `PMC123456`).
|
|
15
|
+
* Undefined for anything else (`PMC`, `pending`, `n/a`).
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizePmcid(value: string | undefined): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* A PMID field's value as the model holds it: the PubMed number alone, without a `PMID:`
|
|
20
|
+
* label or the PubMed page URL around it (`PMID: 21491125`,
|
|
21
|
+
* `https://pubmed.ncbi.nlm.nih.gov/21491125/` → `21491125`). Undefined for anything else
|
|
22
|
+
* (`n/a`, a number holding letters, a PubMed search query).
|
|
23
|
+
*/
|
|
24
|
+
export declare function normalizePmid(value: string | undefined): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* An ORCID field's value as the model holds it: the bare hyphenated iD with its check
|
|
27
|
+
* character an uppercase `X`, without an `ORCID:` label, the orcid.org URL around it, or
|
|
28
|
+
* both (`https://orcid.org/0000-0002-1694-233x` → `0000-0002-1694-233X`). Undefined for
|
|
29
|
+
* anything else (15 characters, no hyphens, another host).
|
|
30
|
+
*/
|
|
31
|
+
export declare function normalizeOrcid(value: string | undefined): string | undefined;
|
|
32
|
+
//# sourceMappingURL=identifiers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifiers.d.ts","sourceRoot":"","sources":["../../src/model/identifiers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAG5E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAG3E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAG5E"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview PMC IDs, PMIDs, and ORCID iDs as the model holds them. A field the source
|
|
3
|
+
* types as one of these holds it in whatever form its producer wrote: a `PMCID:` or
|
|
4
|
+
* `PMID:` label, a link to PMC, PubMed, or orcid.org, a lowercase `pmc` or check
|
|
5
|
+
* character. Each normalizer reads that form to the canonical one, or to nothing when
|
|
6
|
+
* the value is not an identifier (`pending`, `n/a`, a PubMed search query). JATS, TEI,
|
|
7
|
+
* and HTML identifier fields normalize here, beside `normalizeDoi`.
|
|
8
|
+
* @module src/model/identifiers
|
|
9
|
+
*/
|
|
10
|
+
/** A PMC article page: NCBI's former `www.ncbi.nlm.nih.gov/pmc/articles/` and current `pmc.ncbi.nlm.nih.gov/articles/`. */
|
|
11
|
+
const PMC_URL = /^https?:\/\/(?:(?:www\.)?ncbi\.nlm\.nih\.gov\/pmc\/articles\/|pmc\.ncbi\.nlm\.nih\.gov\/articles\/)/i;
|
|
12
|
+
/** A PubMed record page: `pubmed.ncbi.nlm.nih.gov/` and the former `www.ncbi.nlm.nih.gov/pubmed/`. */
|
|
13
|
+
const PUBMED_URL = /^https?:\/\/(?:pubmed\.ncbi\.nlm\.nih\.gov\/|(?:www\.)?ncbi\.nlm\.nih\.gov\/pubmed\/)/i;
|
|
14
|
+
/** An ORCID record page, with or without its scheme. */
|
|
15
|
+
const ORCID_URL = /^(?:https?:\/\/)?(?:www\.)?orcid\.org\//i;
|
|
16
|
+
/**
|
|
17
|
+
* A PMC ID field's value as the model holds it: `PMC` and the article number, whatever
|
|
18
|
+
* the case of the prefix, with or without it, without a `PMCID:` label, the PMC page URL
|
|
19
|
+
* around it, or the version PMC's versioned form adds (`pmc123456`, `123456`,
|
|
20
|
+
* `PMC123456.1`, `https://pmc.ncbi.nlm.nih.gov/articles/PMC123456/` → `PMC123456`).
|
|
21
|
+
* Undefined for anything else (`PMC`, `pending`, `n/a`).
|
|
22
|
+
*/
|
|
23
|
+
export function normalizePmcid(value) {
|
|
24
|
+
const digits = /^(?:PMC)?(\d+)(?:\.\d+)?$/i.exec(stripLink(value, PMC_URL, /^PMCID:?\s*/i))?.[1];
|
|
25
|
+
return digits ? `PMC${digits}` : undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A PMID field's value as the model holds it: the PubMed number alone, without a `PMID:`
|
|
29
|
+
* label or the PubMed page URL around it (`PMID: 21491125`,
|
|
30
|
+
* `https://pubmed.ncbi.nlm.nih.gov/21491125/` → `21491125`). Undefined for anything else
|
|
31
|
+
* (`n/a`, a number holding letters, a PubMed search query).
|
|
32
|
+
*/
|
|
33
|
+
export function normalizePmid(value) {
|
|
34
|
+
const pmid = stripLink(value, PUBMED_URL, /^PMID:?\s*/i);
|
|
35
|
+
return /^\d+$/.test(pmid) ? pmid : undefined;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* An ORCID field's value as the model holds it: the bare hyphenated iD with its check
|
|
39
|
+
* character an uppercase `X`, without an `ORCID:` label, the orcid.org URL around it, or
|
|
40
|
+
* both (`https://orcid.org/0000-0002-1694-233x` → `0000-0002-1694-233X`). Undefined for
|
|
41
|
+
* anything else (15 characters, no hyphens, another host).
|
|
42
|
+
*/
|
|
43
|
+
export function normalizeOrcid(value) {
|
|
44
|
+
const orcid = stripLink(value, ORCID_URL, /^ORCID:?\s*/i);
|
|
45
|
+
return /^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/i.test(orcid) ? orcid.toUpperCase() : undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* `value` trimmed and without a `label` prefix that does not start a `link`, then without
|
|
49
|
+
* the `link` prefix and whatever follows the identifier in the link (a trailing `/`, a
|
|
50
|
+
* query, a fragment).
|
|
51
|
+
*/
|
|
52
|
+
function stripLink(value, link, label) {
|
|
53
|
+
const trimmed = (value ?? '').trim();
|
|
54
|
+
const unlabelled = link.test(trimmed) ? trimmed : trimmed.replace(label, '');
|
|
55
|
+
const url = link.exec(unlabelled);
|
|
56
|
+
if (!url)
|
|
57
|
+
return unlabelled;
|
|
58
|
+
const path = unlabelled.slice(url[0].length);
|
|
59
|
+
return path.slice(0, path.search(/[/?#]|$/));
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=identifiers.js.map
|
|
@@ -0,0 +1 @@
|
|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I,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC7E,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAClC,IAAI,CAAC,GAAG;QAAE,OAAO,UAAU,CAAC;IAC5B,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
package/dist/model/result.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview The value every parser returns. Expected failures (malformed input,
|
|
3
|
-
* the wrong format, an empty body, input over budget) are results, not exceptions;
|
|
4
|
-
* a missing optional peer dependency is a setup error and throws.
|
|
5
|
-
* @module src/model/result
|
|
6
|
-
*/
|
|
7
1
|
import type { ScholarlyDocument } from './document.js';
|
|
8
2
|
/** Why a parse produced no document. */
|
|
9
3
|
export type ParseFailureReason =
|
|
@@ -13,7 +7,10 @@ export type ParseFailureReason =
|
|
|
13
7
|
| 'wrong-format'
|
|
14
8
|
/** Parsed, but carried no article content. */
|
|
15
9
|
| 'empty'
|
|
16
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* A page standing in for the document: a captcha, bot check, or login wall, an
|
|
12
|
+
* access-denied or HTTP error page, or a redirect stub.
|
|
13
|
+
*/
|
|
17
14
|
| 'blocked'
|
|
18
15
|
/** Larger than the configured input budget. */
|
|
19
16
|
| 'too-large';
|
|
@@ -35,7 +32,13 @@ export interface ParseOptions {
|
|
|
35
32
|
/** Reject inputs larger than this many bytes. Defaults vary by format. */
|
|
36
33
|
maxInputBytes?: number;
|
|
37
34
|
}
|
|
38
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Build a successful result. An arXiv ID the article's identifiers or a reference leaves
|
|
37
|
+
* empty is filled from the arXiv DataCite DOI beside it (`10.48550/arXiv.2105.00001` →
|
|
38
|
+
* `2105.00001`), on copies, so the document passed in is never changed: every parser
|
|
39
|
+
* returns through here after setting the IDs its source types, prints, or links, so one
|
|
40
|
+
* of those always wins, and no other field changes.
|
|
41
|
+
*/
|
|
39
42
|
export declare function parsed(document: ScholarlyDocument): ParseResult;
|
|
40
43
|
/** Build a failed result. */
|
|
41
44
|
export declare function failed(reason: ParseFailureReason, message: string): ParseResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/model/result.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/model/result.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,wCAAwC;AACxC,MAAM,MAAM,kBAAkB;AAC5B,mFAAmF;AACjF,WAAW;AACb,8FAA8F;GAC5F,cAAc;AAChB,8CAA8C;GAC5C,OAAO;AACT;;;GAGG;GACD,SAAS;AACX,+CAA+C;GAC7C,WAAW,CAAC;AAEhB,sFAAsF;AACtF,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,8BAA8B;AAC9B,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,EAAE,iBAAiB,CAAC;IAAC,EAAE,EAAE,IAAI,CAAA;CAAE,GACzC;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC;AAEvC,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,iBAAiB,GAAG,WAAW,CAS/D;AASD,6BAA6B;AAC7B,wBAAgB,MAAM,CAAC,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,CAE/E;AAED,mGAAmG;AACnG,qBAAa,gBAAiB,SAAQ,KAAK;CAAG;AAE9C;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,WAAW,GAAG,WAAW,CAM3D;AAED,4DAA4D;AAC5D,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAMxF"}
|