scholarly-parse 0.1.1 → 0.2.0

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 (152) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +4 -4
  3. package/changelog/0.2.x/0.2.0.md +43 -0
  4. package/dist/detect.d.ts +3 -2
  5. package/dist/detect.d.ts.map +1 -1
  6. package/dist/detect.js +40 -18
  7. package/dist/detect.js.map +1 -1
  8. package/dist/formats/html/blocks.d.ts +3 -2
  9. package/dist/formats/html/blocks.d.ts.map +1 -1
  10. package/dist/formats/html/blocks.js +116 -114
  11. package/dist/formats/html/blocks.js.map +1 -1
  12. package/dist/formats/html/context.d.ts +17 -0
  13. package/dist/formats/html/context.d.ts.map +1 -1
  14. package/dist/formats/html/context.js +4 -0
  15. package/dist/formats/html/context.js.map +1 -1
  16. package/dist/formats/html/inline.d.ts +7 -6
  17. package/dist/formats/html/inline.d.ts.map +1 -1
  18. package/dist/formats/html/inline.js +30 -28
  19. package/dist/formats/html/inline.js.map +1 -1
  20. package/dist/formats/html/metadata.d.ts +10 -5
  21. package/dist/formats/html/metadata.d.ts.map +1 -1
  22. package/dist/formats/html/metadata.js +41 -16
  23. package/dist/formats/html/metadata.js.map +1 -1
  24. package/dist/formats/html/parse.d.ts.map +1 -1
  25. package/dist/formats/html/parse.js +207 -59
  26. package/dist/formats/html/parse.js.map +1 -1
  27. package/dist/formats/html/references.d.ts.map +1 -1
  28. package/dist/formats/html/references.js +11 -13
  29. package/dist/formats/html/references.js.map +1 -1
  30. package/dist/formats/html/subtree.d.ts +112 -0
  31. package/dist/formats/html/subtree.d.ts.map +1 -0
  32. package/dist/formats/html/subtree.js +316 -0
  33. package/dist/formats/html/subtree.js.map +1 -0
  34. package/dist/formats/jats/blocks.d.ts +4 -1
  35. package/dist/formats/jats/blocks.d.ts.map +1 -1
  36. package/dist/formats/jats/blocks.js +120 -32
  37. package/dist/formats/jats/blocks.js.map +1 -1
  38. package/dist/formats/jats/front.d.ts.map +1 -1
  39. package/dist/formats/jats/front.js +12 -5
  40. package/dist/formats/jats/front.js.map +1 -1
  41. package/dist/formats/jats/inline.d.ts.map +1 -1
  42. package/dist/formats/jats/inline.js +23 -4
  43. package/dist/formats/jats/inline.js.map +1 -1
  44. package/dist/formats/jats/parse.js +10 -1
  45. package/dist/formats/jats/parse.js.map +1 -1
  46. package/dist/formats/jats/references.d.ts.map +1 -1
  47. package/dist/formats/jats/references.js +6 -4
  48. package/dist/formats/jats/references.js.map +1 -1
  49. package/dist/formats/latexml/blocks.d.ts.map +1 -1
  50. package/dist/formats/latexml/blocks.js +42 -31
  51. package/dist/formats/latexml/blocks.js.map +1 -1
  52. package/dist/formats/latexml/context.d.ts +4 -1
  53. package/dist/formats/latexml/context.d.ts.map +1 -1
  54. package/dist/formats/latexml/context.js.map +1 -1
  55. package/dist/formats/latexml/inline.d.ts +4 -3
  56. package/dist/formats/latexml/inline.d.ts.map +1 -1
  57. package/dist/formats/latexml/inline.js +10 -11
  58. package/dist/formats/latexml/inline.js.map +1 -1
  59. package/dist/formats/latexml/parse.d.ts.map +1 -1
  60. package/dist/formats/latexml/parse.js +19 -11
  61. package/dist/formats/latexml/parse.js.map +1 -1
  62. package/dist/formats/pdf/inline.d.ts +16 -0
  63. package/dist/formats/pdf/inline.d.ts.map +1 -1
  64. package/dist/formats/pdf/inline.js +45 -3
  65. package/dist/formats/pdf/inline.js.map +1 -1
  66. package/dist/formats/pdf/layout.d.ts.map +1 -1
  67. package/dist/formats/pdf/layout.js +32 -1
  68. package/dist/formats/pdf/layout.js.map +1 -1
  69. package/dist/formats/pdf/lines.d.ts +7 -1
  70. package/dist/formats/pdf/lines.d.ts.map +1 -1
  71. package/dist/formats/pdf/lines.js +17 -1
  72. package/dist/formats/pdf/lines.js.map +1 -1
  73. package/dist/formats/pdf/load.d.ts +15 -5
  74. package/dist/formats/pdf/load.d.ts.map +1 -1
  75. package/dist/formats/pdf/load.js +17 -5
  76. package/dist/formats/pdf/load.js.map +1 -1
  77. package/dist/formats/pdf/parse.d.ts +5 -0
  78. package/dist/formats/pdf/parse.d.ts.map +1 -1
  79. package/dist/formats/pdf/parse.js +9 -10
  80. package/dist/formats/pdf/parse.js.map +1 -1
  81. package/dist/formats/pdf/references.d.ts.map +1 -1
  82. package/dist/formats/pdf/references.js +36 -6
  83. package/dist/formats/pdf/references.js.map +1 -1
  84. package/dist/formats/pdf/structure.d.ts +3 -1
  85. package/dist/formats/pdf/structure.d.ts.map +1 -1
  86. package/dist/formats/pdf/structure.js +89 -33
  87. package/dist/formats/pdf/structure.js.map +1 -1
  88. package/dist/formats/tei/inline.d.ts +4 -1
  89. package/dist/formats/tei/inline.d.ts.map +1 -1
  90. package/dist/formats/tei/inline.js +6 -3
  91. package/dist/formats/tei/inline.js.map +1 -1
  92. package/dist/formats/tei/parse.d.ts.map +1 -1
  93. package/dist/formats/tei/parse.js +16 -8
  94. package/dist/formats/tei/parse.js.map +1 -1
  95. package/dist/html/dom.d.ts +34 -7
  96. package/dist/html/dom.d.ts.map +1 -1
  97. package/dist/html/dom.js +459 -1
  98. package/dist/html/dom.js.map +1 -1
  99. package/dist/html/math.d.ts +7 -0
  100. package/dist/html/math.d.ts.map +1 -0
  101. package/dist/html/math.js +34 -0
  102. package/dist/html/math.js.map +1 -0
  103. package/dist/model/document.d.ts +5 -0
  104. package/dist/model/document.d.ts.map +1 -1
  105. package/dist/model/doi.d.ts +21 -3
  106. package/dist/model/doi.d.ts.map +1 -1
  107. package/dist/model/doi.js +45 -3
  108. package/dist/model/doi.js.map +1 -1
  109. package/dist/model/input.d.ts +2 -0
  110. package/dist/model/input.d.ts.map +1 -1
  111. package/dist/model/input.js +2 -1
  112. package/dist/model/input.js.map +1 -1
  113. package/dist/model/limits.d.ts +14 -0
  114. package/dist/model/limits.d.ts.map +1 -0
  115. package/dist/model/limits.js +14 -0
  116. package/dist/model/limits.js.map +1 -0
  117. package/dist/model/section-ids.d.ts +23 -2
  118. package/dist/model/section-ids.d.ts.map +1 -1
  119. package/dist/model/section-ids.js +38 -13
  120. package/dist/model/section-ids.js.map +1 -1
  121. package/dist/parse.d.ts +2 -0
  122. package/dist/parse.d.ts.map +1 -1
  123. package/dist/parse.js.map +1 -1
  124. package/dist/render/escape.d.ts +5 -0
  125. package/dist/render/escape.d.ts.map +1 -1
  126. package/dist/render/escape.js +9 -2
  127. package/dist/render/escape.js.map +1 -1
  128. package/dist/render/inline.d.ts +67 -6
  129. package/dist/render/inline.d.ts.map +1 -1
  130. package/dist/render/inline.js +243 -9
  131. package/dist/render/inline.js.map +1 -1
  132. package/dist/render/markdown.d.ts +14 -9
  133. package/dist/render/markdown.d.ts.map +1 -1
  134. package/dist/render/markdown.js +23 -14
  135. package/dist/render/markdown.js.map +1 -1
  136. package/dist/render/sections.d.ts +9 -5
  137. package/dist/render/sections.d.ts.map +1 -1
  138. package/dist/render/sections.js +20 -15
  139. package/dist/render/sections.js.map +1 -1
  140. package/dist/render/text.d.ts +5 -0
  141. package/dist/render/text.d.ts.map +1 -1
  142. package/dist/render/text.js +65 -87
  143. package/dist/render/text.js.map +1 -1
  144. package/dist/xml/mathml.d.ts +16 -12
  145. package/dist/xml/mathml.d.ts.map +1 -1
  146. package/dist/xml/mathml.js +110 -40
  147. package/dist/xml/mathml.js.map +1 -1
  148. package/dist/xml/ordered.d.ts +0 -6
  149. package/dist/xml/ordered.d.ts.map +1 -1
  150. package/dist/xml/ordered.js +1 -6
  151. package/dist/xml/ordered.js.map +1 -1
  152. package/package.json +1 -1
