scholarly-parse 0.1.1 → 0.2.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 +8 -0
- package/README.md +6 -6
- package/changelog/0.2.x/0.2.0.md +43 -0
- package/changelog/0.2.x/0.2.1.md +45 -0
- package/dist/detect.d.ts +3 -2
- package/dist/detect.d.ts.map +1 -1
- package/dist/detect.js +40 -18
- package/dist/detect.js.map +1 -1
- package/dist/formats/html/blocks.d.ts +3 -2
- package/dist/formats/html/blocks.d.ts.map +1 -1
- package/dist/formats/html/blocks.js +116 -114
- package/dist/formats/html/blocks.js.map +1 -1
- package/dist/formats/html/context.d.ts +17 -0
- package/dist/formats/html/context.d.ts.map +1 -1
- package/dist/formats/html/context.js +4 -0
- package/dist/formats/html/context.js.map +1 -1
- package/dist/formats/html/inline.d.ts +7 -6
- package/dist/formats/html/inline.d.ts.map +1 -1
- package/dist/formats/html/inline.js +30 -28
- package/dist/formats/html/inline.js.map +1 -1
- package/dist/formats/html/metadata.d.ts +7 -10
- package/dist/formats/html/metadata.d.ts.map +1 -1
- package/dist/formats/html/metadata.js +59 -23
- 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 +207 -59
- 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 +15 -31
- package/dist/formats/html/references.js.map +1 -1
- package/dist/formats/html/subtree.d.ts +112 -0
- package/dist/formats/html/subtree.d.ts.map +1 -0
- package/dist/formats/html/subtree.js +316 -0
- package/dist/formats/html/subtree.js.map +1 -0
- package/dist/formats/jats/blocks.d.ts +4 -1
- package/dist/formats/jats/blocks.d.ts.map +1 -1
- package/dist/formats/jats/blocks.js +176 -59
- 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 +55 -33
- 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 +118 -43
- package/dist/formats/jats/inline.js.map +1 -1
- package/dist/formats/jats/parse.js +43 -6
- 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 +158 -50
- package/dist/formats/jats/references.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/blocks.d.ts.map +1 -1
- package/dist/formats/latexml/blocks.js +42 -31
- 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/inline.d.ts +4 -3
- package/dist/formats/latexml/inline.d.ts.map +1 -1
- package/dist/formats/latexml/inline.js +10 -11
- package/dist/formats/latexml/inline.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 +61 -25
- package/dist/formats/latexml/parse.js.map +1 -1
- package/dist/formats/pdf/inline.d.ts +16 -0
- package/dist/formats/pdf/inline.d.ts.map +1 -1
- package/dist/formats/pdf/inline.js +45 -3
- package/dist/formats/pdf/inline.js.map +1 -1
- package/dist/formats/pdf/layout.d.ts.map +1 -1
- package/dist/formats/pdf/layout.js +32 -1
- package/dist/formats/pdf/layout.js.map +1 -1
- package/dist/formats/pdf/lines.d.ts +7 -1
- package/dist/formats/pdf/lines.d.ts.map +1 -1
- package/dist/formats/pdf/lines.js +17 -1
- package/dist/formats/pdf/lines.js.map +1 -1
- package/dist/formats/pdf/load.d.ts +15 -5
- package/dist/formats/pdf/load.d.ts.map +1 -1
- package/dist/formats/pdf/load.js +17 -5
- package/dist/formats/pdf/load.js.map +1 -1
- package/dist/formats/pdf/parse.d.ts +5 -0
- package/dist/formats/pdf/parse.d.ts.map +1 -1
- package/dist/formats/pdf/parse.js +9 -10
- package/dist/formats/pdf/parse.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 +44 -8
- package/dist/formats/pdf/references.js.map +1 -1
- package/dist/formats/pdf/structure.d.ts +3 -1
- package/dist/formats/pdf/structure.d.ts.map +1 -1
- package/dist/formats/pdf/structure.js +89 -33
- package/dist/formats/pdf/structure.js.map +1 -1
- package/dist/formats/tei/inline.d.ts +4 -1
- package/dist/formats/tei/inline.d.ts.map +1 -1
- package/dist/formats/tei/inline.js +6 -3
- 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 +50 -30
- package/dist/formats/tei/parse.js.map +1 -1
- package/dist/html/dom.d.ts +34 -7
- package/dist/html/dom.d.ts.map +1 -1
- package/dist/html/dom.js +459 -1
- package/dist/html/dom.js.map +1 -1
- package/dist/html/math.d.ts +7 -0
- package/dist/html/math.d.ts.map +1 -0
- package/dist/html/math.js +34 -0
- package/dist/html/math.js.map +1 -0
- package/dist/model/arxiv.d.ts +51 -0
- package/dist/model/arxiv.d.ts.map +1 -0
- package/dist/model/arxiv.js +167 -0
- package/dist/model/arxiv.js.map +1 -0
- package/dist/model/document.d.ts +22 -4
- package/dist/model/document.d.ts.map +1 -1
- package/dist/model/doi.d.ts +21 -3
- package/dist/model/doi.d.ts.map +1 -1
- package/dist/model/doi.js +45 -3
- package/dist/model/doi.js.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/input.d.ts +2 -0
- package/dist/model/input.d.ts.map +1 -1
- package/dist/model/input.js +2 -1
- package/dist/model/input.js.map +1 -1
- package/dist/model/limits.d.ts +14 -0
- package/dist/model/limits.d.ts.map +1 -0
- package/dist/model/limits.js +14 -0
- package/dist/model/limits.js.map +1 -0
- package/dist/model/section-ids.d.ts +23 -2
- package/dist/model/section-ids.d.ts.map +1 -1
- package/dist/model/section-ids.js +38 -13
- package/dist/model/section-ids.js.map +1 -1
- package/dist/parse.d.ts +6 -1
- package/dist/parse.d.ts.map +1 -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 +59 -8
- package/dist/render/escape.d.ts.map +1 -1
- package/dist/render/escape.js +225 -17
- package/dist/render/escape.js.map +1 -1
- package/dist/render/inline.d.ts +53 -9
- package/dist/render/inline.d.ts.map +1 -1
- package/dist/render/inline.js +789 -23
- package/dist/render/inline.js.map +1 -1
- package/dist/render/markdown.d.ts +14 -9
- package/dist/render/markdown.d.ts.map +1 -1
- package/dist/render/markdown.js +39 -18
- 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/sections.d.ts +9 -5
- package/dist/render/sections.d.ts.map +1 -1
- package/dist/render/sections.js +20 -15
- package/dist/render/sections.js.map +1 -1
- package/dist/render/text.d.ts +3 -4
- package/dist/render/text.d.ts.map +1 -1
- package/dist/render/text.js +5 -182
- package/dist/render/text.js.map +1 -1
- package/dist/xml/mathml.d.ts +16 -12
- package/dist/xml/mathml.d.ts.map +1 -1
- package/dist/xml/mathml.js +110 -40
- package/dist/xml/mathml.js.map +1 -1
- package/dist/xml/ordered.d.ts +0 -6
- package/dist/xml/ordered.d.ts.map +1 -1
- package/dist/xml/ordered.js +111 -20
- 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 +12 -8
|
@@ -0,0 +1,167 @@
|
|
|
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 LaTeXML watermark and page URL read the
|
|
8
|
+
* paper's own ID here, and a field the source types as an arXiv ID (JATS `pub-id-type`
|
|
9
|
+
* `arxiv`, TEI `<idno type="arXiv">`, HTML `citation_arxiv_id`) is read here too.
|
|
10
|
+
* @module src/model/arxiv
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The archives an old-style ID could name: every archive arXiv used before the April 2007
|
|
14
|
+
* scheme change (`econ`, `eess`, `q-fin`, and `stat` started later), so a path-like
|
|
15
|
+
* `and/1234567` is not read as one.
|
|
16
|
+
*/
|
|
17
|
+
const OLD_ARCHIVES = new Set([
|
|
18
|
+
'acc-phys',
|
|
19
|
+
'adap-org',
|
|
20
|
+
'alg-geom',
|
|
21
|
+
'ao-sci',
|
|
22
|
+
'astro-ph',
|
|
23
|
+
'atom-ph',
|
|
24
|
+
'bayes-an',
|
|
25
|
+
'chao-dyn',
|
|
26
|
+
'chem-ph',
|
|
27
|
+
'cmp-lg',
|
|
28
|
+
'comp-gas',
|
|
29
|
+
'cond-mat',
|
|
30
|
+
'cs',
|
|
31
|
+
'dg-ga',
|
|
32
|
+
'funct-an',
|
|
33
|
+
'gr-qc',
|
|
34
|
+
'hep-ex',
|
|
35
|
+
'hep-lat',
|
|
36
|
+
'hep-ph',
|
|
37
|
+
'hep-th',
|
|
38
|
+
'math',
|
|
39
|
+
'math-ph',
|
|
40
|
+
'mtrl-th',
|
|
41
|
+
'nlin',
|
|
42
|
+
'nucl-ex',
|
|
43
|
+
'nucl-th',
|
|
44
|
+
'patt-sol',
|
|
45
|
+
'physics',
|
|
46
|
+
'plasm-ph',
|
|
47
|
+
'q-alg',
|
|
48
|
+
'q-bio',
|
|
49
|
+
'quant-ph',
|
|
50
|
+
'solv-int',
|
|
51
|
+
'supr-con',
|
|
52
|
+
]);
|
|
53
|
+
/**
|
|
54
|
+
* An ID's shape before its parts are checked: a new-style `YYMM.NNNN(N)`, or an old-style
|
|
55
|
+
* archive, optional two-letter subject class, `/`, and `YYMMNNN`; then an optional
|
|
56
|
+
* version. A digit right after the number is not part of an ID.
|
|
57
|
+
*/
|
|
58
|
+
const ID_SHAPE = String.raw `(?:\d{4}\.\d{4,5}|[a-z]+(?:-[a-z]+)?(?:\.[a-z]{2})?\/\d{7})(?!\d)(?:v\d+)?`;
|
|
59
|
+
/**
|
|
60
|
+
* An exact ID, its parts captured: new-style YYMM and number, or archive, YYMM, and serial;
|
|
61
|
+
* then the version, which arXiv numbers from 1.
|
|
62
|
+
*/
|
|
63
|
+
const ID_PARTS = /^(?:(\d{4})\.(\d{4,5})|([a-z]+(?:-[a-z]+)?)(?:\.[A-Z]{2})?\/(\d{4})(\d{3}))(?:[vV]([1-9]\d*))?$/;
|
|
64
|
+
/**
|
|
65
|
+
* A field typed as an arXiv ID: an optional `arXiv` label, the ID or a link to it, and an
|
|
66
|
+
* optional bracketed subject class (`arXiv:1706.03762 [cs.CL]`, as arXiv prints a
|
|
67
|
+
* citation and Grobid keeps it). Anchored, and the body stops at whitespace or a bracket,
|
|
68
|
+
* so a value is read in one pass.
|
|
69
|
+
*/
|
|
70
|
+
const FIELD = /^(?:arxiv(?:\s*:\s*|\s+))?([^\s[\]]+)(?:\s*\[[^\]]*\])?$/i;
|
|
71
|
+
/**
|
|
72
|
+
* Where an ID starts in running text: after an `arXiv` label (`arXiv:`, `arXiv `,
|
|
73
|
+
* `arXiv :`), even one a PDF's text runs into the word before it (`preprintarXiv:`), after
|
|
74
|
+
* an arxiv.org `/abs/` or `/pdf/` path, or bare, where nothing that continues a word or a
|
|
75
|
+
* path comes before it. A bare ID counts only in the old style (see {@link arxivInText}).
|
|
76
|
+
*/
|
|
77
|
+
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');
|
|
78
|
+
/** A web link: its host, its path's first segment, and the rest of the path. */
|
|
79
|
+
const WEB_URL = /^(?:https?:)?\/\/([^/?#]*)\/(\w+)\/([^?#]*)/i;
|
|
80
|
+
/** arxiv.org or ar5iv.org, or a subdomain of either, with an optional port. */
|
|
81
|
+
const ARXIV_HOST = /(?:^|\.)(?:arxiv|ar5iv)\.org(?::\d+)?$/i;
|
|
82
|
+
/**
|
|
83
|
+
* `value` as an arXiv ID in the model's form, when the whole of it is one: a new-style ID
|
|
84
|
+
* whose month exists and whose number has the four digits of 0704–1412 or the five from
|
|
85
|
+
* 1501, or an old-style ID whose archive arXiv used before April 2007 and whose YYMM falls
|
|
86
|
+
* in 9107–0703, its subject class dropped. A version is kept, and must be `v1` or later.
|
|
87
|
+
* Undefined otherwise.
|
|
88
|
+
*/
|
|
89
|
+
export function arxivId(value) {
|
|
90
|
+
const parts = ID_PARTS.exec(value);
|
|
91
|
+
if (!parts)
|
|
92
|
+
return;
|
|
93
|
+
const [, newYymm, number, archive, oldYymm, serial, versionNumber] = parts;
|
|
94
|
+
const version = versionNumber === undefined ? '' : `v${versionNumber}`;
|
|
95
|
+
if (newYymm !== undefined && number !== undefined) {
|
|
96
|
+
const yymm = Number(newYymm);
|
|
97
|
+
const month = yymm % 100;
|
|
98
|
+
const digits = yymm >= 704 && yymm <= 1412 ? 4 : yymm >= 1501 ? 5 : 0;
|
|
99
|
+
return month >= 1 && month <= 12 && number.length === digits
|
|
100
|
+
? `${newYymm}.${number}${version}`
|
|
101
|
+
: undefined;
|
|
102
|
+
}
|
|
103
|
+
if (!archive || !oldYymm || !serial || !OLD_ARCHIVES.has(archive))
|
|
104
|
+
return;
|
|
105
|
+
const month = Number(oldYymm.slice(2));
|
|
106
|
+
const year = Number(oldYymm.slice(0, 2));
|
|
107
|
+
const inRange = year >= 91 ? Number(oldYymm) >= 9107 : Number(oldYymm) <= 703;
|
|
108
|
+
return month >= 1 && month <= 12 && inRange
|
|
109
|
+
? `${archive}/${oldYymm}${serial}${version}`
|
|
110
|
+
: undefined;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The arXiv ID a link to a paper names in its `/abs/` or `/pdf/` path on arxiv.org,
|
|
114
|
+
* ar5iv.org, or a subdomain of either (`https://arxiv.org/pdf/2105.00001v1.pdf` →
|
|
115
|
+
* `2105.00001v1`, `https://export.arxiv.org/abs/hep-th/9711200`), read as
|
|
116
|
+
* {@link arxivId} reads one. A link to any other host or path, or whose path holds more
|
|
117
|
+
* than the ID, names none.
|
|
118
|
+
*/
|
|
119
|
+
export function arxivFromUrl(url) {
|
|
120
|
+
return idInPath(url, /^(?:abs|pdf)$/i);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A field the source types as an arXiv ID, as the model holds it: the ID read as
|
|
124
|
+
* {@link arxivId} reads one, or the one an arxiv.org link names, without an `arXiv`
|
|
125
|
+
* label or a bracketed subject class after it (`arXiv:math.GT/0309136v1 [math.GT]` →
|
|
126
|
+
* `math/0309136v1`, `https://arxiv.org/abs/2105.00001v3` → `2105.00001v3`). Undefined
|
|
127
|
+
* for anything else (`pending`, `n/a`, `hep-th/0805123`), so every format reads the same
|
|
128
|
+
* value from the same field.
|
|
129
|
+
*/
|
|
130
|
+
export function normalizeArxiv(value) {
|
|
131
|
+
const [, body = ''] = FIELD.exec(value?.trim() ?? '') ?? [];
|
|
132
|
+
return arxivId(body) ?? arxivFromUrl(body);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The arXiv ID of the page a LaTeXML render was served at: an arxiv.org or ar5iv
|
|
136
|
+
* `/html/` or `/abs/` URL (`https://ar5iv.labs.arxiv.org/html/math.GT/0309136` →
|
|
137
|
+
* `math/0309136`), read as {@link arxivId} reads one.
|
|
138
|
+
*/
|
|
139
|
+
export function arxivFromPageUrl(url) {
|
|
140
|
+
return idInPath(url, /^(?:abs|html)$/i);
|
|
141
|
+
}
|
|
142
|
+
/** The ID an arxiv.org or ar5iv.org URL names after a first path segment `kind` matches. */
|
|
143
|
+
function idInPath(url, kind) {
|
|
144
|
+
const [, host = '', segment = '', path = ''] = WEB_URL.exec(url?.trim() ?? '') ?? [];
|
|
145
|
+
return ARXIV_HOST.test(host) && kind.test(segment)
|
|
146
|
+
? arxivId(path.replace(/\/$/, '').replace(/\.pdf$/i, ''))
|
|
147
|
+
: undefined;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The first arXiv ID in `text`, read as {@link arxivId} reads one: after an `arXiv`
|
|
151
|
+
* label in any case (`arXiv:hep-th/9711200`, `arXiv 1706.03762`), in an arxiv.org link
|
|
152
|
+
* (`https://arxiv.org/abs/2105.00001v3`), or bare in the old style (`…, hep-th/9711200.`).
|
|
153
|
+
* A bare new-style number (`1999.12345`) could be anything, so it needs the label or
|
|
154
|
+
* link. Each candidate is read once, so the text is read in one pass.
|
|
155
|
+
*/
|
|
156
|
+
export function arxivInText(text) {
|
|
157
|
+
for (const { 0: whole, 1: candidate = '' } of text.matchAll(IN_TEXT)) {
|
|
158
|
+
const bare = whole.length === candidate.length;
|
|
159
|
+
if (bare && !candidate.includes('/'))
|
|
160
|
+
continue;
|
|
161
|
+
const id = arxivId(candidate);
|
|
162
|
+
if (id)
|
|
163
|
+
return id;
|
|
164
|
+
}
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=arxiv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arxiv.js","sourceRoot":"","sources":["../../src/model/arxiv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;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;AAExG;;;GAGG;AACH,MAAM,QAAQ,GACZ,iGAAiG,CAAC;AAEpG;;;;;GAKG;AACH,MAAM,KAAK,GAAG,2DAA2D,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,OAAO,GAAG,IAAI,MAAM,CACxB,MAAM,CAAC,GAAG,CAAA,yFAAyF,QAAQ,GAAG,EAC9G,IAAI,CACL,CAAC;AAEF,gFAAgF;AAChF,MAAM,OAAO,GAAG,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I,CAAC,IAAI,CAAC,OAAO,CAAC;QAChD,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACzD,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,KAAK,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,GAAG,EAAE,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,CAAC;QAC/C,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,SAAS;QAC/C,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;QAC9B,IAAI,EAAE;YAAE,OAAO,EAAE,CAAC;IACpB,CAAC;IACD,OAAO;AACT,CAAC"}
|
package/dist/model/document.d.ts
CHANGED
|
@@ -36,19 +36,23 @@ 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.
|
|
47
|
+
*/
|
|
45
48
|
arxiv?: string;
|
|
46
49
|
/** Lowercased DOI without a resolver prefix. */
|
|
47
50
|
doi?: string;
|
|
48
51
|
/** Publisher-assigned identifiers keyed by the source's own type label. */
|
|
49
52
|
other?: Record<string, string>;
|
|
50
|
-
/** PMC ID with
|
|
53
|
+
/** PMC ID with an uppercase `PMC` prefix, e.g. `PMC123456`. */
|
|
51
54
|
pmcid?: string;
|
|
55
|
+
/** PubMed ID: digits only, without a label or link. */
|
|
52
56
|
pmid?: string;
|
|
53
57
|
}
|
|
54
58
|
/** Journal or venue details. */
|
|
@@ -76,8 +80,9 @@ export interface License {
|
|
|
76
80
|
export interface RelatedWork {
|
|
77
81
|
/** Lowercased DOI without a resolver prefix. */
|
|
78
82
|
doi?: string;
|
|
79
|
-
/** PMC ID with
|
|
83
|
+
/** PMC ID with an uppercase `PMC` prefix, e.g. `PMC123456`. */
|
|
80
84
|
pmcid?: string;
|
|
85
|
+
/** PubMed ID: digits only, without a label or link. */
|
|
81
86
|
pmid?: string;
|
|
82
87
|
/**
|
|
83
88
|
* The relation as the source names it, e.g. JATS `@related-article-type`
|
|
@@ -228,14 +233,23 @@ export interface SupplementBlock {
|
|
|
228
233
|
export type Block = ParagraphBlock | ListBlock | TableBlock | FigureBlock | FormulaBlock | CodeBlock | QuoteBlock | BoxBlock | SupplementBlock;
|
|
229
234
|
/** One entry in the reference list. */
|
|
230
235
|
export interface Reference {
|
|
236
|
+
/**
|
|
237
|
+
* arXiv ID without the `arXiv:` prefix, version kept when the entry prints one
|
|
238
|
+
* (`2105.00001v2`). LaTeXML, HTML, and PDF references read it from an `arXiv` label, an
|
|
239
|
+
* arxiv.org `/abs/` or `/pdf/` link, or a bare old-style ID, dropping an old-style ID's
|
|
240
|
+
* subject class (`math.GT/0309136` → `math/0309136`).
|
|
241
|
+
*/
|
|
231
242
|
arxiv?: string;
|
|
232
243
|
/** Author names as printed. */
|
|
233
244
|
authors?: string[];
|
|
245
|
+
/** Lowercased DOI without a resolver prefix, whatever form `text` prints it in. */
|
|
234
246
|
doi?: string;
|
|
235
247
|
id?: string;
|
|
236
248
|
/** Printed label without brackets or a trailing period: `12` for `[12]` or `12.`. */
|
|
237
249
|
label?: string;
|
|
250
|
+
/** PMC ID with an uppercase `PMC` prefix, e.g. `PMC123456`. */
|
|
238
251
|
pmcid?: string;
|
|
252
|
+
/** PubMed ID: digits only, without a label or link. */
|
|
239
253
|
pmid?: string;
|
|
240
254
|
/** Journal, book, or proceedings title. */
|
|
241
255
|
source?: string;
|
|
@@ -249,6 +263,10 @@ export interface Reference {
|
|
|
249
263
|
export interface Footnote {
|
|
250
264
|
id?: string;
|
|
251
265
|
label?: string;
|
|
266
|
+
/**
|
|
267
|
+
* The note as inline Markdown. A note is text in every format: block content the source
|
|
268
|
+
* puts in one (a list's items, a formula, code, a figure's caption) is written into it.
|
|
269
|
+
*/
|
|
252
270
|
text: string;
|
|
253
271
|
}
|
|
254
272
|
/** A condition worth reporting that did not stop the parse. */
|
|
@@ -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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AM,CAAC;IACf;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED,+DAA+D;AAC/D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,sCAAsC;AACtC,MAAM,MAAM,gBAAgB,GACxB,SAAS,GACT,UAAU,GACV,aAAa,GACb,mBAAmB,GACnB,qBAAqB,GACrB,kBAAkB,GAClB,oBAAoB,GACpB,oBAAoB,GACpB,iBAAiB,GACjB,iBAAiB,CAAC;AAEtB,0BAA0B;AAC1B,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,YAAY,CAAC;IACtB,oEAAoE;IACpE,SAAS,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAChD,QAAQ,EAAE,YAAY,EAAE,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"}
|
package/dist/model/doi.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* @fileoverview DOIs as the model holds them: a field's DOI without its resolver or `doi:`
|
|
3
|
+
* prefix, and the first DOI in running text, read in one pass over its runs of DOI
|
|
4
|
+
* characters without the punctuation, quotes, and brackets that close it. JATS and TEI
|
|
5
|
+
* identifier fields and HTML `<meta>` tags normalize here; PDF, HTML, and LaTeXML
|
|
6
|
+
* references read the DOI in an entry's text here, and a PDF's first page reads the DOI
|
|
7
|
+
* a label introduces.
|
|
5
8
|
* @module src/model/doi
|
|
6
9
|
*/
|
|
10
|
+
/**
|
|
11
|
+
* A DOI field's value as the model holds it: without a resolver (`https://doi.org/`,
|
|
12
|
+
* `http://dx.doi.org/`) or `doi:` prefix in any case, without the marks closing it
|
|
13
|
+
* ({@link trimDoi}), lowercased. Undefined for a value that is not a DOI (`n/a`, `10.`,
|
|
14
|
+
* `10.1234/`).
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalizeDoi(value: string | undefined): string | undefined;
|
|
7
17
|
/**
|
|
8
18
|
* The first DOI in `text` whose run of DOI characters ends at whitespace, the end of the
|
|
9
19
|
* text, or a quote closing one opened right before it, without the marks closing it
|
|
@@ -12,6 +22,14 @@
|
|
|
12
22
|
* that ends at a quote costs one pass, not one per `10.` inside it.
|
|
13
23
|
*/
|
|
14
24
|
export declare function doiInText(text: string): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The first DOI in `text` that a label introduces, read as {@link doiInText} reads one:
|
|
27
|
+
* its run must follow `doi.org/`, `doi:`, or `doi` and a space (in any case), optionally
|
|
28
|
+
* with one opening quote between (`doi: "10.1234/abc"`, `DOI 10.1234/abc`). A DOI with no
|
|
29
|
+
* label before it is passed over. The label is looked for in a bounded window before each
|
|
30
|
+
* run, so the text is still read in one pass.
|
|
31
|
+
*/
|
|
32
|
+
export declare function labeledDoiInText(text: string): string | undefined;
|
|
15
33
|
/**
|
|
16
34
|
* `doi` without the punctuation, quotes, and brackets closing it, or undefined when that
|
|
17
35
|
* leaves no suffix. A `)` or `]` goes only when nothing before it in the DOI opens it, so
|
package/dist/model/doi.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doi.d.ts","sourceRoot":"","sources":["../../src/model/doi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"doi.d.ts","sourceRoot":"","sources":["../../src/model/doi.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAuBH;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAI1E;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE1D;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIjE;AAcD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgBvD"}
|
package/dist/model/doi.js
CHANGED
|
@@ -1,13 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* @fileoverview DOIs as the model holds them: a field's DOI without its resolver or `doi:`
|
|
3
|
+
* prefix, and the first DOI in running text, read in one pass over its runs of DOI
|
|
4
|
+
* characters without the punctuation, quotes, and brackets that close it. JATS and TEI
|
|
5
|
+
* identifier fields and HTML `<meta>` tags normalize here; PDF, HTML, and LaTeXML
|
|
6
|
+
* references read the DOI in an entry's text here, and a PDF's first page reads the DOI
|
|
7
|
+
* a label introduces.
|
|
5
8
|
* @module src/model/doi
|
|
6
9
|
*/
|
|
7
10
|
/** A DOI's `10.` prefix and every character after it that a DOI can hold. */
|
|
8
11
|
const DOI_RUN = /\b10\.\d{4,9}\/[^\s"<>]+/g;
|
|
9
12
|
/** Marks that close a DOI rather than belong to it: a sentence's punctuation, closing quotes. */
|
|
10
13
|
const CLOSING_MARKS = '.,;:"\'”’';
|
|
14
|
+
/** A resolver URL or `doi:` label leading a DOI field's value. */
|
|
15
|
+
const DOI_PREFIX = /^(?:https?:\/\/(?:dx\.|www\.)?doi\.org\/|doi:\s*)/i;
|
|
16
|
+
/** A value that starts as a DOI does: `10.`, a registrant code, and a `/`. */
|
|
17
|
+
const DOI_START = /^10\.\d{4,9}\//;
|
|
18
|
+
/**
|
|
19
|
+
* A label ending right before a DOI: `doi.org/`, `doi:`, or `doi` and a space, then
|
|
20
|
+
* optionally one opening quote. Its whitespace is bounded, so it fits {@link LABEL_WINDOW}.
|
|
21
|
+
*/
|
|
22
|
+
const DOI_LABEL = /\bdoi(?:\.org\/|:\s{0,8}|\s{1,8})["'“‘]?$/i;
|
|
23
|
+
/** How far back from a DOI run its label is looked for: the longest label and the character before it. */
|
|
24
|
+
const LABEL_WINDOW = 14;
|
|
25
|
+
/**
|
|
26
|
+
* A DOI field's value as the model holds it: without a resolver (`https://doi.org/`,
|
|
27
|
+
* `http://dx.doi.org/`) or `doi:` prefix in any case, without the marks closing it
|
|
28
|
+
* ({@link trimDoi}), lowercased. Undefined for a value that is not a DOI (`n/a`, `10.`,
|
|
29
|
+
* `10.1234/`).
|
|
30
|
+
*/
|
|
31
|
+
export function normalizeDoi(value) {
|
|
32
|
+
if (value === undefined)
|
|
33
|
+
return;
|
|
34
|
+
const doi = value.trim().replace(DOI_PREFIX, '');
|
|
35
|
+
return DOI_START.test(doi) ? trimDoi(doi)?.toLowerCase() : undefined;
|
|
36
|
+
}
|
|
11
37
|
/**
|
|
12
38
|
* The first DOI in `text` whose run of DOI characters ends at whitespace, the end of the
|
|
13
39
|
* text, or a quote closing one opened right before it, without the marks closing it
|
|
@@ -16,7 +42,23 @@ const CLOSING_MARKS = '.,;:"\'”’';
|
|
|
16
42
|
* that ends at a quote costs one pass, not one per `10.` inside it.
|
|
17
43
|
*/
|
|
18
44
|
export function doiInText(text) {
|
|
45
|
+
return firstDoi(text, () => true);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The first DOI in `text` that a label introduces, read as {@link doiInText} reads one:
|
|
49
|
+
* its run must follow `doi.org/`, `doi:`, or `doi` and a space (in any case), optionally
|
|
50
|
+
* with one opening quote between (`doi: "10.1234/abc"`, `DOI 10.1234/abc`). A DOI with no
|
|
51
|
+
* label before it is passed over. The label is looked for in a bounded window before each
|
|
52
|
+
* run, so the text is still read in one pass.
|
|
53
|
+
*/
|
|
54
|
+
export function labeledDoiInText(text) {
|
|
55
|
+
return firstDoi(text, (index) => DOI_LABEL.test(text.slice(Math.max(0, index - LABEL_WINDOW), index)));
|
|
56
|
+
}
|
|
57
|
+
/** The first whole DOI run in `text` that `accept`, given where the run starts, takes. */
|
|
58
|
+
function firstDoi(text, accept) {
|
|
19
59
|
for (const { 0: run, index } of text.matchAll(DOI_RUN)) {
|
|
60
|
+
if (!accept(index))
|
|
61
|
+
continue;
|
|
20
62
|
const after = text.charAt(index + run.length);
|
|
21
63
|
const whole = !after || /\s/.test(after) || (after === '"' && text.charAt(index - 1) === '"');
|
|
22
64
|
const doi = whole ? trimDoi(run) : undefined;
|
package/dist/model/doi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doi.js","sourceRoot":"","sources":["../../src/model/doi.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"doi.js","sourceRoot":"","sources":["../../src/model/doi.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,6EAA6E;AAC7E,MAAM,OAAO,GAAG,2BAA2B,CAAC;AAE5C,iGAAiG;AACjG,MAAM,aAAa,GAAG,WAAW,CAAC;AAElC,kEAAkE;AAClE,MAAM,UAAU,GAAG,oDAAoD,CAAC;AAExE,8EAA8E;AAC9E,MAAM,SAAS,GAAG,gBAAgB,CAAC;AAEnC;;;GAGG;AACH,MAAM,SAAS,GAAG,4CAA4C,CAAC;AAE/D,0GAA0G;AAC1G,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB;;;;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AAC,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"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"identifiers.js","sourceRoot":"","sources":["../../src/model/identifiers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,2HAA2H;AAC3H,MAAM,OAAO,GACX,sGAAsG,CAAC;AAEzG,sGAAsG;AACtG,MAAM,UAAU,GACd,wFAAwF,CAAC;AAE3F,wDAAwD;AACxD,MAAM,SAAS,GAAG,0CAA0C,CAAC;AAE7D;;;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,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/input.d.ts
CHANGED
|
@@ -11,4 +11,6 @@ export declare function exceedsBudget(input: string | Uint8Array, maxBytes: numb
|
|
|
11
11
|
* A leading byte-order mark is dropped from strings too.
|
|
12
12
|
*/
|
|
13
13
|
export declare function decodeText(input: string | Uint8Array): string;
|
|
14
|
+
/** The encoding a leading byte-order mark names: UTF-8, UTF-16LE, or UTF-16BE. */
|
|
15
|
+
export declare function bomEncoding(bytes: Uint8Array): 'utf-8' | 'utf-16le' | 'utf-16be' | undefined;
|
|
14
16
|
//# sourceMappingURL=input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/model/input.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAKnF;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAU7D"}
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/model/input.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAKnF;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAU7D;AAED,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAK5F"}
|
package/dist/model/input.js
CHANGED
|
@@ -30,7 +30,8 @@ export function decodeText(input) {
|
|
|
30
30
|
}
|
|
31
31
|
return decoder.decode(input).replace(/^/, '');
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
/** The encoding a leading byte-order mark names: UTF-8, UTF-16LE, or UTF-16BE. */
|
|
34
|
+
export function bomEncoding(bytes) {
|
|
34
35
|
if (bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf)
|
|
35
36
|
return 'utf-8';
|
|
36
37
|
if (bytes[0] === 0xff && bytes[1] === 0xfe)
|
package/dist/model/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/model/input.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,oFAAoF;AACpF,MAAM,UAAU,aAAa,CAAC,KAA0B,EAAE,QAAgB;IACxE,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,UAAU,GAAG,QAAQ,CAAC;IAClE,4FAA4F;IAC5F,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC/C,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,GAAG,QAAQ,CAAC;AAC/D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,KAA0B;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC;IACvE,IAAI,OAAoB,CAAC;IACzB,IAAI,CAAC;QACH,OAAO,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CA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AU,WAAW,CAAC,KAAiB;IAC3C,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;QAAE,OAAO,OAAO,CAAC;IAChF,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;QAAE,OAAO,UAAU,CAAC;IAC9D,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;QAAE,OAAO,UAAU,CAAC;IAC9D,OAAO;AACT,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAiB;IACzC,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IACvE,OAAO,CACL,iDAAiD,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACjE,0CAA0C,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAC3D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Bounds on untrusted input that the XML parser (`src/xml/`) and the HTML
|
|
3
|
+
* loader (`src/html/dom.ts`) share, in a module of their own so neither imports the
|
|
4
|
+
* other's module for a constant.
|
|
5
|
+
* @module src/model/limits
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Deepest element nesting accepted. Real articles stay far shallower — body, section,
|
|
9
|
+
* paragraph, and inline markup rarely pass 20 levels, the deepest MathML seen stays
|
|
10
|
+
* under 60, and the deepest HTML fixture nests 39 levels — so this bounds hostile input
|
|
11
|
+
* and the recursive walks over it.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MAX_XML_DEPTH = 256;
|
|
14
|
+
//# sourceMappingURL=limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/model/limits.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,aAAa,MAAM,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Bounds on untrusted input that the XML parser (`src/xml/`) and the HTML
|
|
3
|
+
* loader (`src/html/dom.ts`) share, in a module of their own so neither imports the
|
|
4
|
+
* other's module for a constant.
|
|
5
|
+
* @module src/model/limits
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Deepest element nesting accepted. Real articles stay far shallower — body, section,
|
|
9
|
+
* paragraph, and inline markup rarely pass 20 levels, the deepest MathML seen stays
|
|
10
|
+
* under 60, and the deepest HTML fixture nests 39 levels — so this bounds hostile input
|
|
11
|
+
* and the recursive walks over it.
|
|
12
|
+
*/
|
|
13
|
+
export const MAX_XML_DEPTH = 256;
|
|
14
|
+
//# sourceMappingURL=limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/model/limits.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC"}
|
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Section IDs unique within one document: the source's own ID when it is
|
|
3
|
-
* unused, else a fallback made unique with a numeric suffix.
|
|
3
|
+
* unused, else a fallback made unique with a numeric suffix. The IDs `toSections` gives
|
|
4
|
+
* its entries that are not sections are defined here too, and no section is issued one.
|
|
4
5
|
* @module src/model/section-ids
|
|
5
6
|
*/
|
|
6
|
-
/**
|
|
7
|
+
/** The ID `toSections` gives the abstract at `index` in `document.abstracts`. */
|
|
8
|
+
export declare function abstractId(index: number): string;
|
|
9
|
+
/** The ID `toSections` gives the figures and tables outside any section. */
|
|
10
|
+
export declare const FLOATS_ID = "floats";
|
|
11
|
+
/** The ID `toSections` gives the footnotes. */
|
|
12
|
+
export declare const FOOTNOTES_ID = "footnotes";
|
|
13
|
+
/** The ID `toSections` gives the references. */
|
|
14
|
+
export declare const REFERENCES_ID = "references";
|
|
15
|
+
/**
|
|
16
|
+
* The IDs `toSections` generates: {@link abstractId}'s `abstract-<digits>`,
|
|
17
|
+
* {@link FLOATS_ID}, {@link FOOTNOTES_ID}, and {@link REFERENCES_ID}. A section never
|
|
18
|
+
* takes one, so each entry's ID names that entry alone.
|
|
19
|
+
*/
|
|
20
|
+
export declare const RESERVED_SECTION_ID: RegExp;
|
|
21
|
+
/**
|
|
22
|
+
* Issue an ID into `issued`: `sourceId` when unused, else `fallback` made unique. An ID
|
|
23
|
+
* in the reserved family counts as used, so it takes a suffix of its own: `abstract-1`
|
|
24
|
+
* becomes `abstract-1-2`, and a second `abstract`, whose `abstract-2` is reserved,
|
|
25
|
+
* becomes `abstract-2-2`. A suffixed ID is reserved only when its base is `abstract`, and
|
|
26
|
+
* suffixing that one again leaves the family, so at most two suffixes are added.
|
|
27
|
+
*/
|
|
7
28
|
export declare function issueId(issued: Set<string>, sourceId: string | undefined, fallback: string): string;
|
|
8
29
|
//# sourceMappingURL=section-ids.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section-ids.d.ts","sourceRoot":"","sources":["../../src/model/section-ids.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"section-ids.d.ts","sourceRoot":"","sources":["../../src/model/section-ids.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,iFAAiF;AACjF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,4EAA4E;AAC5E,eAAO,MAAM,SAAS,WAAW,CAAC;AAElC,+CAA+C;AAC/C,eAAO,MAAM,YAAY,cAAc,CAAC;AAExC,gDAAgD;AAChD,eAAO,MAAM,aAAa,eAAe,CAAC;AAE1C;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAmD,CAAC;AASpF;;;;;;GAMG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,EACnB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,QAAQ,EAAE,MAAM,GACf,MAAM,CAKR"}
|