@manuscripts/transform 1.0.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 (315) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +193 -0
  3. package/dist/cjs/errors.js +17 -0
  4. package/dist/cjs/index.js +27 -0
  5. package/dist/cjs/jats/importer/index.js +24 -0
  6. package/dist/cjs/jats/importer/jats-body-dom-parser.js +650 -0
  7. package/dist/cjs/jats/importer/jats-body-transformations.js +269 -0
  8. package/dist/cjs/jats/importer/jats-comments.js +131 -0
  9. package/dist/cjs/jats/importer/jats-front-parser.js +341 -0
  10. package/dist/cjs/jats/importer/jats-journal-meta-parser.js +77 -0
  11. package/dist/cjs/jats/importer/jats-parser-utils.js +145 -0
  12. package/dist/cjs/jats/importer/jats-reference-parser.js +180 -0
  13. package/dist/cjs/jats/importer/parse-jats-article.js +237 -0
  14. package/dist/cjs/jats/index.js +40 -0
  15. package/dist/cjs/jats/jats-exporter.js +1569 -0
  16. package/dist/cjs/jats/jats-versions.js +41 -0
  17. package/dist/cjs/lib/attributes.js +26 -0
  18. package/dist/cjs/lib/html.js +48 -0
  19. package/dist/cjs/lib/styled-content.js +28 -0
  20. package/dist/cjs/lib/table-cell-styles.js +52 -0
  21. package/dist/cjs/lib/utils.js +66 -0
  22. package/dist/cjs/mathjax/index.js +41 -0
  23. package/dist/cjs/mathjax/mathjax-packages.js +20 -0
  24. package/dist/cjs/mathjax/mathml-to-svg.js +56 -0
  25. package/dist/cjs/mathjax/tex-to-mathml.js +49 -0
  26. package/dist/cjs/mathjax/tex-to-svg.js +59 -0
  27. package/dist/cjs/schema/groups.js +31 -0
  28. package/dist/cjs/schema/index.js +195 -0
  29. package/dist/cjs/schema/marks.js +159 -0
  30. package/dist/cjs/schema/nodes/attribution.js +32 -0
  31. package/dist/cjs/schema/nodes/bibliography_element.js +44 -0
  32. package/dist/cjs/schema/nodes/bibliography_item.js +101 -0
  33. package/dist/cjs/schema/nodes/bibliography_section.js +46 -0
  34. package/dist/cjs/schema/nodes/blockquote_element.js +62 -0
  35. package/dist/cjs/schema/nodes/caption.js +52 -0
  36. package/dist/cjs/schema/nodes/caption_title.js +51 -0
  37. package/dist/cjs/schema/nodes/citation.js +52 -0
  38. package/dist/cjs/schema/nodes/comment.js +26 -0
  39. package/dist/cjs/schema/nodes/cross_reference.js +58 -0
  40. package/dist/cjs/schema/nodes/doc.js +21 -0
  41. package/dist/cjs/schema/nodes/equation.js +55 -0
  42. package/dist/cjs/schema/nodes/equation_element.js +52 -0
  43. package/dist/cjs/schema/nodes/figcaption.js +31 -0
  44. package/dist/cjs/schema/nodes/figure.js +52 -0
  45. package/dist/cjs/schema/nodes/figure_element.js +78 -0
  46. package/dist/cjs/schema/nodes/footnote.js +67 -0
  47. package/dist/cjs/schema/nodes/footnotes_element.js +54 -0
  48. package/dist/cjs/schema/nodes/footnotes_section.js +45 -0
  49. package/dist/cjs/schema/nodes/graphical_abstract_section.js +46 -0
  50. package/dist/cjs/schema/nodes/hard_break.js +30 -0
  51. package/dist/cjs/schema/nodes/highlight_marker.js +53 -0
  52. package/dist/cjs/schema/nodes/inline_equation.js +58 -0
  53. package/dist/cjs/schema/nodes/inline_footnote.js +51 -0
  54. package/dist/cjs/schema/nodes/keywords_element.js +52 -0
  55. package/dist/cjs/schema/nodes/keywords_section.js +46 -0
  56. package/dist/cjs/schema/nodes/link.js +61 -0
  57. package/dist/cjs/schema/nodes/list.js +121 -0
  58. package/dist/cjs/schema/nodes/listing.js +73 -0
  59. package/dist/cjs/schema/nodes/listing_element.js +52 -0
  60. package/dist/cjs/schema/nodes/manuscript.js +46 -0
  61. package/dist/cjs/schema/nodes/missing_figure.js +50 -0
  62. package/dist/cjs/schema/nodes/paragraph.js +63 -0
  63. package/dist/cjs/schema/nodes/placeholder.js +49 -0
  64. package/dist/cjs/schema/nodes/placeholder_element.js +48 -0
  65. package/dist/cjs/schema/nodes/pullquote_element.js +65 -0
  66. package/dist/cjs/schema/nodes/section.js +94 -0
  67. package/dist/cjs/schema/nodes/section_label.js +30 -0
  68. package/dist/cjs/schema/nodes/section_title.js +48 -0
  69. package/dist/cjs/schema/nodes/table.js +70 -0
  70. package/dist/cjs/schema/nodes/table_col.js +57 -0
  71. package/dist/cjs/schema/nodes/table_element.js +62 -0
  72. package/dist/cjs/schema/nodes/table_row.js +123 -0
  73. package/dist/cjs/schema/nodes/text.js +21 -0
  74. package/dist/cjs/schema/nodes/toc_element.js +52 -0
  75. package/dist/cjs/schema/nodes/toc_section.js +46 -0
  76. package/dist/cjs/schema/types.js +17 -0
  77. package/dist/cjs/tests.js +30 -0
  78. package/dist/cjs/transformer/builders.js +305 -0
  79. package/dist/cjs/transformer/bundles-data.js +36 -0
  80. package/dist/cjs/transformer/bundles.js +32 -0
  81. package/dist/cjs/transformer/decode.js +619 -0
  82. package/dist/cjs/transformer/document-object-types.js +31 -0
  83. package/dist/cjs/transformer/encode.js +545 -0
  84. package/dist/cjs/transformer/filename.js +27 -0
  85. package/dist/cjs/transformer/footnote-category.js +20 -0
  86. package/dist/cjs/transformer/footnotes-order.js +59 -0
  87. package/dist/cjs/transformer/highlight-markers.js +126 -0
  88. package/dist/cjs/transformer/html.js +414 -0
  89. package/dist/cjs/transformer/id.js +28 -0
  90. package/dist/cjs/transformer/index.js +54 -0
  91. package/dist/cjs/transformer/labels.js +85 -0
  92. package/dist/cjs/transformer/manuscript-dependencies.js +74 -0
  93. package/dist/cjs/transformer/model-map.js +26 -0
  94. package/dist/cjs/transformer/models.js +17 -0
  95. package/dist/cjs/transformer/node-names.js +42 -0
  96. package/dist/cjs/transformer/node-title.js +87 -0
  97. package/dist/cjs/transformer/node-types.js +62 -0
  98. package/dist/cjs/transformer/object-types.js +57 -0
  99. package/dist/cjs/transformer/project-bundle.js +86 -0
  100. package/dist/cjs/transformer/section-category.js +222 -0
  101. package/dist/cjs/transformer/serializer.js +23 -0
  102. package/dist/cjs/transformer/shared-data.js +31 -0
  103. package/dist/cjs/transformer/tei-grobid-importer.js +121 -0
  104. package/dist/cjs/transformer/timestamp.js +20 -0
  105. package/dist/cjs/transformer/update-identifiers.js +93 -0
  106. package/dist/cjs/types.js +2 -0
  107. package/dist/es/errors.js +12 -0
  108. package/dist/es/index.js +9 -0
  109. package/dist/es/jats/importer/index.js +16 -0
  110. package/dist/es/jats/importer/jats-body-dom-parser.js +644 -0
  111. package/dist/es/jats/importer/jats-body-transformations.js +266 -0
  112. package/dist/es/jats/importer/jats-comments.js +124 -0
  113. package/dist/es/jats/importer/jats-front-parser.js +335 -0
  114. package/dist/es/jats/importer/jats-journal-meta-parser.js +70 -0
  115. package/dist/es/jats/importer/jats-parser-utils.js +139 -0
  116. package/dist/es/jats/importer/jats-reference-parser.js +177 -0
  117. package/dist/es/jats/importer/parse-jats-article.js +229 -0
  118. package/dist/es/jats/index.js +18 -0
  119. package/dist/es/jats/jats-exporter.js +1561 -0
  120. package/dist/es/jats/jats-versions.js +36 -0
  121. package/dist/es/lib/attributes.js +22 -0
  122. package/dist/es/lib/html.js +43 -0
  123. package/dist/es/lib/styled-content.js +23 -0
  124. package/dist/es/lib/table-cell-styles.js +47 -0
  125. package/dist/es/lib/utils.js +59 -0
  126. package/dist/es/mathjax/index.js +12 -0
  127. package/dist/es/mathjax/mathjax-packages.js +17 -0
  128. package/dist/es/mathjax/mathml-to-svg.js +52 -0
  129. package/dist/es/mathjax/tex-to-mathml.js +45 -0
  130. package/dist/es/mathjax/tex-to-svg.js +55 -0
  131. package/dist/es/schema/groups.js +27 -0
  132. package/dist/es/schema/index.js +178 -0
  133. package/dist/es/schema/marks.js +156 -0
  134. package/dist/es/schema/nodes/attribution.js +29 -0
  135. package/dist/es/schema/nodes/bibliography_element.js +41 -0
  136. package/dist/es/schema/nodes/bibliography_item.js +98 -0
  137. package/dist/es/schema/nodes/bibliography_section.js +42 -0
  138. package/dist/es/schema/nodes/blockquote_element.js +58 -0
  139. package/dist/es/schema/nodes/caption.js +49 -0
  140. package/dist/es/schema/nodes/caption_title.js +48 -0
  141. package/dist/es/schema/nodes/citation.js +48 -0
  142. package/dist/es/schema/nodes/comment.js +23 -0
  143. package/dist/es/schema/nodes/cross_reference.js +55 -0
  144. package/dist/es/schema/nodes/doc.js +18 -0
  145. package/dist/es/schema/nodes/equation.js +52 -0
  146. package/dist/es/schema/nodes/equation_element.js +49 -0
  147. package/dist/es/schema/nodes/figcaption.js +28 -0
  148. package/dist/es/schema/nodes/figure.js +49 -0
  149. package/dist/es/schema/nodes/figure_element.js +74 -0
  150. package/dist/es/schema/nodes/footnote.js +63 -0
  151. package/dist/es/schema/nodes/footnotes_element.js +50 -0
  152. package/dist/es/schema/nodes/footnotes_section.js +41 -0
  153. package/dist/es/schema/nodes/graphical_abstract_section.js +42 -0
  154. package/dist/es/schema/nodes/hard_break.js +27 -0
  155. package/dist/es/schema/nodes/highlight_marker.js +49 -0
  156. package/dist/es/schema/nodes/inline_equation.js +55 -0
  157. package/dist/es/schema/nodes/inline_footnote.js +47 -0
  158. package/dist/es/schema/nodes/keywords_element.js +49 -0
  159. package/dist/es/schema/nodes/keywords_section.js +42 -0
  160. package/dist/es/schema/nodes/link.js +58 -0
  161. package/dist/es/schema/nodes/list.js +117 -0
  162. package/dist/es/schema/nodes/listing.js +69 -0
  163. package/dist/es/schema/nodes/listing_element.js +49 -0
  164. package/dist/es/schema/nodes/manuscript.js +43 -0
  165. package/dist/es/schema/nodes/missing_figure.js +47 -0
  166. package/dist/es/schema/nodes/paragraph.js +59 -0
  167. package/dist/es/schema/nodes/placeholder.js +46 -0
  168. package/dist/es/schema/nodes/placeholder_element.js +45 -0
  169. package/dist/es/schema/nodes/pullquote_element.js +61 -0
  170. package/dist/es/schema/nodes/section.js +90 -0
  171. package/dist/es/schema/nodes/section_label.js +26 -0
  172. package/dist/es/schema/nodes/section_title.js +44 -0
  173. package/dist/es/schema/nodes/table.js +67 -0
  174. package/dist/es/schema/nodes/table_col.js +54 -0
  175. package/dist/es/schema/nodes/table_element.js +59 -0
  176. package/dist/es/schema/nodes/table_row.js +120 -0
  177. package/dist/es/schema/nodes/text.js +18 -0
  178. package/dist/es/schema/nodes/toc_element.js +49 -0
  179. package/dist/es/schema/nodes/toc_section.js +42 -0
  180. package/dist/es/schema/types.js +16 -0
  181. package/dist/es/tests.js +28 -0
  182. package/dist/es/transformer/builders.js +261 -0
  183. package/dist/es/transformer/bundles-data.js +8 -0
  184. package/dist/es/transformer/bundles.js +27 -0
  185. package/dist/es/transformer/decode.js +608 -0
  186. package/dist/es/transformer/document-object-types.js +28 -0
  187. package/dist/es/transformer/encode.js +535 -0
  188. package/dist/es/transformer/filename.js +23 -0
  189. package/dist/es/transformer/footnote-category.js +16 -0
  190. package/dist/es/transformer/footnotes-order.js +53 -0
  191. package/dist/es/transformer/highlight-markers.js +120 -0
  192. package/dist/es/transformer/html.js +407 -0
  193. package/dist/es/transformer/id.js +23 -0
  194. package/dist/es/transformer/index.js +38 -0
  195. package/dist/es/transformer/labels.js +81 -0
  196. package/dist/es/transformer/manuscript-dependencies.js +64 -0
  197. package/dist/es/transformer/model-map.js +22 -0
  198. package/dist/es/transformer/models.js +16 -0
  199. package/dist/es/transformer/node-names.js +39 -0
  200. package/dist/es/transformer/node-title.js +82 -0
  201. package/dist/es/transformer/node-types.js +55 -0
  202. package/dist/es/transformer/object-types.js +52 -0
  203. package/dist/es/transformer/project-bundle.js +77 -0
  204. package/dist/es/transformer/section-category.js +210 -0
  205. package/dist/es/transformer/serializer.js +17 -0
  206. package/dist/es/transformer/shared-data.js +1 -0
  207. package/dist/es/transformer/tei-grobid-importer.js +115 -0
  208. package/dist/es/transformer/timestamp.js +16 -0
  209. package/dist/es/transformer/update-identifiers.js +87 -0
  210. package/dist/es/types.js +1 -0
  211. package/dist/types/errors.d.ts +6 -0
  212. package/dist/types/index.d.ts +9 -0
  213. package/dist/types/jats/importer/index.d.ts +16 -0
  214. package/dist/types/jats/importer/jats-body-dom-parser.d.ts +24 -0
  215. package/dist/types/jats/importer/jats-body-transformations.d.ts +31 -0
  216. package/dist/types/jats/importer/jats-comments.d.ts +26 -0
  217. package/dist/types/jats/importer/jats-front-parser.d.ts +62 -0
  218. package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +37 -0
  219. package/dist/types/jats/importer/jats-parser-utils.d.ts +23 -0
  220. package/dist/types/jats/importer/jats-reference-parser.d.ts +23 -0
  221. package/dist/types/jats/importer/parse-jats-article.d.ts +30 -0
  222. package/dist/types/jats/index.d.ts +18 -0
  223. package/dist/types/jats/jats-exporter.d.ts +72 -0
  224. package/dist/types/jats/jats-versions.d.ts +23 -0
  225. package/dist/types/lib/attributes.d.ts +20 -0
  226. package/dist/types/lib/html.d.ts +17 -0
  227. package/dist/types/lib/styled-content.d.ts +22 -0
  228. package/dist/types/lib/table-cell-styles.d.ts +27 -0
  229. package/dist/types/lib/utils.d.ts +26 -0
  230. package/dist/types/mathjax/index.d.ts +3 -0
  231. package/dist/types/mathjax/mathjax-packages.d.ts +16 -0
  232. package/dist/types/mathjax/mathml-to-svg.d.ts +17 -0
  233. package/dist/types/mathjax/tex-to-mathml.d.ts +17 -0
  234. package/dist/types/mathjax/tex-to-svg.d.ts +17 -0
  235. package/dist/types/schema/groups.d.ts +22 -0
  236. package/dist/types/schema/index.d.ts +65 -0
  237. package/dist/types/schema/marks.d.ts +27 -0
  238. package/dist/types/schema/nodes/attribution.d.ts +21 -0
  239. package/dist/types/schema/nodes/bibliography_element.d.ts +26 -0
  240. package/dist/types/schema/nodes/bibliography_item.d.ts +36 -0
  241. package/dist/types/schema/nodes/bibliography_section.d.ts +26 -0
  242. package/dist/types/schema/nodes/blockquote_element.d.ts +28 -0
  243. package/dist/types/schema/nodes/caption.d.ts +25 -0
  244. package/dist/types/schema/nodes/caption_title.d.ts +25 -0
  245. package/dist/types/schema/nodes/citation.d.ts +27 -0
  246. package/dist/types/schema/nodes/comment.d.ts +31 -0
  247. package/dist/types/schema/nodes/cross_reference.d.ts +26 -0
  248. package/dist/types/schema/nodes/doc.d.ts +17 -0
  249. package/dist/types/schema/nodes/equation.d.ts +28 -0
  250. package/dist/types/schema/nodes/equation_element.d.ts +29 -0
  251. package/dist/types/schema/nodes/figcaption.d.ts +21 -0
  252. package/dist/types/schema/nodes/figure.d.ts +25 -0
  253. package/dist/types/schema/nodes/figure_element.d.ts +44 -0
  254. package/dist/types/schema/nodes/footnote.d.ts +32 -0
  255. package/dist/types/schema/nodes/footnotes_element.d.ts +28 -0
  256. package/dist/types/schema/nodes/footnotes_section.d.ts +26 -0
  257. package/dist/types/schema/nodes/graphical_abstract_section.d.ts +26 -0
  258. package/dist/types/schema/nodes/hard_break.d.ts +21 -0
  259. package/dist/types/schema/nodes/highlight_marker.d.ts +29 -0
  260. package/dist/types/schema/nodes/inline_equation.d.ts +28 -0
  261. package/dist/types/schema/nodes/inline_footnote.d.ts +27 -0
  262. package/dist/types/schema/nodes/keywords_element.d.ts +27 -0
  263. package/dist/types/schema/nodes/keywords_section.d.ts +26 -0
  264. package/dist/types/schema/nodes/link.d.ts +26 -0
  265. package/dist/types/schema/nodes/list.d.ts +39 -0
  266. package/dist/types/schema/nodes/listing.d.ts +33 -0
  267. package/dist/types/schema/nodes/listing_element.d.ts +29 -0
  268. package/dist/types/schema/nodes/manuscript.d.ts +23 -0
  269. package/dist/types/schema/nodes/missing_figure.d.ts +23 -0
  270. package/dist/types/schema/nodes/paragraph.d.ts +30 -0
  271. package/dist/types/schema/nodes/placeholder.d.ts +26 -0
  272. package/dist/types/schema/nodes/placeholder_element.d.ts +25 -0
  273. package/dist/types/schema/nodes/pullquote_element.d.ts +28 -0
  274. package/dist/types/schema/nodes/section.d.ts +36 -0
  275. package/dist/types/schema/nodes/section_label.d.ts +22 -0
  276. package/dist/types/schema/nodes/section_title.d.ts +22 -0
  277. package/dist/types/schema/nodes/table.d.ts +27 -0
  278. package/dist/types/schema/nodes/table_col.d.ts +24 -0
  279. package/dist/types/schema/nodes/table_element.d.ts +35 -0
  280. package/dist/types/schema/nodes/table_row.d.ts +41 -0
  281. package/dist/types/schema/nodes/text.d.ts +17 -0
  282. package/dist/types/schema/nodes/toc_element.d.ts +27 -0
  283. package/dist/types/schema/nodes/toc_section.d.ts +26 -0
  284. package/dist/types/schema/types.d.ts +45 -0
  285. package/dist/types/tests.d.ts +16 -0
  286. package/dist/types/transformer/builders.d.ts +74 -0
  287. package/dist/types/transformer/bundles-data.d.ts +3 -0
  288. package/dist/types/transformer/bundles.d.ts +3 -0
  289. package/dist/types/transformer/decode.d.ts +38 -0
  290. package/dist/types/transformer/document-object-types.d.ts +17 -0
  291. package/dist/types/transformer/encode.d.ts +29 -0
  292. package/dist/types/transformer/filename.d.ts +16 -0
  293. package/dist/types/transformer/footnote-category.d.ts +17 -0
  294. package/dist/types/transformer/footnotes-order.d.ts +23 -0
  295. package/dist/types/transformer/highlight-markers.d.ts +26 -0
  296. package/dist/types/transformer/html.d.ts +36 -0
  297. package/dist/types/transformer/id.d.ts +20 -0
  298. package/dist/types/transformer/index.d.ts +38 -0
  299. package/dist/types/transformer/labels.d.ts +24 -0
  300. package/dist/types/transformer/manuscript-dependencies.d.ts +12 -0
  301. package/dist/types/transformer/model-map.d.ts +19 -0
  302. package/dist/types/transformer/models.d.ts +48 -0
  303. package/dist/types/transformer/node-names.d.ts +17 -0
  304. package/dist/types/transformer/node-title.d.ts +19 -0
  305. package/dist/types/transformer/node-types.d.ts +22 -0
  306. package/dist/types/transformer/object-types.d.ts +29 -0
  307. package/dist/types/transformer/project-bundle.d.ts +30 -0
  308. package/dist/types/transformer/section-category.d.ts +28 -0
  309. package/dist/types/transformer/serializer.d.ts +19 -0
  310. package/dist/types/transformer/shared-data.d.ts +2 -0
  311. package/dist/types/transformer/tei-grobid-importer.d.ts +20 -0
  312. package/dist/types/transformer/timestamp.d.ts +16 -0
  313. package/dist/types/transformer/update-identifiers.d.ts +23 -0
  314. package/dist/types/types.d.ts +2 -0
  315. package/package.json +89 -0
