scholarly-parse 0.1.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 (238) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +201 -0
  3. package/README.md +118 -0
  4. package/changelog/0.1.x/0.1.0.md +17 -0
  5. package/changelog/template.md +150 -0
  6. package/dist/detect.d.ts +11 -0
  7. package/dist/detect.d.ts.map +1 -0
  8. package/dist/detect.js +51 -0
  9. package/dist/detect.js.map +1 -0
  10. package/dist/formats/html/blocks.d.ts +29 -0
  11. package/dist/formats/html/blocks.d.ts.map +1 -0
  12. package/dist/formats/html/blocks.js +527 -0
  13. package/dist/formats/html/blocks.js.map +1 -0
  14. package/dist/formats/html/context.d.ts +19 -0
  15. package/dist/formats/html/context.d.ts.map +1 -0
  16. package/dist/formats/html/context.js +122 -0
  17. package/dist/formats/html/context.js.map +1 -0
  18. package/dist/formats/html/index.d.ts +7 -0
  19. package/dist/formats/html/index.d.ts.map +1 -0
  20. package/dist/formats/html/index.js +7 -0
  21. package/dist/formats/html/index.js.map +1 -0
  22. package/dist/formats/html/inline.d.ts +26 -0
  23. package/dist/formats/html/inline.d.ts.map +1 -0
  24. package/dist/formats/html/inline.js +253 -0
  25. package/dist/formats/html/inline.js.map +1 -0
  26. package/dist/formats/html/metadata.d.ts +30 -0
  27. package/dist/formats/html/metadata.d.ts.map +1 -0
  28. package/dist/formats/html/metadata.js +212 -0
  29. package/dist/formats/html/metadata.js.map +1 -0
  30. package/dist/formats/html/parse.d.ts +17 -0
  31. package/dist/formats/html/parse.d.ts.map +1 -0
  32. package/dist/formats/html/parse.js +405 -0
  33. package/dist/formats/html/parse.js.map +1 -0
  34. package/dist/formats/html/references.d.ts +12 -0
  35. package/dist/formats/html/references.d.ts.map +1 -0
  36. package/dist/formats/html/references.js +123 -0
  37. package/dist/formats/html/references.js.map +1 -0
  38. package/dist/formats/jats/blocks.d.ts +52 -0
  39. package/dist/formats/jats/blocks.d.ts.map +1 -0
  40. package/dist/formats/jats/blocks.js +614 -0
  41. package/dist/formats/jats/blocks.js.map +1 -0
  42. package/dist/formats/jats/context.d.ts +17 -0
  43. package/dist/formats/jats/context.d.ts.map +1 -0
  44. package/dist/formats/jats/context.js +2 -0
  45. package/dist/formats/jats/context.js.map +1 -0
  46. package/dist/formats/jats/fragment.d.ts +7 -0
  47. package/dist/formats/jats/fragment.d.ts.map +1 -0
  48. package/dist/formats/jats/fragment.js +42 -0
  49. package/dist/formats/jats/fragment.js.map +1 -0
  50. package/dist/formats/jats/front.d.ts +25 -0
  51. package/dist/formats/jats/front.d.ts.map +1 -0
  52. package/dist/formats/jats/front.js +380 -0
  53. package/dist/formats/jats/front.js.map +1 -0
  54. package/dist/formats/jats/index.d.ts +8 -0
  55. package/dist/formats/jats/index.d.ts.map +1 -0
  56. package/dist/formats/jats/index.js +8 -0
  57. package/dist/formats/jats/index.js.map +1 -0
  58. package/dist/formats/jats/inline.d.ts +24 -0
  59. package/dist/formats/jats/inline.d.ts.map +1 -0
  60. package/dist/formats/jats/inline.js +274 -0
  61. package/dist/formats/jats/inline.js.map +1 -0
  62. package/dist/formats/jats/parse.d.ts +9 -0
  63. package/dist/formats/jats/parse.d.ts.map +1 -0
  64. package/dist/formats/jats/parse.js +247 -0
  65. package/dist/formats/jats/parse.js.map +1 -0
  66. package/dist/formats/jats/references.d.ts +25 -0
  67. package/dist/formats/jats/references.d.ts.map +1 -0
  68. package/dist/formats/jats/references.js +406 -0
  69. package/dist/formats/jats/references.js.map +1 -0
  70. package/dist/formats/jats/tables.d.ts +18 -0
  71. package/dist/formats/jats/tables.d.ts.map +1 -0
  72. package/dist/formats/jats/tables.js +105 -0
  73. package/dist/formats/jats/tables.js.map +1 -0
  74. package/dist/formats/jats/text.d.ts +23 -0
  75. package/dist/formats/jats/text.d.ts.map +1 -0
  76. package/dist/formats/jats/text.js +114 -0
  77. package/dist/formats/jats/text.js.map +1 -0
  78. package/dist/formats/latexml/blocks.d.ts +13 -0
  79. package/dist/formats/latexml/blocks.d.ts.map +1 -0
  80. package/dist/formats/latexml/blocks.js +454 -0
  81. package/dist/formats/latexml/blocks.js.map +1 -0
  82. package/dist/formats/latexml/context.d.ts +19 -0
  83. package/dist/formats/latexml/context.d.ts.map +1 -0
  84. package/dist/formats/latexml/context.js +18 -0
  85. package/dist/formats/latexml/context.js.map +1 -0
  86. package/dist/formats/latexml/index.d.ts +7 -0
  87. package/dist/formats/latexml/index.d.ts.map +1 -0
  88. package/dist/formats/latexml/index.js +7 -0
  89. package/dist/formats/latexml/index.js.map +1 -0
  90. package/dist/formats/latexml/inline.d.ts +16 -0
  91. package/dist/formats/latexml/inline.d.ts.map +1 -0
  92. package/dist/formats/latexml/inline.js +113 -0
  93. package/dist/formats/latexml/inline.js.map +1 -0
  94. package/dist/formats/latexml/parse.d.ts +16 -0
  95. package/dist/formats/latexml/parse.d.ts.map +1 -0
  96. package/dist/formats/latexml/parse.js +405 -0
  97. package/dist/formats/latexml/parse.js.map +1 -0
  98. package/dist/formats/pdf/blocks.d.ts +14 -0
  99. package/dist/formats/pdf/blocks.d.ts.map +1 -0
  100. package/dist/formats/pdf/blocks.js +203 -0
  101. package/dist/formats/pdf/blocks.js.map +1 -0
  102. package/dist/formats/pdf/index.d.ts +7 -0
  103. package/dist/formats/pdf/index.d.ts.map +1 -0
  104. package/dist/formats/pdf/index.js +7 -0
  105. package/dist/formats/pdf/index.js.map +1 -0
  106. package/dist/formats/pdf/inline.d.ts +8 -0
  107. package/dist/formats/pdf/inline.d.ts.map +1 -0
  108. package/dist/formats/pdf/inline.js +91 -0
  109. package/dist/formats/pdf/inline.js.map +1 -0
  110. package/dist/formats/pdf/layout.d.ts +33 -0
  111. package/dist/formats/pdf/layout.d.ts.map +1 -0
  112. package/dist/formats/pdf/layout.js +358 -0
  113. package/dist/formats/pdf/layout.js.map +1 -0
  114. package/dist/formats/pdf/lines.d.ts +40 -0
  115. package/dist/formats/pdf/lines.d.ts.map +1 -0
  116. package/dist/formats/pdf/lines.js +104 -0
  117. package/dist/formats/pdf/lines.js.map +1 -0
  118. package/dist/formats/pdf/load.d.ts +43 -0
  119. package/dist/formats/pdf/load.d.ts.map +1 -0
  120. package/dist/formats/pdf/load.js +126 -0
  121. package/dist/formats/pdf/load.js.map +1 -0
  122. package/dist/formats/pdf/parse.d.ts +9 -0
  123. package/dist/formats/pdf/parse.d.ts.map +1 -0
  124. package/dist/formats/pdf/parse.js +126 -0
  125. package/dist/formats/pdf/parse.js.map +1 -0
  126. package/dist/formats/pdf/references.d.ts +14 -0
  127. package/dist/formats/pdf/references.d.ts.map +1 -0
  128. package/dist/formats/pdf/references.js +104 -0
  129. package/dist/formats/pdf/references.js.map +1 -0
  130. package/dist/formats/pdf/structure.d.ts +29 -0
  131. package/dist/formats/pdf/structure.d.ts.map +1 -0
  132. package/dist/formats/pdf/structure.js +533 -0
  133. package/dist/formats/pdf/structure.js.map +1 -0
  134. package/dist/formats/tei/index.d.ts +7 -0
  135. package/dist/formats/tei/index.d.ts.map +1 -0
  136. package/dist/formats/tei/index.js +7 -0
  137. package/dist/formats/tei/index.js.map +1 -0
  138. package/dist/formats/tei/inline.d.ts +24 -0
  139. package/dist/formats/tei/inline.d.ts.map +1 -0
  140. package/dist/formats/tei/inline.js +107 -0
  141. package/dist/formats/tei/inline.js.map +1 -0
  142. package/dist/formats/tei/parse.d.ts +4 -0
  143. package/dist/formats/tei/parse.d.ts.map +1 -0
  144. package/dist/formats/tei/parse.js +560 -0
  145. package/dist/formats/tei/parse.js.map +1 -0
  146. package/dist/html/dom.d.ts +35 -0
  147. package/dist/html/dom.d.ts.map +1 -0
  148. package/dist/html/dom.js +70 -0
  149. package/dist/html/dom.js.map +1 -0
  150. package/dist/html/interstitial.d.ts +14 -0
  151. package/dist/html/interstitial.d.ts.map +1 -0
  152. package/dist/html/interstitial.js +67 -0
  153. package/dist/html/interstitial.js.map +1 -0
  154. package/dist/html/tables.d.ts +12 -0
  155. package/dist/html/tables.d.ts.map +1 -0
  156. package/dist/html/tables.js +62 -0
  157. package/dist/html/tables.js.map +1 -0
  158. package/dist/index.d.ts +12 -0
  159. package/dist/index.d.ts.map +1 -0
  160. package/dist/index.js +12 -0
  161. package/dist/index.js.map +1 -0
  162. package/dist/model/diagnostics.d.ts +15 -0
  163. package/dist/model/diagnostics.d.ts.map +1 -0
  164. package/dist/model/diagnostics.js +37 -0
  165. package/dist/model/diagnostics.js.map +1 -0
  166. package/dist/model/document.d.ts +289 -0
  167. package/dist/model/document.d.ts.map +1 -0
  168. package/dist/model/document.js +13 -0
  169. package/dist/model/document.js.map +1 -0
  170. package/dist/model/extremes.d.ts +11 -0
  171. package/dist/model/extremes.d.ts.map +1 -0
  172. package/dist/model/extremes.js +23 -0
  173. package/dist/model/extremes.js.map +1 -0
  174. package/dist/model/index.d.ts +8 -0
  175. package/dist/model/index.d.ts.map +1 -0
  176. package/dist/model/index.js +2 -0
  177. package/dist/model/index.js.map +1 -0
  178. package/dist/model/input.d.ts +14 -0
  179. package/dist/model/input.d.ts.map +1 -0
  180. package/dist/model/input.js +47 -0
  181. package/dist/model/input.js.map +1 -0
  182. package/dist/model/result.d.ts +53 -0
  183. package/dist/model/result.d.ts.map +1 -0
  184. package/dist/model/result.js +40 -0
  185. package/dist/model/result.js.map +1 -0
  186. package/dist/model/section-ids.d.ts +8 -0
  187. package/dist/model/section-ids.d.ts.map +1 -0
  188. package/dist/model/section-ids.js +28 -0
  189. package/dist/model/section-ids.js.map +1 -0
  190. package/dist/model/section-kinds.d.ts +19 -0
  191. package/dist/model/section-kinds.d.ts.map +1 -0
  192. package/dist/model/section-kinds.js +42 -0
  193. package/dist/model/section-kinds.js.map +1 -0
  194. package/dist/model/table-grid.d.ts +40 -0
  195. package/dist/model/table-grid.d.ts.map +1 -0
  196. package/dist/model/table-grid.js +79 -0
  197. package/dist/model/table-grid.js.map +1 -0
  198. package/dist/parse.d.ts +18 -0
  199. package/dist/parse.d.ts.map +1 -0
  200. package/dist/parse.js +35 -0
  201. package/dist/parse.js.map +1 -0
  202. package/dist/render/escape.d.ts +53 -0
  203. package/dist/render/escape.d.ts.map +1 -0
  204. package/dist/render/escape.js +94 -0
  205. package/dist/render/escape.js.map +1 -0
  206. package/dist/render/index.d.ts +8 -0
  207. package/dist/render/index.d.ts.map +1 -0
  208. package/dist/render/index.js +8 -0
  209. package/dist/render/index.js.map +1 -0
  210. package/dist/render/inline.d.ts +39 -0
  211. package/dist/render/inline.d.ts.map +1 -0
  212. package/dist/render/inline.js +87 -0
  213. package/dist/render/inline.js.map +1 -0
  214. package/dist/render/markdown.d.ts +35 -0
  215. package/dist/render/markdown.d.ts.map +1 -0
  216. package/dist/render/markdown.js +279 -0
  217. package/dist/render/markdown.js.map +1 -0
  218. package/dist/render/sections.d.ts +25 -0
  219. package/dist/render/sections.d.ts.map +1 -0
  220. package/dist/render/sections.js +45 -0
  221. package/dist/render/sections.js.map +1 -0
  222. package/dist/render/text.d.ts +13 -0
  223. package/dist/render/text.d.ts.map +1 -0
  224. package/dist/render/text.js +66 -0
  225. package/dist/render/text.js.map +1 -0
  226. package/dist/xml/mathml.d.ts +24 -0
  227. package/dist/xml/mathml.d.ts.map +1 -0
  228. package/dist/xml/mathml.js +201 -0
  229. package/dist/xml/mathml.js.map +1 -0
  230. package/dist/xml/ordered.d.ts +49 -0
  231. package/dist/xml/ordered.d.ts.map +1 -0
  232. package/dist/xml/ordered.js +151 -0
  233. package/dist/xml/ordered.js.map +1 -0
  234. package/dist/xml/well-formed.d.ts +15 -0
  235. package/dist/xml/well-formed.d.ts.map +1 -0
  236. package/dist/xml/well-formed.js +120 -0
  237. package/dist/xml/well-formed.js.map +1 -0
  238. package/package.json +137 -0
