scholarly-parse 0.2.0 → 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.
Files changed (94) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +3 -3
  3. package/changelog/0.2.x/0.2.1.md +45 -0
  4. package/dist/formats/html/metadata.d.ts +0 -8
  5. package/dist/formats/html/metadata.d.ts.map +1 -1
  6. package/dist/formats/html/metadata.js +18 -7
  7. package/dist/formats/html/metadata.js.map +1 -1
  8. package/dist/formats/html/references.d.ts.map +1 -1
  9. package/dist/formats/html/references.js +4 -18
  10. package/dist/formats/html/references.js.map +1 -1
  11. package/dist/formats/jats/blocks.d.ts.map +1 -1
  12. package/dist/formats/jats/blocks.js +57 -28
  13. package/dist/formats/jats/blocks.js.map +1 -1
  14. package/dist/formats/jats/fragment.d.ts +8 -2
  15. package/dist/formats/jats/fragment.d.ts.map +1 -1
  16. package/dist/formats/jats/fragment.js +187 -7
  17. package/dist/formats/jats/fragment.js.map +1 -1
  18. package/dist/formats/jats/front.d.ts +0 -5
  19. package/dist/formats/jats/front.d.ts.map +1 -1
  20. package/dist/formats/jats/front.js +49 -34
  21. package/dist/formats/jats/front.js.map +1 -1
  22. package/dist/formats/jats/inline.d.ts +3 -3
  23. package/dist/formats/jats/inline.d.ts.map +1 -1
  24. package/dist/formats/jats/inline.js +96 -40
  25. package/dist/formats/jats/inline.js.map +1 -1
  26. package/dist/formats/jats/parse.js +33 -5
  27. package/dist/formats/jats/parse.js.map +1 -1
  28. package/dist/formats/jats/references.d.ts +0 -5
  29. package/dist/formats/jats/references.d.ts.map +1 -1
  30. package/dist/formats/jats/references.js +153 -47
  31. package/dist/formats/jats/references.js.map +1 -1
  32. package/dist/formats/jats/text.d.ts +16 -0
  33. package/dist/formats/jats/text.d.ts.map +1 -1
  34. package/dist/formats/jats/text.js +77 -1
  35. package/dist/formats/jats/text.js.map +1 -1
  36. package/dist/formats/latexml/parse.d.ts +7 -1
  37. package/dist/formats/latexml/parse.d.ts.map +1 -1
  38. package/dist/formats/latexml/parse.js +42 -14
  39. package/dist/formats/latexml/parse.js.map +1 -1
  40. package/dist/formats/pdf/references.d.ts +0 -6
  41. package/dist/formats/pdf/references.d.ts.map +1 -1
  42. package/dist/formats/pdf/references.js +8 -2
  43. package/dist/formats/pdf/references.js.map +1 -1
  44. package/dist/formats/tei/parse.d.ts.map +1 -1
  45. package/dist/formats/tei/parse.js +39 -27
  46. package/dist/formats/tei/parse.js.map +1 -1
  47. package/dist/model/arxiv.d.ts +51 -0
  48. package/dist/model/arxiv.d.ts.map +1 -0
  49. package/dist/model/arxiv.js +167 -0
  50. package/dist/model/arxiv.js.map +1 -0
  51. package/dist/model/document.d.ts +17 -4
  52. package/dist/model/document.d.ts.map +1 -1
  53. package/dist/model/identifiers.d.ts +32 -0
  54. package/dist/model/identifiers.d.ts.map +1 -0
  55. package/dist/model/identifiers.js +61 -0
  56. package/dist/model/identifiers.js.map +1 -0
  57. package/dist/parse.d.ts +4 -1
  58. package/dist/parse.d.ts.map +1 -1
  59. package/dist/parse.js.map +1 -1
  60. package/dist/render/bare-url.d.ts +29 -0
  61. package/dist/render/bare-url.d.ts.map +1 -0
  62. package/dist/render/bare-url.js +207 -0
  63. package/dist/render/bare-url.js.map +1 -0
  64. package/dist/render/escape.d.ts +55 -9
  65. package/dist/render/escape.d.ts.map +1 -1
  66. package/dist/render/escape.js +217 -16
  67. package/dist/render/escape.js.map +1 -1
  68. package/dist/render/inline.d.ts +38 -55
  69. package/dist/render/inline.d.ts.map +1 -1
  70. package/dist/render/inline.js +682 -150
  71. package/dist/render/inline.js.map +1 -1
  72. package/dist/render/markdown.d.ts.map +1 -1
  73. package/dist/render/markdown.js +18 -6
  74. package/dist/render/markdown.js.map +1 -1
  75. package/dist/render/read-inline.d.ts +70 -0
  76. package/dist/render/read-inline.d.ts.map +1 -0
  77. package/dist/render/read-inline.js +376 -0
  78. package/dist/render/read-inline.js.map +1 -0
  79. package/dist/render/scan.d.ts +54 -0
  80. package/dist/render/scan.d.ts.map +1 -0
  81. package/dist/render/scan.js +145 -0
  82. package/dist/render/scan.js.map +1 -0
  83. package/dist/render/text.d.ts +3 -9
  84. package/dist/render/text.d.ts.map +1 -1
  85. package/dist/render/text.js +5 -160
  86. package/dist/render/text.js.map +1 -1
  87. package/dist/xml/ordered.d.ts.map +1 -1
  88. package/dist/xml/ordered.js +110 -14
  89. package/dist/xml/ordered.js.map +1 -1
  90. package/dist/xml/well-formed.d.ts +11 -3
  91. package/dist/xml/well-formed.d.ts.map +1 -1
  92. package/dist/xml/well-formed.js +25 -7
  93. package/dist/xml/well-formed.js.map +1 -1
  94. 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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EAAE,CAAC;IACrF,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,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"}
@@ -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-1825-0097`. */
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
- /** arXiv ID without the `arXiv:` prefix, version suffix kept when present. */
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 the `PMC` prefix. */
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 the `PMC` prefix. */
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,6 +233,12 @@ 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[];
@@ -236,7 +247,9 @@ export interface Reference {
236
247
  id?: string;
237
248
  /** Printed label without brackets or a trailing period: `12` for `[12]` or `12.`. */
238
249
  label?: string;
250
+ /** PMC ID with an uppercase `PMC` prefix, e.g. `PMC123456`. */
239
251
  pmcid?: string;
252
+ /** PubMed ID: digits only, without a label or link. */
240
253
  pmid?: string;
241
254
  /** Journal, book, or proceedings title. */
242
255
  source?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/model/document.ts"],"names":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AE,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"}
@@ -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;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAyB;IACtD,MAAM,MAAM,GAAG,4BAA4B,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACjG,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;IACzD,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAyB;IACtD,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;IAC1D,OAAO,iCAAiC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACzF,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAAyB,EAAE,IAAY,EAAE,KAAa;IACvE,MAAM,OAAO,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACrC,MAAM,UAAU,GAAG,IAAI,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/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
- /** Where the document was retrieved, so relative links and images resolve (HTML, LaTeXML). */
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;
@@ -1 +1 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAU,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhF,2EAA2E;AAC3E,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,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;;;;GAIG;AACH,wBAAsB,KAAK,CACzB,KAAK,EAAE,MAAM,GAAG,UAAU,EAC1B,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,WAAW,CAAC,CA6BtB"}
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,gBAAi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AAG,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 (`&amp;`) 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 (`&amp;`) 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
+ return false;
205
+ };
206
+ }
207
+ //# sourceMappingURL=bare-url.js.map