@@ -0,0 +1,115 @@
1
+ /*!
2
+ * © 2020 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { buildAffiliation, buildBibliographicDate, buildBibliographicName, buildBibliographyItem, buildContributor, buildManuscript, } from './builders';
17
+ import { addModelToMap } from './model-map';
18
+ const iterateSnapshot = function* (snapshot) {
19
+ for (let i = 0; i < snapshot.snapshotLength; i++) {
20
+ yield snapshot.snapshotItem(i);
21
+ }
22
+ };
23
+ const namespaces = new Map([
24
+ [null, 'http://www.tei-c.org/ns/1.0'],
25
+ ]);
26
+ const namespaceResolver = (prefix) => namespaces.get(prefix) || null;
27
+ export const parseFront = (doc, addModel) => {
28
+ const headerNode = doc.evaluate('/TEI/teiHeader', doc, namespaceResolver, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue;
29
+ if (!headerNode) {
30
+ throw new Error('No header element found!');
31
+ }
32
+ const title = doc.evaluate('fileDesc/titleStmt/title', headerNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
33
+ const manuscript = buildManuscript(title);
34
+ addModel(manuscript);
35
+ const affiliationsMap = new Map();
36
+ const authorNodes = doc.evaluate('fileDesc/sourceDesc/biblStruct/analytic/author', headerNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
37
+ for (const authorNode of iterateSnapshot(authorNodes)) {
38
+ const name = buildBibliographicName({});
39
+ name.given = doc.evaluate('persName/forename', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
40
+ name.family = doc.evaluate('persName/surname', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
41
+ const contributor = buildContributor(name, 'author', 1);
42
+ contributor.affiliations = [];
43
+ const affiliationNodes = doc.evaluate('affiliation', authorNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
44
+ for (const affiliationNode of iterateSnapshot(affiliationNodes)) {
45
+ const key = affiliationNode.getAttribute('key');
46
+ if (key) {
47
+ const affiliation = affiliationsMap.get(key);
48
+ if (affiliation) {
49
+ contributor.affiliations.push(affiliation._id);
50
+ }
51
+ else {
52
+ const affiliation = buildAffiliation('', 1);
53
+ affiliation.institution = doc.evaluate('orgName[@type="institution"]', affiliationNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
54
+ affiliation.department = doc.evaluate('orgName[@type="department"]', affiliationNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
55
+ addModel(affiliation);
56
+ affiliationsMap.set(key, affiliation);
57
+ contributor.affiliations.push(affiliation._id);
58
+ }
59
+ }
60
+ }
61
+ addModel(contributor);
62
+ }
63
+ };
64
+ const chooseBibliographyItemType = (publicationType) => {
65
+ switch (publicationType) {
66
+ case 'book':
67
+ case 'thesis':
68
+ return publicationType;
69
+ case 'journal':
70
+ default:
71
+ return 'article-journal';
72
+ }
73
+ };
74
+ export const parseBack = (doc, addModel) => {
75
+ const backNode = doc.evaluate('/TEI/text/back', doc, namespaceResolver, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue;
76
+ if (!backNode) {
77
+ return;
78
+ }
79
+ const referenceNodes = doc.evaluate('div[@type="references"]/listBibl/biblStruct', backNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
80
+ for (const referenceNode of iterateSnapshot(referenceNodes)) {
81
+ const bibliographyItem = buildBibliographyItem({
82
+ type: chooseBibliographyItemType(null),
83
+ });
84
+ bibliographyItem.title = doc.evaluate('analytic/title', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
85
+ bibliographyItem.source = doc.evaluate('monogr/title', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
86
+ bibliographyItem.volume = doc.evaluate('monogr/imprint/biblScope[unit="volume"]', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
87
+ const fpage = doc.evaluate('monogr/imprint/biblScope[unit="page"]/@from', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
88
+ const lpage = doc.evaluate('monogr/imprint/biblScope[unit="page"]/@to', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
89
+ if (fpage) {
90
+ bibliographyItem.page = lpage ? `${fpage}-${lpage}` : fpage;
91
+ }
92
+ const date = doc.evaluate('monogr/imprint/date[type="published"]/@when', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
93
+ if (date) {
94
+ bibliographyItem.issued = buildBibliographicDate({
95
+ 'date-parts': [date.split(/-/)],
96
+ });
97
+ }
98
+ const authorNodes = doc.evaluate('analytic/author', referenceNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
99
+ bibliographyItem.author = [];
100
+ for (const authorNode of iterateSnapshot(authorNodes)) {
101
+ const name = buildBibliographicName({});
102
+ name.given = doc.evaluate('persName/forename', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
103
+ name.family = doc.evaluate('persName/surname', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
104
+ bibliographyItem.author.push(name);
105
+ }
106
+ addModel(bibliographyItem);
107
+ }
108
+ };
109
+ export const parseTEIGROBIDArticle = (doc) => {
110
+ const modelMap = new Map();
111
+ const addModel = addModelToMap(modelMap);
112
+ parseFront(doc, addModel);
113
+ parseBack(doc, addModel);
114
+ return [...modelMap.values()];
115
+ };
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export const timestamp = () => Math.floor(Date.now() / 1000);
@@ -0,0 +1,87 @@
1
+ /*!
2
+ * © 2020 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { generateID } from './id';
17
+ export const updateIdentifiers = async (data) => {
18
+ const idMap = new Map();
19
+ const updateIDs = (model) => {
20
+ const { _id, objectType } = model;
21
+ if (!objectType || !_id || !_id.match(/^MP.+:.+/)) {
22
+ return;
23
+ }
24
+ if (idMap.has(_id)) {
25
+ model._id = idMap.get(_id);
26
+ }
27
+ else {
28
+ model._id = generateID(objectType);
29
+ idMap.set(_id, model._id);
30
+ }
31
+ for (const value of Object.values(model)) {
32
+ if (Array.isArray(value)) {
33
+ value.forEach(updateIDs);
34
+ }
35
+ else {
36
+ updateIDs(value);
37
+ }
38
+ }
39
+ };
40
+ const replaceContent = (content) => {
41
+ content = content.replace(/MP\w+:[\w-]+/g, (match) => {
42
+ const value = idMap.get(match);
43
+ return value !== null && value !== void 0 ? value : match;
44
+ });
45
+ content = content.replace(/MP\w+_[\w-]+/g, (match) => {
46
+ const value = idMap.get(match.replace('_', ':'));
47
+ return value ? value.replace(':', '_') : match;
48
+ });
49
+ return content;
50
+ };
51
+ const updateContent = (model) => {
52
+ for (const [key, value] of Object.entries(model)) {
53
+ if (typeof value === 'object') {
54
+ updateContent(value);
55
+ }
56
+ else if (typeof value === 'string') {
57
+ model[key] = replaceContent(value);
58
+ }
59
+ }
60
+ };
61
+ for (const item of data) {
62
+ updateIDs(item);
63
+ }
64
+ for (const item of data) {
65
+ updateContent(item);
66
+ }
67
+ return { data, idMap };
68
+ };
69
+ export const updateAttachmentPath = (oldPath, idMap) => {
70
+ const matches = oldPath.match(/^Data\/([^.]+)(.*)/);
71
+ if (matches) {
72
+ const [, prefix, suffix] = matches;
73
+ const id = idMap.get(prefix.replace('_', ':'));
74
+ if (id) {
75
+ const newPrefix = id.replace(':', '_');
76
+ return `Data/${newPrefix}${suffix}`;
77
+ }
78
+ }
79
+ };
80
+ export const updateAttachments = async (zip, idMap) => {
81
+ for (const [oldPath, entry] of Object.entries(zip.files)) {
82
+ const newPath = updateAttachmentPath(oldPath, idMap);
83
+ if (newPath) {
84
+ zip.file(newPath, await entry.async('blob')).remove(oldPath);
85
+ }
86
+ }
87
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare class MissingElement extends Error {
2
+ constructor(elementID: string);
3
+ }
4
+ export declare class InvalidInput extends Error {
5
+ constructor(message: string);
6
+ }
@@ -0,0 +1,9 @@
1
+ export * from './lib/table-cell-styles';
2
+ export * from './lib/utils';
3
+ export * from './mathjax';
4
+ export * from './schema';
5
+ export * from './transformer';
6
+ export * from './jats';
7
+ export * from './types';
8
+ export * from './errors';
9
+ export { isSectionLabelNode } from './schema/nodes/section_label';
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * © 2020 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { parseJATSFront, parseJATSBody, parseJATSReferences, parseJATSArticle, getElementsOrder, } from './parse-jats-article';
@@ -0,0 +1,24 @@
1
+ /*!
2
+ * © 2020 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { DOMParser, ParseRule } from 'prosemirror-model';
17
+ import { Marks, Nodes } from '../../schema';
18
+ export type MarkRule = ParseRule & {
19
+ mark: Marks | null;
20
+ };
21
+ export type NodeRule = ParseRule & {
22
+ node?: Nodes | null;
23
+ };
24
+ export declare const jatsBodyDOMParser: DOMParser;
@@ -0,0 +1,31 @@
1
+ /*!
2
+ * © 2020 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { BibliographyItem } from '@manuscripts/manuscripts-json-schema';
17
+ export declare const jatsBodyTransformations: {
18
+ ensureSection(body: Element, createElement: (tagName: string) => HTMLElement): void;
19
+ createAbstract(abstractNode: Element, createElement: (tagName: string) => HTMLElement): HTMLElement;
20
+ createAcknowledgments(ackNode: Element, createElement: (tagName: string) => HTMLElement): HTMLElement;
21
+ createBibliography(doc: Document, references: BibliographyItem[], createElement: (tagName: string) => HTMLElement): HTMLElement;
22
+ createFootnotes(footnoteGroups: Element[], createElement: (tagName: string) => HTMLElement): HTMLElement;
23
+ createAppendixSection(app: Element, createElement: (tagName: string) => HTMLElement): HTMLElement;
24
+ createFloatsGroupSection(floatsGroup: Element, createElement: (tagName: string) => HTMLElement): HTMLElement;
25
+ moveSectionsToBody(doc: Document, body: Element, references: BibliographyItem[] | null, createElement: (tagName: string) => HTMLElement): void;
26
+ mapFootnotesToSections(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
27
+ moveCaptionsToEnd(body: Element): void;
28
+ moveTableFooterToEnd(body: Element): void;
29
+ moveFloatsGroupToBody(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
30
+ moveBlockNodesFromParagraph(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
31
+ };
@@ -0,0 +1,26 @@
1
+ /*!
2
+ * © 2020 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { BibliographyItem, CommentAnnotation, Model } from '@manuscripts/manuscripts-json-schema';
17
+ import { Build } from '../../transformer';
18
+ type ProcessingInstruction = {
19
+ id: string;
20
+ queryText: string;
21
+ };
22
+ export declare const parseProcessingInstruction: (node: Node) => ProcessingInstruction | undefined;
23
+ export declare const markProcessingInstructions: (doc: Document) => Map<string, string>;
24
+ export declare const createComments: (authorQueriesMap: Map<string, string>, manuscriptModels: Array<Model>) => Build<CommentAnnotation>[];
25
+ export declare const createReferenceComments: (referenceQueriesMap: Map<string, string[]>, references: Array<BibliographyItem>) => Build<CommentAnnotation>[];
26
+ export {};
@@ -0,0 +1,62 @@
1
+ /*!
2
+ * © 2020 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Bundle, Journal, Keyword, KeywordGroup } from '@manuscripts/manuscripts-json-schema';
17
+ import { Build } from '../../transformer/builders';
18
+ import { ISSN } from './jats-journal-meta-parser';
19
+ export declare const jatsFrontParser: {
20
+ loadJournalBundles(issns: ISSN[]): Promise<{
21
+ manuscript_bundle: string | undefined;
22
+ bundleNodes: Bundle[];
23
+ }>;
24
+ parseCounts(counts: Element | null | undefined): {
25
+ wordCount: number | undefined;
26
+ figureCount: number | undefined;
27
+ tableCount: number | undefined;
28
+ equationCount: number | undefined;
29
+ referencesCount: number | undefined;
30
+ genericCounts: {
31
+ count: number;
32
+ countType: string;
33
+ }[] | undefined;
34
+ } | undefined;
35
+ parseJournal(journalMeta: Element | null): Partial<Journal>;
36
+ parseKeywords(keywordGroupNodes?: NodeListOf<Element> | null): {
37
+ groups: Build<KeywordGroup>[];
38
+ keywords: Build<Keyword>[];
39
+ };
40
+ parseDates(historyNode: Element | null): {
41
+ acceptanceDate?: number | undefined;
42
+ correctionDate?: number | undefined;
43
+ retractionDate?: number | undefined;
44
+ revisionRequestDate?: number | undefined;
45
+ revisionReceiveDate?: number | undefined;
46
+ receiveDate?: number | undefined;
47
+ } | undefined;
48
+ parseSupplements(supplementNodes: Element[] | null): Build<import("@manuscripts/manuscripts-json-schema").Supplement>[];
49
+ parseAffiliationNodes(affiliationNodes: Element[]): {
50
+ affiliations: Build<import("@manuscripts/manuscripts-json-schema").Affiliation>[];
51
+ affiliationIDs: Map<string, string>;
52
+ };
53
+ parseFootnoteNodes(footnoteNodes: Element[]): {
54
+ footnotes: Build<import("@manuscripts/manuscripts-json-schema").Footnote>[];
55
+ footnoteIDs: Map<string, string>;
56
+ };
57
+ parseCorrespNodes(correspNodes: Element[]): {
58
+ correspondingList: Build<import("@manuscripts/manuscripts-json-schema").Corresponding>[];
59
+ correspondingIDs: Map<string, string>;
60
+ };
61
+ parseAuthorNodes(authorNodes: Element[], affiliationIDs: Map<string, string>, footnoteIDs: Map<string, string>, correspondingIDs: Map<string, string>): Build<import("@manuscripts/manuscripts-json-schema").Contributor>[];
62
+ };
@@ -0,0 +1,37 @@
1
+ /*!
2
+ * © 2020 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export type ISSN = {
17
+ ISSN: string;
18
+ publicationType?: string;
19
+ };
20
+ export type AbbreviatedTitle = {
21
+ abbreviatedTitle: string;
22
+ abbrevType?: string;
23
+ };
24
+ export type JournalIdentifier = {
25
+ journalID: string;
26
+ journalIDType?: string;
27
+ };
28
+ export declare const parseJournalIdentifiers: (journalMeta: Element) => Array<JournalIdentifier>;
29
+ export declare const parseJournalAbbreviatedTitles: (journalMeta: Element) => Array<AbbreviatedTitle>;
30
+ export declare const parseJournalISSNs: (journalMeta: Element) => Array<ISSN>;
31
+ export declare const parseJournalMeta: (journalMeta: Element) => {
32
+ abbreviatedTitles: AbbreviatedTitle[];
33
+ journalIdentifiers: JournalIdentifier[];
34
+ ISSNs: ISSN[];
35
+ publisherName: string | undefined;
36
+ title: string | undefined;
37
+ };
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * © 2020 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Model } from '@manuscripts/manuscripts-json-schema';
17
+ import { ManuscriptNode } from '../../schema';
18
+ export declare function flatten<T>(arrays: T[][]): T[];
19
+ export declare const fixBodyPMNode: (output: ManuscriptNode, models: Model[], referenceIdsMap?: Map<string, string>) => {
20
+ warnings: string[];
21
+ replacements: Map<string, string>;
22
+ };
23
+ export declare const htmlFromJatsNode: (element: Element | undefined | null, createElement: (tagName: string) => HTMLElement) => string | undefined;
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * © 2020 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export declare const jatsReferenceParser: {
17
+ parseReferences(referenceNodes: Element[], createElement: (tagName: string) => HTMLElement): {
18
+ references: import("../../transformer/builders").Build<import("@manuscripts/manuscripts-json-schema").BibliographyItem>[];
19
+ referenceIDs: Map<string, string>;
20
+ referenceQueries: Map<string, string[]>;
21
+ };
22
+ parseCrossReferences(crossReferenceNodes: Element[], referenceIDs: Map<string, string>): (import("../../transformer/builders").Build<import("@manuscripts/manuscripts-json-schema").AuxiliaryObjectReference> | import("../../transformer/builders").Build<import("@manuscripts/manuscripts-json-schema").Citation>)[];
23
+ };
@@ -0,0 +1,30 @@
1
+ /*!
2
+ * © 2020 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { BibliographyItem, ElementsOrder, FootnotesOrder, Model } from '@manuscripts/manuscripts-json-schema';
17
+ import { ManuscriptNode } from '../../schema';
18
+ export declare const parseJATSFront: (front: Element) => Promise<{
19
+ models: Model[];
20
+ bundles: import("@manuscripts/manuscripts-json-schema").Bundle[];
21
+ }>;
22
+ export declare const parseJATSReferences: (back: Element | null, body: Element | null, createElement: (tagName: string) => HTMLElement) => {
23
+ references: Model[];
24
+ crossReferences: Model[];
25
+ referenceQueriesMap: Map<string, string[]> | undefined;
26
+ referenceIdsMap: Map<string, string> | undefined;
27
+ };
28
+ export declare const parseJATSBody: (document: Document, body: Element, bibliographyItems: BibliographyItem[] | null, refModels: Model[], referenceIdsMap: Map<string, string> | undefined, footnotesOrder?: FootnotesOrder) => ManuscriptNode;
29
+ export declare const parseJATSArticle: (doc: Document) => Promise<Model[]>;
30
+ export declare const getElementsOrder: (node: ManuscriptNode) => ElementsOrder[];
@@ -0,0 +1,18 @@
1
+ /*!
2
+ * © 2020 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { parseJATSFront, parseJATSReferences, parseJATSBody, parseJATSArticle, getElementsOrder, } from './importer';
17
+ export * from './jats-exporter';
18
+ export * from './jats-versions';
@@ -0,0 +1,72 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Model } from '@manuscripts/manuscripts-json-schema';
17
+ import { DOMSerializer } from 'prosemirror-model';
18
+ import { ManuscriptFragment, ManuscriptNode } from '../schema';
19
+ import { Target } from '../transformer/labels';
20
+ import { IDGenerator, MediaPathGenerator } from '../types';
21
+ import { Version } from './jats-versions';
22
+ interface Links {
23
+ self?: {
24
+ [key: string]: string;
25
+ };
26
+ }
27
+ export declare const createCounter: () => {
28
+ increment: (field: string) => number;
29
+ };
30
+ export interface JATSExporterOptions {
31
+ version?: Version;
32
+ doi?: string;
33
+ id?: string;
34
+ frontMatterOnly?: boolean;
35
+ links?: Links;
36
+ citationType?: 'element' | 'mixed';
37
+ idGenerator?: IDGenerator;
38
+ mediaPathGenerator?: MediaPathGenerator;
39
+ }
40
+ export declare class JATSExporter {
41
+ protected document: Document;
42
+ protected modelMap: Map<string, Model>;
43
+ protected models: Model[];
44
+ protected serializer: DOMSerializer;
45
+ protected labelTargets?: Map<string, Target>;
46
+ serializeToJATS: (fragment: ManuscriptFragment, modelMap: Map<string, Model>, manuscriptID: string, options?: JATSExporterOptions) => Promise<string>;
47
+ private nodeFromJATS;
48
+ protected rewriteCrossReferenceTypes: () => void;
49
+ protected rewriteMediaPaths: (mediaPathGenerator: MediaPathGenerator) => Promise<void>;
50
+ protected rewriteIDs: (idGenerator?: IDGenerator) => Promise<void>;
51
+ protected setTitleContent: (element: HTMLElement, title: string) => void;
52
+ protected buildFront: (doi?: string, id?: string, links?: Links) => HTMLElement;
53
+ protected buildDateElement: (timestamp: number, type: string) => HTMLElement;
54
+ protected buildCountingElement: (tagName: string, count: number | undefined) => HTMLElement | undefined;
55
+ protected buildBody: (fragment: ManuscriptFragment) => HTMLBodyElement;
56
+ protected buildBack: (body: HTMLElement) => HTMLElement;
57
+ protected createSerializer: () => void;
58
+ protected serializeFragment: (fragment: ManuscriptFragment) => HTMLElement | DocumentFragment;
59
+ protected serializeNode: (node: ManuscriptNode) => Node;
60
+ private validateContributor;
61
+ private buildContributors;
62
+ private buildKeywords;
63
+ private fixBody;
64
+ private changeTag;
65
+ private fixTable;
66
+ private moveAbstracts;
67
+ private moveSectionsToBack;
68
+ sectionToFootnote: (section: Element, fnType: string) => HTMLElement;
69
+ private moveFloatsGroup;
70
+ private buildContributorName;
71
+ }
72
+ export {};
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ interface VersionIds {
17
+ publicId: string;
18
+ systemId: string;
19
+ }
20
+ export type Version = '1.1' | '1.2d1' | '1.2';
21
+ export declare const supportedVersions: () => Version[];
22
+ export declare const selectVersionIds: (version: Version) => VersionIds;
23
+ export {};
@@ -0,0 +1,20 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ interface StyledNodeAttrs {
17
+ paragraphStyle?: string;
18
+ }
19
+ export declare const buildElementClass: (attrs: StyledNodeAttrs) => string;
20
+ export {};