@@ -0,0 +1,614 @@
1
+ import { issueId } from '../../model/section-ids.js';
2
+ import { splitSectionNumber } from '../../model/section-kinds.js';
3
+ import { escapeInline } from '../../render/escape.js';
4
+ import { emphasis, joinAdjacentMath } from '../../render/inline.js';
5
+ import { attrOf, childrenOf, collapseWhitespace, findAll, findOne, isTextNode, tagNameOf, textOf, } from '../../xml/ordered.js';
6
+ import { formulaParts, inlineMarkdown, inlineText } from './inline.js';
7
+ import { parseBareTable, parseTableWrap } from './tables.js';
8
+ import { rawText, selectAlternative, text } from './text.js';
9
+ /**
10
+ * JATS block-level elements. Membership decides placement: each flushes the prose run
11
+ * and contributes at block position. `address`, `related-article`, and
12
+ * `related-object` are both display and inline in the JATS model; they stay here
13
+ * because a wrong split costs a paragraph break, while a wrong fusion fabricates
14
+ * adjacency the source never had. `<alternatives>` is deliberately absent: it is a
15
+ * container of equivalent renderings, placed wherever its holder is. (#130, #135)
16
+ */
17
+ const BLOCK_TAGS = new Set([
18
+ 'address',
19
+ 'array',
20
+ 'boxed-text',
21
+ 'chem-struct-wrap',
22
+ 'code',
23
+ 'def-list',
24
+ 'disp-formula',
25
+ 'disp-formula-group',
26
+ 'disp-quote',
27
+ 'fig',
28
+ 'fig-group',
29
+ 'fn-group',
30
+ 'graphic',
31
+ 'list',
32
+ 'media',
33
+ 'p',
34
+ 'preformat',
35
+ 'ref-list',
36
+ 'related-article',
37
+ 'related-object',
38
+ 'sec',
39
+ 'sec-meta',
40
+ 'speech',
41
+ 'statement',
42
+ 'supplementary-material',
43
+ 'table-wrap',
44
+ 'table-wrap-group',
45
+ 'title',
46
+ 'verse-group',
47
+ ]);
48
+ /**
49
+ * True when a block-level element sits anywhere in this subtree. An `<alternatives>` is
50
+ * not looked into: a `<graphic>` among its renderings says nothing about the placement
51
+ * of the inline formula holding it, and descending would split the sentence around a
52
+ * rendering the walk then emits as a figure. (#130, #135)
53
+ */
54
+ function containsBlock(node) {
55
+ return childrenOf(node).some((child) => {
56
+ const tag = tagNameOf(child) ?? '';
57
+ return BLOCK_TAGS.has(tag) || (tag !== 'alternatives' && containsBlock(child));
58
+ });
59
+ }
60
+ function flushRun(flow) {
61
+ const text = joinAdjacentMath(collapseWhitespace(flow.run));
62
+ if (text)
63
+ flow.blocks.push({ text, type: 'paragraph' });
64
+ flow.run = '';
65
+ }
66
+ function walk(nodes, flow, ctx) {
67
+ for (const node of nodes) {
68
+ if (isTextNode(node)) {
69
+ flow.run += escapeInline(textOf(node));
70
+ continue;
71
+ }
72
+ const tag = tagNameOf(node) ?? '';
73
+ if (tag === 'alternatives') {
74
+ const chosen = selectAlternative(node);
75
+ if (chosen && BLOCK_TAGS.has(tagNameOf(chosen) ?? '')) {
76
+ flushRun(flow);
77
+ flow.blocks.push(...renderBlock(chosen, ctx));
78
+ }
79
+ else {
80
+ flow.run += inlineMarkdown([node], ctx);
81
+ }
82
+ continue;
83
+ }
84
+ if (tag === 'fn') {
85
+ flow.run += inlineMarkdown([node], ctx);
86
+ continue;
87
+ }
88
+ if (BLOCK_TAGS.has(tag)) {
89
+ flushRun(flow);
90
+ flow.blocks.push(...renderBlock(node, ctx));
91
+ continue;
92
+ }
93
+ if (containsBlock(node))
94
+ walk(childrenOf(node), flow, ctx);
95
+ else
96
+ flow.run += inlineMarkdown([node], ctx);
97
+ }
98
+ }
99
+ /** Blocks for mixed content, in document order. */
100
+ export function flowBlocks(nodes, ctx) {
101
+ const flow = { blocks: [], run: '' };
102
+ walk(nodes, flow, ctx);
103
+ flushRun(flow);
104
+ return flow.blocks;
105
+ }
106
+ /** Render one block-level element. */
107
+ function renderBlock(node, ctx) {
108
+ const children = childrenOf(node);
109
+ switch (tagNameOf(node)) {
110
+ case 'p':
111
+ return flowBlocks(children, ctx);
112
+ case 'title': {
113
+ const title = inlineText(node, ctx);
114
+ return title ? [{ text: emphasis(title, '**'), type: 'paragraph' }] : [];
115
+ }
116
+ case 'sec-meta':
117
+ // A section's own metadata: each keyword group reads as a labeled line (Pensoft's
118
+ // taxon classification). Section contributors and permissions are left out.
119
+ return findAll(node, 'kwd-group').flatMap((group) => {
120
+ const label = inlineText(findOne(group, 'label') ?? findOne(group, 'title'), ctx);
121
+ const words = findAll(group, 'kwd')
122
+ .map((kwd) => inlineText(kwd, ctx))
123
+ .filter(Boolean);
124
+ if (words.length === 0)
125
+ return [];
126
+ const head = label ? `${emphasis(`${label}:`, '**')} ` : '';
127
+ return [{ text: `${head}${words.join(', ')}`, type: 'paragraph' }];
128
+ });
129
+ case 'table-wrap':
130
+ return [parseTableWrap(node, captionText(findOne(node, 'caption'), ctx), ctx)];
131
+ case 'table-wrap-group':
132
+ case 'fig-group':
133
+ case 'disp-formula-group':
134
+ return [
135
+ ...groupCaption(node, ctx),
136
+ ...flowBlocks(withoutTags(children, 'caption', 'label'), ctx),
137
+ ];
138
+ case 'fig': {
139
+ // A figure with no label, caption, or alt text whose file is a `<media>` (a review
140
+ // report's PDF) has nothing to show: it is a file to open.
141
+ const shown = figure(node, ctx);
142
+ const pointer = assetPointer(node);
143
+ const opaque = !shown.label && !shown.caption && !shown.alt;
144
+ const asset = opaque && pointer && tagNameOf(pointer) === 'media' ? supplement(node, ctx) : shown;
145
+ // Figure supplements nest inside their parent figure, often wrapped in a
146
+ // `<p content-type="supplemental-figure">`; they follow it as figures of their own.
147
+ return [asset, ...flowBlocks(withoutTags(children, ...FIGURE_PARTS), ctx)];
148
+ }
149
+ case 'graphic': {
150
+ const href = attrOf(node, 'xlink:href');
151
+ const alt = text(findOne(node, 'alt-text')) || undefined;
152
+ return href ? [{ type: 'figure', href, ...(alt && { alt }) }] : [];
153
+ }
154
+ case 'supplementary-material':
155
+ case 'media':
156
+ return [supplement(node, ctx)];
157
+ case 'list':
158
+ return nonEmpty(list(node, ctx, true));
159
+ case 'def-list':
160
+ return nonEmpty(defList(node, ctx, true));
161
+ case 'disp-quote':
162
+ return [quote(node, ctx)];
163
+ case 'boxed-text':
164
+ return [box(node, ctx, true)];
165
+ case 'statement':
166
+ return [statement(node, ctx)];
167
+ case 'preformat':
168
+ case 'code': {
169
+ const code = rawText(node).replace(/^\s*\n|\s+$/g, '');
170
+ const language = tagNameOf(node) === 'code' ? attrOf(node, 'language') : undefined;
171
+ return code ? [{ text: code, type: 'code', ...(language && { language }) }] : [];
172
+ }
173
+ case 'disp-formula': {
174
+ const formula = displayFormula(node, ctx);
175
+ return formula ? [formula] : [];
176
+ }
177
+ case 'array': {
178
+ // An array holds a `<table>`, or its rows straight in a `<tbody>` (MDPI's abbreviation lists).
179
+ const table = findOne(node, 'table') ?? (findOne(node, 'tbody') && node);
180
+ return table ? [parseBareTable(table, ctx)] : flowBlocks(children, ctx);
181
+ }
182
+ case 'ref-list':
183
+ return [];
184
+ case 'fn-group':
185
+ collectFootnotes(node, ctx);
186
+ return [];
187
+ case 'sec': {
188
+ // A section with nowhere of its own to live (inside a list item): its heading
189
+ // leads its content.
190
+ const title = inlineText(findOne(node, 'title'), ctx);
191
+ const heading = title ? [{ text: emphasis(title, '**'), type: 'paragraph' }] : [];
192
+ return [...heading, ...flowBlocks(withoutTags(children, 'title', 'label'), ctx)];
193
+ }
194
+ default:
195
+ return flowBlocks(children, ctx);
196
+ }
197
+ }
198
+ function nonEmpty(block) {
199
+ return block.items.length > 0 ? [block] : [];
200
+ }
201
+ function withoutTags(nodes, ...tags) {
202
+ return nodes.filter((node) => !tags.includes(tagNameOf(node) ?? ''));
203
+ }
204
+ /**
205
+ * A `<caption>` as one line: its title in bold, then its paragraphs. The title and
206
+ * paragraphs are separate statements; reading them as one run glued the title onto the
207
+ * first sentence. (#111, #134)
208
+ */
209
+ export function captionText(caption, ctx) {
210
+ if (!caption)
211
+ return;
212
+ const parts = [];
213
+ for (const child of childrenOf(caption)) {
214
+ if (isTextNode(child))
215
+ continue;
216
+ const piece = inlineText(child, ctx);
217
+ if (!piece)
218
+ continue;
219
+ parts.push(tagNameOf(child) === 'title' ? emphasis(piece, '**') : piece);
220
+ }
221
+ return parts.join(' ') || undefined;
222
+ }
223
+ /**
224
+ * A figure, table, or formula group's label and caption as one paragraph, the label in
225
+ * bold the way a figure's renders; the panels inside carry neither.
226
+ */
227
+ function groupCaption(group, ctx) {
228
+ const label = text(findOne(group, 'label')).replace(/[.:]\s*$/, '');
229
+ const line = [label && `**${escapeInline(label)}.**`, captionText(findOne(group, 'caption'), ctx)]
230
+ .filter(Boolean)
231
+ .join(' ');
232
+ return line ? [{ text: line, type: 'paragraph' }] : [];
233
+ }
234
+ /** A figure's own parts; anything else inside a `<fig>` is content that follows it. */
235
+ const FIGURE_PARTS = [
236
+ 'alt-text',
237
+ 'alternatives',
238
+ 'attrib',
239
+ 'caption',
240
+ 'graphic',
241
+ 'label',
242
+ 'long-desc',
243
+ 'media',
244
+ 'object-id',
245
+ 'permissions',
246
+ ];
247
+ /** Pointer elements a figure or supplement can carry its file reference on. */
248
+ const POINTER_TAGS = new Set(['graphic', 'media']);
249
+ /**
250
+ * The `<graphic>`/`<media>` an asset hangs its file on: a direct child, else the web
251
+ * rendering its `<alternatives>` offers (JATS4R marks renderings `web` and `print`).
252
+ * (#142)
253
+ */
254
+ function assetPointer(node) {
255
+ const direct = findOne(node, 'graphic') ?? findOne(node, 'media');
256
+ if (direct)
257
+ return direct;
258
+ const pointers = childrenOf(findOne(node, 'alternatives')).filter((child) => POINTER_TAGS.has(tagNameOf(child) ?? ''));
259
+ return (pointers.find((pointer) => attrOf(pointer, 'specific-use')?.toLowerCase().includes('web')) ??
260
+ pointers[0]);
261
+ }
262
+ /**
263
+ * Label, caption, and file reference of a `<fig>` or `<supplementary-material>`. A
264
+ * common deposit style hangs the label and caption on the `<graphic>`/`<media>` instead
265
+ * of the asset; the asset's own win where it has them. (#130)
266
+ */
267
+ function assetParts(node, ctx) {
268
+ const pointer = assetPointer(node);
269
+ const id = attrOf(node, 'id');
270
+ const label = text(findOne(node, 'label')) || text(findOne(pointer, 'label')) || undefined;
271
+ const ownCaption = captionText(findOne(node, 'caption'), ctx) ?? captionText(findOne(pointer, 'caption'), ctx);
272
+ const credit = inlineText(findOne(node, 'attrib'), ctx);
273
+ const caption = [ownCaption, credit].filter(Boolean).join(' ') || undefined;
274
+ const href = pointer ? attrOf(pointer, 'xlink:href') : undefined;
275
+ return { caption, href, id, label, pointer };
276
+ }
277
+ function figure(node, ctx) {
278
+ const { caption, href, id, label, pointer } = assetParts(node, ctx);
279
+ const alt = text(findOne(node, 'alt-text')) || text(findOne(pointer, 'alt-text')) || undefined;
280
+ return {
281
+ type: 'figure',
282
+ ...(id && { id }),
283
+ ...(label && { label }),
284
+ ...(caption && { caption }),
285
+ ...(href && { href }),
286
+ ...(alt && { alt }),
287
+ };
288
+ }
289
+ function supplement(node, ctx) {
290
+ const { caption, href, id, label } = assetParts(node, ctx);
291
+ const ownHref = tagNameOf(node) === 'media' ? attrOf(node, 'xlink:href') : undefined;
292
+ const target = href ?? ownHref;
293
+ return {
294
+ type: 'supplement',
295
+ ...(id && { id }),
296
+ ...(label && { label }),
297
+ ...(caption && { caption }),
298
+ ...(target && { href: target }),
299
+ };
300
+ }
301
+ /** List types JATS numbers or letters. */
302
+ const ORDERED_LIST_TYPE = /^(order|alpha-|roman-)/;
303
+ /** An item label that is only a bullet glyph, which the list marker already draws. */
304
+ const BULLET_LABEL = /^[•◦▪▫●○■□▸►‣⁃∙·*–-]$/u;
305
+ /**
306
+ * A `<list>`. An item's `<label>` ("(a)", "i.") leads its first paragraph, and a list
307
+ * whose items carry labels renders unordered so the printed labels are the only numbering.
308
+ */
309
+ function list(node, ctx, withTitle) {
310
+ const title = withTitle ? inlineText(findOne(node, 'title'), ctx) : '';
311
+ let labeled = false;
312
+ const items = [];
313
+ for (const item of findAll(node, 'list-item')) {
314
+ const label = text(findOne(item, 'label')).replace(BULLET_LABEL, '');
315
+ const blocks = flowBlocks(withoutTags(childrenOf(item), 'label'), ctx);
316
+ if (label) {
317
+ labeled = true;
318
+ const [first] = blocks;
319
+ if (first?.type === 'paragraph')
320
+ first.text = `${escapeInline(label)} ${first.text}`;
321
+ else
322
+ blocks.unshift({ text: escapeInline(label), type: 'paragraph' });
323
+ }
324
+ if (blocks.length > 0)
325
+ items.push(blocks);
326
+ }
327
+ const ordered = !labeled && ORDERED_LIST_TYPE.test(attrOf(node, 'list-type') ?? '');
328
+ return { type: 'list', ordered, items, ...(title && { title }) };
329
+ }
330
+ /** A `<def-list>`: one item per `<def-item>`, the term in bold before its definition. */
331
+ function defList(node, ctx, withTitle) {
332
+ const title = withTitle ? inlineText(findOne(node, 'title'), ctx) : '';
333
+ const items = [];
334
+ for (const item of findAll(node, 'def-item')) {
335
+ const term = inlineText(findOne(item, 'term'), ctx);
336
+ const definition = inlineText(findOne(item, 'def'), ctx);
337
+ const entry = [term && emphasis(term, '**'), definition].filter(Boolean).join(' — ');
338
+ if (entry)
339
+ items.push([{ text: entry, type: 'paragraph' }]);
340
+ }
341
+ return { type: 'list', ordered: false, items, ...(title && { title }) };
342
+ }
343
+ /** A `<disp-quote>`, its `<attrib>` as a trailing attribution line. */
344
+ function quote(node, ctx) {
345
+ const blocks = flowBlocks(withoutTags(childrenOf(node), 'attrib'), ctx);
346
+ const attrib = inlineText(findOne(node, 'attrib'), ctx);
347
+ if (attrib)
348
+ blocks.push({ text: `— ${attrib}`, type: 'paragraph' });
349
+ return { blocks, type: 'quote' };
350
+ }
351
+ /**
352
+ * A `<boxed-text>`. Most are section containers rather than captioned boxes — 13 of 14
353
+ * in a 68-record draw held only `<sec>` children — so nested sections are kept as
354
+ * sections. The caption's title is the box title. (#130, #169)
355
+ */
356
+ function box(node, ctx, withTitle) {
357
+ const caption = findOne(node, 'caption');
358
+ const title = withTitle ? inlineText(findOne(caption, 'title'), ctx) : '';
359
+ const label = text(findOne(node, 'label')) || undefined;
360
+ const id = attrOf(node, 'id');
361
+ const blocks = flowBlocks(withoutTags(childrenOf(caption), 'title'), ctx);
362
+ const sections = [];
363
+ for (const child of childrenOf(node)) {
364
+ const tag = tagNameOf(child);
365
+ if (tag === 'caption' || tag === 'label')
366
+ continue;
367
+ if (tag === 'sec') {
368
+ const section = parseSection(child, ctx, 'body', `${id ?? 'box'}-s${sections.length + 1}`);
369
+ if (section)
370
+ sections.push(section);
371
+ }
372
+ else {
373
+ blocks.push(...flowBlocks([child], ctx));
374
+ }
375
+ }
376
+ return {
377
+ type: 'box',
378
+ ...(id && { id }),
379
+ ...(label && { label }),
380
+ ...(title && { title }),
381
+ blocks,
382
+ sections,
383
+ };
384
+ }
385
+ /** A `<statement>` (theorem, lemma, proof): a box with its label and title. */
386
+ function statement(node, ctx) {
387
+ const id = attrOf(node, 'id');
388
+ const label = text(findOne(node, 'label')) || undefined;
389
+ const title = inlineText(findOne(node, 'title'), ctx);
390
+ return {
391
+ type: 'box',
392
+ ...(id && { id }),
393
+ ...(label && { label }),
394
+ ...(title && { title }),
395
+ blocks: flowBlocks(withoutTags(childrenOf(node), 'label', 'title'), ctx),
396
+ sections: [],
397
+ };
398
+ }
399
+ /**
400
+ * A `<disp-formula>`: TeX from `<tex-math>` or converted MathML, else text, else the
401
+ * image it is published as. (#130, #135)
402
+ */
403
+ function displayFormula(node, ctx) {
404
+ const parts = formulaParts(node, ctx);
405
+ if (!parts)
406
+ return;
407
+ const id = attrOf(node, 'id');
408
+ const label = text(findOne(node, 'label')) || undefined;
409
+ return { type: 'formula', ...(id && { id }), ...(label && { label }), ...parts };
410
+ }
411
+ /** Collect every `<fn>` under a node into the document's footnotes. */
412
+ export function collectFootnotes(node, ctx) {
413
+ for (const fn of childrenOf(node)) {
414
+ const tag = tagNameOf(fn);
415
+ if (tag === 'fn') {
416
+ const label = text(findOne(fn, 'label')) || undefined;
417
+ const body = flowBlocks(withoutTags(childrenOf(fn), 'label'), ctx)
418
+ .map((block) => (block.type === 'paragraph' ? block.text : ''))
419
+ .filter(Boolean)
420
+ .join(' ');
421
+ const id = attrOf(fn, 'id');
422
+ if (body)
423
+ ctx.footnotes.push({ ...(id && { id }), ...(label && { label }), text: body });
424
+ }
425
+ else if (tag && tag !== 'title' && tag !== 'label') {
426
+ collectFootnotes(fn, ctx);
427
+ }
428
+ }
429
+ }
430
+ // ─── Sections ───────────────────────────────────────────────────────────────
431
+ /**
432
+ * The title a block carries of its own where the JATS model puts one: a `<list>` or
433
+ * `<def-list>` `<title>`, a `<boxed-text>` caption title. (#148)
434
+ */
435
+ export function ownBlockTitle(node, ctx) {
436
+ switch (tagNameOf(node)) {
437
+ case 'def-list':
438
+ case 'list':
439
+ return inlineText(findOne(node, 'title'), ctx) || undefined;
440
+ case 'boxed-text':
441
+ return inlineText(findOne(findOne(node, 'caption'), 'title'), ctx) || undefined;
442
+ default:
443
+ return;
444
+ }
445
+ }
446
+ /** A block whose own title has become its section's title, rendered without it. */
447
+ export function blocksWithoutTitle(node, ctx) {
448
+ switch (tagNameOf(node)) {
449
+ case 'def-list':
450
+ return nonEmpty(defList(node, ctx, false));
451
+ case 'list':
452
+ return nonEmpty(list(node, ctx, false));
453
+ case 'boxed-text':
454
+ return [box(node, ctx, false)];
455
+ default:
456
+ return renderBlock(node, ctx);
457
+ }
458
+ }
459
+ /** A child that reads as a subsection of its parent, not as its content. */
460
+ function isSubsectionTag(node) {
461
+ const tag = tagNameOf(node);
462
+ return tag === 'sec' || (tag === 'notes' && text(findOne(node, 'title')) !== '');
463
+ }
464
+ /**
465
+ * True when a titled `<notes>` can be a subsection: nothing but other subsections
466
+ * follows it. A section's blocks come before its subsections, and unlike `<sec>`,
467
+ * which JATS places after every paragraph, `<notes>` may be followed by more text,
468
+ * which would otherwise move above it.
469
+ */
470
+ function isTrailingNotes(notes, siblings) {
471
+ if (!isSubsectionTag(notes))
472
+ return false;
473
+ return siblings
474
+ .slice(siblings.indexOf(notes) + 1)
475
+ .every((sibling) => isTextNode(sibling)
476
+ ? textOf(sibling).trim() === ''
477
+ : isSubsectionTag(sibling) || ['label', 'title'].includes(tagNameOf(sibling) ?? ''));
478
+ }
479
+ /** The one element a `<sec>` holds besides its title and label, if it holds only one. */
480
+ function loneContent(sec) {
481
+ const content = childrenOf(sec).filter((child) => isTextNode(child)
482
+ ? textOf(child).trim() !== ''
483
+ : !['title', 'label'].includes(tagNameOf(child) ?? ''));
484
+ const [node] = content;
485
+ return content.length === 1 && node && !isTextNode(node) ? node : undefined;
486
+ }
487
+ /**
488
+ * The titled `<list>`, `<def-list>`, or `<boxed-text>` an untitled `<sec>` carries as
489
+ * its only content. A `<sec>` holding nothing but an abbreviations list is that list,
490
+ * and the list's title is the section's. (#148, #169)
491
+ */
492
+ function loneTitledBlock(sec, ctx) {
493
+ if (text(findOne(sec, 'title')))
494
+ return;
495
+ const node = loneContent(sec);
496
+ const title = node && ownBlockTitle(node, ctx);
497
+ return node && title ? { node, title } : undefined;
498
+ }
499
+ /** A title that says only that notes follow. */
500
+ const NOTES_TITLE = /^(?:foot)?notes?$/i;
501
+ /**
502
+ * True when a title names what a group of notes holds (`Competing interests`), which
503
+ * makes the notes that section's content, rather than saying only that notes follow.
504
+ */
505
+ function namesNotes(title) {
506
+ return title !== undefined && title !== '' && !NOTES_TITLE.test(title);
507
+ }
508
+ /**
509
+ * The notes of an `<fn-group>` read as content: each `<fn>`'s blocks, its label dropped.
510
+ * A note authors point at leads with their names, since eLife's contribution and
511
+ * competing-interest notes do not name the author themselves.
512
+ */
513
+ function noteBlocks(group, ctx) {
514
+ return findAll(group, 'fn').flatMap((fn) => {
515
+ const blocks = flowBlocks(withoutTags(childrenOf(fn), 'label'), ctx);
516
+ const owners = ctx.noteOwners.get(attrOf(fn, 'id') ?? '');
517
+ const [first, ...rest] = blocks;
518
+ if (!owners || first?.type !== 'paragraph')
519
+ return blocks;
520
+ const lead = emphasis(`${escapeInline(owners.join(', '))}:`, '**');
521
+ return [{ ...first, text: `${lead} ${first.text}` }, ...rest];
522
+ });
523
+ }
524
+ /**
525
+ * An `<fn-group>` whose title names what its notes hold (eLife's `Author contributions`)
526
+ * as a section of those notes. Undefined for a group of footnotes: untitled, or titled
527
+ * only `Footnotes`.
528
+ */
529
+ export function noteGroupSection(group, ctx, kind, fallbackId) {
530
+ const title = inlineText(findOne(group, 'title'), ctx);
531
+ if (!namesNotes(title))
532
+ return;
533
+ const blocks = noteBlocks(group, ctx);
534
+ if (blocks.length === 0)
535
+ return;
536
+ const id = issueId(ctx.sectionIds, attrOf(group, 'id'), fallbackId);
537
+ return { blocks, id, kind, sections: [], title };
538
+ }
539
+ /**
540
+ * One `<sec>`: its first `<title>` and `<label>`, subsections (each `<sec>`, and each
541
+ * titled `<notes>` that {@link isTrailingNotes} allows), and every other child as blocks
542
+ * at its position. A section with no blocks and no subsections — a `<sec>` that
543
+ * only wraps a `<ref-list>` — is dropped, and so is Europe PMC's generated
544
+ * `sec-type="history"` note, whose received and accepted dates the metadata carries.
545
+ * (#116, #130)
546
+ *
547
+ * An `<fn-group>` with a title naming its notes is a subsection of them, and an untitled
548
+ * one that is all a `<sec>` holds is that section's content when the section's title
549
+ * names its notes: Europe PMC wraps each back `<fn-group>` in a `<sec>` carrying the
550
+ * group's title, `Footnotes` when it had none. Any other group holds footnotes.
551
+ */
552
+ export function parseSection(sec, ctx, kind, fallbackId) {
553
+ if (attrOf(sec, 'sec-type') === 'history')
554
+ return;
555
+ const id = issueId(ctx.sectionIds, attrOf(sec, 'id'), fallbackId);
556
+ const lone = loneTitledBlock(sec, ctx);
557
+ if (lone) {
558
+ const label = text(findOne(sec, 'label')) || undefined;
559
+ const blocks = blocksWithoutTitle(lone.node, ctx);
560
+ return { blocks, id, kind, ...(label && { label }), sections: [], title: lone.title };
561
+ }
562
+ let title;
563
+ let label;
564
+ const blocks = [];
565
+ const sections = [];
566
+ const children = childrenOf(sec);
567
+ const only = loneContent(sec);
568
+ const notesAreContent = only !== undefined &&
569
+ tagNameOf(only) === 'fn-group' &&
570
+ namesNotes(inlineText(findOne(sec, 'title'), ctx));
571
+ for (const child of children) {
572
+ const tag = tagNameOf(child);
573
+ if (tag === 'title' && title === undefined) {
574
+ title = inlineText(child, ctx) || undefined;
575
+ continue;
576
+ }
577
+ if (tag === 'label' && label === undefined) {
578
+ label = text(child) || undefined;
579
+ continue;
580
+ }
581
+ if (tag === 'sec' || (tag === 'notes' && isTrailingNotes(child, children))) {
582
+ const section = parseSection(child, ctx, kind, `${id}.${sections.length + 1}`);
583
+ if (section)
584
+ sections.push(section);
585
+ continue;
586
+ }
587
+ if (tag === 'fn-group') {
588
+ const group = noteGroupSection(child, ctx, kind, `${id}.${sections.length + 1}`);
589
+ if (group) {
590
+ sections.push(group);
591
+ continue;
592
+ }
593
+ if (notesAreContent) {
594
+ blocks.push(...noteBlocks(child, ctx));
595
+ continue;
596
+ }
597
+ }
598
+ blocks.push(...flowBlocks([child], ctx));
599
+ }
600
+ if (blocks.length === 0 && sections.length === 0) {
601
+ ctx.sectionIds.delete(id);
602
+ return;
603
+ }
604
+ const heading = splitSectionNumber(title, label);
605
+ return {
606
+ blocks,
607
+ id,
608
+ kind,
609
+ ...(heading.label && { label: heading.label }),
610
+ sections,
611
+ ...(heading.title && { title: heading.title }),
612
+ };
613
+ }
614
+ //# sourceMappingURL=blocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../../src/formats/jats/blocks.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EACL,MAAM,EACN,UAAU,EACV,kBAAkB,EAClB,OAAO,EACP,OAAO,EACP,UAAU,EACV,SAAS,EACT,MAAM,GAGP,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAC;IAC9C,SAAS;IACT,OAAO;IACP,YAAY;IACZ,kBAAkB;IAClB,MAAM;IACN,UAAU;IACV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