package/dist/html/dom.js CHANGED
@@ -4,6 +4,7 @@
4
4
  * Node, and Workers without a browser.
5
5
  * @module src/html/dom
6
6
  */
7
+ import { MAX_XML_DEPTH } from '../model/limits.js';
7
8
  import { MissingPeerError } from '../model/result.js';
8
9
  let linkedom;
9
10
  /**
@@ -14,7 +15,7 @@ let linkedom;
14
15
  * a lone `<` escapes as plain text that the next node then turns into a tag. Merging
15
16
  * adjacent text nodes lets escaping see each run whole.
16
17
  */
17
- export async function loadDocument(html) {
18
+ async function loadDocument(html) {
18
19
  linkedom ??= import('linkedom').catch((error) => {
19
20
  linkedom = undefined;
20
21
  throw new MissingPeerError('Install "linkedom" to parse HTML: bun add linkedom', {
@@ -25,8 +26,25 @@ export async function loadDocument(html) {
25
26
  document.documentElement?.normalize();
26
27
  return document;
27
28
  }
29
+ /**
30
+ * Parse HTML into a document no element of which nests deeper than `MAX_XML_DEPTH`, and
31
+ * count the tags left out to get there. Each tag of an element that would open deeper is
32
+ * removed before `linkedom` parses, its text kept (see {@link boundNesting}): the DOM
33
+ * engine and every recursive walk over its tree then work at a depth real pages never
34
+ * reach, in time linear in the page. Throws as {@link loadDocument} does.
35
+ */
36
+ export async function loadBoundedDocument(html) {
37
+ const bounded = boundNesting(html, MAX_XML_DEPTH);
38
+ return { document: await loadDocument(bounded.html), droppedTags: bounded.dropped };
39
+ }
40
+ /** The `truncated-input` warning for a page {@link loadBoundedDocument} dropped tags from. */
41
+ export function truncatedNestingMessage(droppedTags) {
42
+ return `Markup nested deeper than ${MAX_XML_DEPTH} levels: ${droppedTags} tags left out, their text kept`;
43
+ }
28
44
  export const ELEMENT_NODE = 1;
29
45
  export const TEXT_NODE = 3;
46
+ /** A CDATA section's node type: text that `textContent` counts, as it does a text node's. */
47
+ export const CDATA_SECTION_NODE = 4;
30
48
  export const COMMENT_NODE = 8;
31
49
  /** True for an element node. */
32
50
  export function isElement(node) {
@@ -67,4 +85,444 @@ export function resolveUrl(url, base) {
67
85
  return url;
68
86
  }
69
87
  }
88
+ // ─── Nesting bound ──────────────────────────────────────────────────────────
89
+ //
90
+ // The scan mirrors how htmlparser2 10.1.0, which `linkedom` parses with, reads markup and
91
+ // keeps its stack of open elements, so the depth it counts is the depth `linkedom` builds.
92
+ // The HTML standard's tree builder would count differently: htmlparser2 closes an element
93
+ // implicitly only while it is innermost (`<p><li><td>` repeated nests), and reads `<x/>`
94
+ // as an open tag outside `<math>` and `<svg>`.
95
+ /** Elements htmlparser2 never puts on its stack. */
96
+ const VOID_TAGS = new Set([
97
+ 'area',
98
+ 'base',
99
+ 'basefont',
100
+ 'br',
101
+ 'col',
102
+ 'command',
103
+ 'embed',
104
+ 'frame',
105
+ 'hr',
106
+ 'img',
107
+ 'input',
108
+ 'isindex',
109
+ 'keygen',
110
+ 'link',
111
+ 'meta',
112
+ 'param',
113
+ 'source',
114
+ 'track',
115
+ 'wbr',
116
+ ]);
117
+ const P_TAG = new Set(['p']);
118
+ const FORM_TAGS = new Set([
119
+ 'button',
120
+ 'datalist',
121
+ 'input',
122
+ 'optgroup',
123
+ 'option',
124
+ 'select',
125
+ 'textarea',
126
+ ]);
127
+ const TABLE_SECTIONS = new Set(['tbody', 'thead']);
128
+ const DEFINITION_TAGS = new Set(['dd', 'dt']);
129
+ const RUBY_TAGS = new Set(['rp', 'rt']);
130
+ /** For each tag, the elements its open tag closes while one of them is innermost. */
131
+ const IMPLIED_CLOSES = new Map([
132
+ ['tr', new Set(['td', 'th', 'tr'])],
133
+ ['th', new Set(['th'])],
134
+ ['td', new Set(['td', 'th', 'thead'])],
135
+ ['body', new Set(['head', 'link', 'script'])],
136
+ ['li', new Set(['li'])],
137
+ ...['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].map((tag) => [
138
+ tag,
139
+ P_TAG,
140
+ ]),
141
+ ...['select', 'input', 'output', 'button', 'datalist', 'textarea'].map((tag) => [tag, FORM_TAGS]),
142
+ ['option', new Set(['option'])],
143
+ ['optgroup', new Set(['optgroup', 'option'])],
144
+ ['dd', DEFINITION_TAGS],
145
+ ['dt', DEFINITION_TAGS],
146
+ ...[
147
+ 'address',
148
+ 'article',
149
+ 'aside',
150
+ 'blockquote',
151
+ 'details',
152
+ 'div',
153
+ 'dl',
154
+ 'fieldset',
155
+ 'figcaption',
156
+ 'figure',
157
+ 'footer',
158
+ 'form',
159
+ 'header',
160
+ 'hr',
161
+ 'main',
162
+ 'nav',
163
+ 'ol',
164
+ 'pre',
165
+ 'section',
166
+ 'table',
167
+ 'ul',
168
+ ].map((tag) => [tag, P_TAG]),
169
+ ['rt', RUBY_TAGS],
170
+ ['rp', RUBY_TAGS],
171
+ ['tbody', TABLE_SECTIONS],
172
+ ['tfoot', TABLE_SECTIONS],
173
+ ]);
174
+ /** Elements whose content is foreign, where `<x/>` closes itself. */
175
+ const FOREIGN_TAGS = new Set(['math', 'svg']);
176
+ /** Elements whose content is HTML again inside foreign content. */
177
+ const INTEGRATION_TAGS = new Set([
178
+ 'annotation-xml',
179
+ 'desc',
180
+ 'foreignobject',
181
+ 'mi',
182
+ 'mn',
183
+ 'mo',
184
+ 'ms',
185
+ 'mtext',
186
+ 'title',
187
+ ]);
188
+ /**
189
+ * Raw-text elements, by the names htmlparser2 recognizes them by, each with the close tag
190
+ * that ends its text. The tokenizer matches a name letter by letter and takes one branch
191
+ * for a name opening with `t` or `x`, so `<xitle>` is read as raw text to `</title>`.
192
+ */
193
+ const RAW_TEXT = new Map([
194
+ ['script', 'script'],
195
+ ['style', 'style'],
196
+ ['title', 'title'],
197
+ ['xitle', 'title'],
198
+ ['textarea', 'textarea'],
199
+ ['xextarea', 'textarea'],
200
+ ['xmp', 'xmp'],
201
+ ['tmp', 'xmp'],
202
+ ]);
203
+ const LT = 0x3c;
204
+ const GT = 0x3e;
205
+ const SLASH = 0x2f;
206
+ const EXCLAMATION = 0x21;
207
+ const QUESTION = 0x3f;
208
+ const QUOTE = 0x22;
209
+ const APOSTROPHE = 0x27;
210
+ const EQUALS = 0x3d;
211
+ /** An open tag's name: up to a space, `/`, or `>`. A close tag's: up to a space or `>`. */
212
+ const OPEN_NAME = /[^\t\n\f\r />]*/y;
213
+ const CLOSE_NAME = /[^\t\n\f\r >]*/y;
214
+ function isSpace(code) {
215
+ return code === 0x20 || code === 0x0a || code === 0x09 || code === 0x0c || code === 0x0d;
216
+ }
217
+ function isAsciiLetter(code) {
218
+ return (code >= 0x41 && code <= 0x5a) || (code >= 0x61 && code <= 0x7a);
219
+ }
220
+ /** Where a sticky pattern's match from `from` ends. */
221
+ function matchEnd(pattern, text, from) {
222
+ pattern.lastIndex = from;
223
+ pattern.exec(text);
224
+ return pattern.lastIndex;
225
+ }
226
+ /** The index after the first `token` at or past `from`; the end of the text when there is none. */
227
+ function after(text, token, from) {
228
+ const at = text.indexOf(token, from);
229
+ return at === -1 ? text.length : at + token.length;
230
+ }
231
+ /**
232
+ * `html` with the tags of every element that would open deeper than `max` levels taken
233
+ * out, and how many tags that was. Each tag removed becomes a space, so the words either
234
+ * side stay apart, and the element's text stays where it was; a close tag whose open tag
235
+ * was removed goes too, and so does every tag inside its element. One pass, in time
236
+ * linear in the markup: an element is found by name in one step rather than by searching
237
+ * the stack, as htmlparser2 does per close tag.
238
+ *
239
+ * htmlparser2 also keeps a stack of foreign-content flags, which it grows by `unshift`: a
240
+ * `<math>`, `<svg>`, or element of {@link INTEGRATION_TAGS} adds one, and only a close tag
241
+ * of one of those names removes one, so each element of them that closes otherwise (`<math/>`,
242
+ * `<b><mi></b>`) leaves its flag behind. Past `max` flags, such an element is removed too.
243
+ *
244
+ * Text htmlparser2 reads raw (`<script>`, `<style>`, `<title>`, `<textarea>`, `<xmp>`) and
245
+ * comments hold no tags. A raw-text element that is itself removed loses its content when
246
+ * that is code (script, style) and keeps it, escaped, otherwise.
247
+ */
248
+ export function boundNesting(html, max) {
249
+ const scan = {
250
+ copied: 0,
251
+ dropped: 0,
252
+ foreignAll: [false],
253
+ foreignKept: [false],
254
+ html,
255
+ kept: 0,
256
+ max,
257
+ open: [],
258
+ openAt: new Map(),
259
+ out: [],
260
+ };
261
+ for (let at = html.indexOf('<'); at !== -1 && at < html.length; at = html.indexOf('<', at)) {
262
+ at = readMarkup(scan, at);
263
+ }
264
+ if (scan.dropped === 0)
265
+ return { dropped: 0, html };
266
+ scan.out.push(html.slice(scan.copied));
267
+ return { dropped: scan.dropped, html: scan.out.join('') };
268
+ }
269
+ /** Read the markup a `<` opens, if any; returns where text resumes. */
270
+ function readMarkup(scan, lt) {
271
+ const { html } = scan;
272
+ const next = html.charCodeAt(lt + 1);
273
+ if (next === EXCLAMATION)
274
+ return declarationEnd(html, lt);
275
+ if (next === QUESTION)
276
+ return after(html, '>', lt + 2);
277
+ if (next === SLASH)
278
+ return readCloseTag(scan, lt);
279
+ if (isAsciiLetter(next))
280
+ return readOpenTag(scan, lt);
281
+ return lt + 1;
282
+ }
283
+ /** The end of a `<!…>` construct: a comment, a CDATA section, or a declaration. */
284
+ function declarationEnd(html, lt) {
285
+ if (html.startsWith('--', lt + 2))
286
+ return after(html, '-->', lt + 2);
287
+ const third = html.charAt(lt + 2);
288
+ // `<!-x` is a declaration from the character after the `x`.
289
+ if (third === '-')
290
+ return after(html, '>', lt + 4);
291
+ if (third === '[') {
292
+ let matched = 0;
293
+ while (matched < 6 && html.charAt(lt + 3 + matched) === 'CDATA['.charAt(matched))
294
+ matched++;
295
+ return matched === 6 ? after(html, ']]>', lt + 9) : after(html, '>', lt + 3 + matched);
296
+ }
297
+ return after(html, '>', lt + 3);
298
+ }
299
+ function readCloseTag(scan, lt) {
300
+ const { html } = scan;
301
+ let at = lt + 2;
302
+ while (isSpace(html.charCodeAt(at)))
303
+ at++;
304
+ if (at >= html.length)
305
+ return html.length;
306
+ const first = html.charCodeAt(at);
307
+ if (first === GT)
308
+ return at + 1;
309
+ // `</` and anything but a letter opens a comment that runs to the next `>`.
310
+ if (!isAsciiLetter(first))
311
+ return after(html, '>', at);
312
+ const nameEnd = matchEnd(CLOSE_NAME, html, at);
313
+ if (nameEnd >= html.length)
314
+ return html.length;
315
+ const end = after(html, '>', nameEnd);
316
+ closeTag(scan, html.slice(at, nameEnd).toLowerCase(), lt, end, false);
317
+ return end;
318
+ }
319
+ function readOpenTag(scan, lt) {
320
+ const { html } = scan;
321
+ const nameEnd = matchEnd(OPEN_NAME, html, lt + 1);
322
+ const tag = openTagEnd(html, nameEnd);
323
+ if (!tag)
324
+ return html.length;
325
+ const name = html.slice(lt + 1, nameEnd).toLowerCase();
326
+ const kept = openTag(scan, name, tag.selfClosing, lt, tag.end);
327
+ const closer = tag.selfClosing ? undefined : RAW_TEXT.get(name);
328
+ return closer ? readRawText(scan, closer, tag.end, kept) : tag.end;
329
+ }
330
+ /**
331
+ * The index after an open tag whose name ends at `from`, and whether it ends `/>`.
332
+ * Attributes are read as htmlparser2 reads them, so a `>` in a quoted value does not end
333
+ * the tag. Undefined when the markup ends first, as htmlparser2 then drops the tag.
334
+ */
335
+ function openTagEnd(html, from) {
336
+ // 0: before an attribute name; 1: after a `/`; 2: in a name; 3: after a name;
337
+ // 4: before a value; 5: in an unquoted value.
338
+ let state = 0;
339
+ for (let at = from; at < html.length; at++) {
340
+ const code = html.charCodeAt(at);
341
+ switch (state) {
342
+ case 0:
343
+ if (code === GT)
344
+ return { end: at + 1, selfClosing: false };
345
+ if (code === SLASH)
346
+ state = 1;
347
+ else if (!isSpace(code))
348
+ state = 2;
349
+ break;
350
+ case 1:
351
+ if (code === GT)
352
+ return { end: at + 1, selfClosing: true };
353
+ if (!isSpace(code)) {
354
+ state = 0;
355
+ at--;
356
+ }
357
+ break;
358
+ case 2:
359
+ if (code === EQUALS || code === SLASH || code === GT || isSpace(code)) {
360
+ state = 3;
361
+ at--;
362
+ }
363
+ break;
364
+ case 3:
365
+ if (code === EQUALS)
366
+ state = 4;
367
+ else if (code === SLASH || code === GT) {
368
+ state = 0;
369
+ at--;
370
+ }
371
+ else if (!isSpace(code))
372
+ state = 2;
373
+ break;
374
+ case 4:
375
+ if (code === QUOTE || code === APOSTROPHE) {
376
+ at = html.indexOf(code === QUOTE ? '"' : "'", at + 1);
377
+ if (at === -1)
378
+ return;
379
+ state = 0;
380
+ }
381
+ else if (!isSpace(code)) {
382
+ state = 5;
383
+ at--;
384
+ }
385
+ break;
386
+ default:
387
+ if (code === GT || isSpace(code)) {
388
+ state = 0;
389
+ at--;
390
+ }
391
+ }
392
+ }
393
+ return;
394
+ }
395
+ /**
396
+ * The text of a raw-text element, up to the close tag that ends it, which is then read
397
+ * like any close tag. htmlparser2 matches that tag as `</name` and a space or `>`,
398
+ * comparing each character `| 0x20`, which also takes `\x1C` for `<` and `\x0F` for `/`.
399
+ */
400
+ function readRawText(scan, closer, from, kept) {
401
+ const { html } = scan;
402
+ const at = rawTextEnd(html, closer, from);
403
+ const end = at === -1 ? html.length : at;
404
+ if (!kept) {
405
+ // With its open tag gone the text would be read as markup.
406
+ const text = html.slice(from, end);
407
+ replace(scan, from, end, closer === 'script' || closer === 'style'
408
+ ? ''
409
+ : closer === 'title'
410
+ ? text.replace(/</g, '&lt;')
411
+ : text.replace(/&/g, '&amp;').replace(/</g, '&lt;'));
412
+ }
413
+ if (at === -1)
414
+ return html.length;
415
+ const tagEnd = after(html, '>', at + 2 + closer.length);
416
+ closeTag(scan, closer, at, tagEnd, !kept);
417
+ return tagEnd;
418
+ }
419
+ /** Where the close tag that ends raw text named `name` starts; -1 when none does. */
420
+ function rawTextEnd(html, name, from) {
421
+ const sequence = `</${name}`;
422
+ let matched = 0;
423
+ for (let at = from; at < html.length; at++) {
424
+ const code = html.charCodeAt(at);
425
+ if (matched === sequence.length) {
426
+ if (code === GT || isSpace(code))
427
+ return at - sequence.length;
428
+ matched = 0;
429
+ }
430
+ if ((code | 0x20) === sequence.charCodeAt(matched))
431
+ matched++;
432
+ else if (matched > 0)
433
+ matched = code === LT ? 1 : 0;
434
+ else if (name !== 'title') {
435
+ // Outside a title the tokenizer skips to the next `<` and counts it matched.
436
+ at = html.indexOf('<', at + 1);
437
+ if (at === -1)
438
+ return -1;
439
+ matched = 1;
440
+ }
441
+ }
442
+ return -1;
443
+ }
444
+ /** Read an open tag into the stack; false when its element is too deep and the tag was dropped. */
445
+ function openTag(scan, name, selfClosing, start, end) {
446
+ const { open } = scan;
447
+ const closes = IMPLIED_CLOSES.get(name);
448
+ while (closes?.has(open.at(-1) ?? ''))
449
+ pop(scan);
450
+ const flagged = FOREIGN_TAGS.has(name) || INTEGRATION_TAGS.has(name);
451
+ // No name with a flag implies a close, so a tag dropped here closed nothing the output keeps.
452
+ const kept = hasRoom(scan) && !(flagged && scan.foreignKept.length > scan.max);
453
+ if (!VOID_TAGS.has(name)) {
454
+ push(scan, name);
455
+ if (kept)
456
+ scan.kept++;
457
+ if (flagged) {
458
+ const foreign = FOREIGN_TAGS.has(name);
459
+ scan.foreignAll.push(foreign);
460
+ if (kept)
461
+ scan.foreignKept.push(foreign);
462
+ }
463
+ if (selfClosing && (kept ? scan.foreignKept : scan.foreignAll).at(-1))
464
+ pop(scan);
465
+ }
466
+ if (!kept) {
467
+ scan.dropped++;
468
+ replace(scan, start, end, ' ');
469
+ }
470
+ return kept;
471
+ }
472
+ /**
473
+ * Read a close tag into the stack, dropping it when the element it closes was dropped.
474
+ * `ofDropped` marks the tag ending the text of a raw-text element that was dropped: it
475
+ * goes with its element, so it closes nothing the output keeps.
476
+ */
477
+ function closeTag(scan, name, start, end, ofDropped) {
478
+ const { open } = scan;
479
+ let kept;
480
+ if (VOID_TAGS.has(name)) {
481
+ // `</br>` makes a `<br>`; any other void close tag is ignored.
482
+ kept = !ofDropped && (name !== 'br' || hasRoom(scan));
483
+ }
484
+ else {
485
+ const at = scan.openAt.get(name)?.at(-1);
486
+ // An unmatched `</p>` makes a `<p>`.
487
+ if (at === undefined)
488
+ kept = !ofDropped && (name !== 'p' || hasRoom(scan));
489
+ else
490
+ kept = !ofDropped && at < scan.kept;
491
+ if (FOREIGN_TAGS.has(name) || INTEGRATION_TAGS.has(name)) {
492
+ scan.foreignAll.pop();
493
+ if (kept)
494
+ scan.foreignKept.pop();
495
+ }
496
+ if (at !== undefined && (kept || at >= scan.kept))
497
+ while (open.length > at)
498
+ pop(scan);
499
+ }
500
+ if (!kept) {
501
+ scan.dropped++;
502
+ replace(scan, start, end, ' ');
503
+ }
504
+ }
505
+ function push(scan, name) {
506
+ const indexes = scan.openAt.get(name);
507
+ if (indexes)
508
+ indexes.push(scan.open.length);
509
+ else
510
+ scan.openAt.set(name, [scan.open.length]);
511
+ scan.open.push(name);
512
+ }
513
+ function pop(scan) {
514
+ const name = scan.open.pop();
515
+ if (name !== undefined)
516
+ scan.openAt.get(name)?.pop();
517
+ scan.kept = Math.min(scan.kept, scan.open.length);
518
+ }
519
+ /** True when an element opened now would be kept: none open is dropped, and it is not too deep. */
520
+ function hasRoom(scan) {
521
+ return scan.open.length === scan.kept && scan.kept < scan.max;
522
+ }
523
+ /** Write the source up to `start`, then `text` in place of `start`…`end`. */
524
+ function replace(scan, start, end, text) {
525
+ scan.out.push(scan.html.slice(scan.copied, start), text);
526
+ scan.copied = end;
527
+ }
70
528
  //# sourceMappingURL=dom.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dom.js","sourceRoot":"","sources":["../../src/html/dom.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,IAAI,QAA6C,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAY;IAC7C,QAAQ,KAAM,MAAM,CAAC,UAAU,CAA6B,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QACpF,QAAQ,GAAG,SAAS,CAAC;QACrB,MAAM,IAAI,gBAAgB,CAAC,oDAAoD,EAAE;YAC/E,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,QAAQ,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,SAAS,EAAE,CAAC;IACtC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAC9B,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAC3B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAE9B,gCAAgC;AAChC,MAAM,UAAU,SA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,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,GAAG,CAAC,IAAiB;IAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,IAAI,IAAI,KAAK,SAAS;QAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACrD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACpD,CAAC;AAED,mGAAmG;AACnG,SAAS,OAAO,CAAC,IAAiB;IAChC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC;AAChE,CAAC;AAED,6EAA6E;AAC7E,SAAS,OAAO,CAAC,IAAiB,EAAE,KAAa,EAAE,GAAW,EAAE,IAAY;IAC1E,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;IACzD,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;AACpB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * TeX for a MathML `<math>` element: its `application/x-tex` annotation (KaTeX and
3
+ * LaTeXML keep one), else its `alttext`, else the presentation markup linearized. Empty
4
+ * when all three are.
5
+ */
6
+ export declare function domMathTex(math: Element): string;
7
+ //# sourceMappingURL=math.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../src/html/math.ts"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAShD"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @fileoverview TeX for MathML in an HTML page: the TeX the page keeps beside it, else
3
+ * the presentation markup linearized as `mathmlToTex` does for JATS. Nodes are read
4
+ * through standard DOM properties only, so nothing here loads `linkedom`, and the XML
5
+ * subpaths, which import `src/xml/mathml.ts`, load no DOM code.
6
+ * @module src/html/math
7
+ */
8
+ import { mathmlToTex } from '../xml/mathml.js';
9
+ import { isElement, TEXT_NODE, tagOf } from './dom.js';
10
+ /** A DOM read as MathML: elements by their lowercase local name, and text. Comments are skipped. */
11
+ const DOM_NODES = {
12
+ attr: (node, name) => (isElement(node) ? (node.getAttribute(name) ?? undefined) : undefined),
13
+ children: (node) => Array.from(node.childNodes).filter((child) => isElement(child) || child.nodeType === TEXT_NODE),
14
+ isText: (node) => node.nodeType === TEXT_NODE,
15
+ name: (node) => {
16
+ if (!isElement(node))
17
+ return;
18
+ const tag = tagOf(node);
19
+ return tag.slice(tag.indexOf(':') + 1);
20
+ },
21
+ text: (node) => node.nodeType === TEXT_NODE ? (node.textContent ?? '').replace(/\u00AD/g, '') : '',
22
+ };
23
+ /**
24
+ * TeX for a MathML `<math>` element: its `application/x-tex` annotation (KaTeX and
25
+ * LaTeXML keep one), else its `alttext`, else the presentation markup linearized. Empty
26
+ * when all three are.
27
+ */
28
+ export function domMathTex(math) {
29
+ const annotation = Array.from(math.getElementsByTagName('annotation')).find((a) => (a.getAttribute('encoding') ?? '').toLowerCase() === 'application/x-tex');
30
+ return ((annotation?.textContent ?? '').trim() ||
31
+ (math.getAttribute('alttext') ?? '').trim() ||
32
+ mathmlToTex(math, DOM_NODES));
33
+ }
34
+ //# sourceMappingURL=math.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.js","sourceRoot":"","sources":["../../src/html/math.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAkB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,U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Y,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,KAAK,mBAAmB,CAChF,CAAC;IACF,OAAO,CACL,CAAC,UAAU,EAAE,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QACtC,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QAC3C,WAAW,CAAO,IAAI,EAAE,SAAS,CAAC,CACnC,CAAC;AACJ,CAAC"}
@@ -231,6 +231,7 @@ export interface Reference {
231
231
  arxiv?: string;
232
232
  /** Author names as printed. */
233
233
  authors?: string[];
234
+ /** Lowercased DOI without a resolver prefix, whatever form `text` prints it in. */
234
235
  doi?: string;
235
236
  id?: string;
236
237
  /** Printed label without brackets or a trailing period: `12` for `[12]` or `12.`. */
@@ -249,6 +250,10 @@ export interface Reference {
249
250
  export interface Footnote {
250
251
  id?: string;
251
252
  label?: string;
253
+ /**
254
+ * The note as inline Markdown. A note is text in every format: block content the source
255
+ * puts in one (a list's items, a formula, code, a figure's caption) is written into it.
256
+ */
252
257
  text: string;
253
258
  }
254
259
  /** 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,CA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CAAC;CACzB"}
@@ -1,9 +1,19 @@
1
1
  /**
2
- * @fileoverview The first DOI in running text, read in one pass over its runs of DOI
3
- * characters, without the punctuation, quotes, and brackets that close it. PDF, HTML, and
4
- * LaTeXML references read the DOI in an entry's text here.
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