@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,222 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseSecType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = void 0;
19
+ const manuscripts_json_schema_1 = require("@manuscripts/manuscripts-json-schema");
20
+ const schema_1 = require("../schema");
21
+ const sectionNodeTypes = [
22
+ schema_1.schema.nodes.bibliography_section,
23
+ schema_1.schema.nodes.footnotes_section,
24
+ schema_1.schema.nodes.keywords_section,
25
+ schema_1.schema.nodes.section,
26
+ schema_1.schema.nodes.toc_section,
27
+ ];
28
+ const isAnySectionNode = (node) => sectionNodeTypes.includes(node.type);
29
+ exports.isAnySectionNode = isAnySectionNode;
30
+ const chooseSectionNodeType = (category) => {
31
+ switch (category) {
32
+ case 'MPSectionCategory:bibliography':
33
+ return schema_1.schema.nodes.bibliography_section;
34
+ case 'MPSectionCategory:abstract-graphical':
35
+ return schema_1.schema.nodes.graphical_abstract_section;
36
+ case 'MPSectionCategory:endnotes':
37
+ return schema_1.schema.nodes.footnotes_section;
38
+ case 'MPSectionCategory:keywords':
39
+ return schema_1.schema.nodes.keywords_section;
40
+ case 'MPSectionCategory:toc':
41
+ return schema_1.schema.nodes.toc_section;
42
+ default:
43
+ return schema_1.schema.nodes.section;
44
+ }
45
+ };
46
+ exports.chooseSectionNodeType = chooseSectionNodeType;
47
+ const chooseSectionLableName = (type) => {
48
+ switch (type) {
49
+ case 'appendices':
50
+ return 'Appendix';
51
+ default:
52
+ return type;
53
+ }
54
+ };
55
+ exports.chooseSectionLableName = chooseSectionLableName;
56
+ const guessSectionCategory = (elements) => {
57
+ if (!elements.length) {
58
+ return undefined;
59
+ }
60
+ switch (elements[0].objectType) {
61
+ case manuscripts_json_schema_1.ObjectTypes.BibliographyElement:
62
+ return 'MPSectionCategory:bibliography';
63
+ case manuscripts_json_schema_1.ObjectTypes.FootnotesElement:
64
+ return 'MPSectionCategory:endnotes';
65
+ case manuscripts_json_schema_1.ObjectTypes.KeywordsElement:
66
+ return 'MPSectionCategory:keywords';
67
+ case manuscripts_json_schema_1.ObjectTypes.TOCElement:
68
+ return 'MPSectionCategory:toc';
69
+ default:
70
+ return undefined;
71
+ }
72
+ };
73
+ exports.guessSectionCategory = guessSectionCategory;
74
+ const buildSectionCategory = (node) => {
75
+ switch (node.type) {
76
+ case schema_1.schema.nodes.bibliography_section:
77
+ return 'MPSectionCategory:bibliography';
78
+ case schema_1.schema.nodes.footnotes_section:
79
+ return 'MPSectionCategory:endnotes';
80
+ case schema_1.schema.nodes.keywords_section:
81
+ return 'MPSectionCategory:keywords';
82
+ case schema_1.schema.nodes.toc_section:
83
+ return 'MPSectionCategory:toc';
84
+ case schema_1.schema.nodes.graphical_abstract_section:
85
+ return 'MPSectionCategory:abstract-graphical';
86
+ default:
87
+ return node.attrs.category || undefined;
88
+ }
89
+ };
90
+ exports.buildSectionCategory = buildSectionCategory;
91
+ const chooseSecType = (sectionCategory) => {
92
+ const [, suffix] = sectionCategory.split(':', 2);
93
+ switch (suffix) {
94
+ case 'acknowledgement':
95
+ return 'acknowledgments';
96
+ case 'introduction':
97
+ return 'intro';
98
+ case 'materials-method':
99
+ return 'methods';
100
+ default:
101
+ return suffix;
102
+ }
103
+ };
104
+ exports.chooseSecType = chooseSecType;
105
+ const chooseSectionCategoryByType = (secType) => {
106
+ switch (secType) {
107
+ case 'abstract':
108
+ return 'MPSectionCategory:abstract';
109
+ case 'abstract-teaser':
110
+ return 'MPSectionCategory:abstract-teaser';
111
+ case 'abstract-graphical':
112
+ return 'MPSectionCategory:abstract-graphical';
113
+ case 'acknowledgments':
114
+ return 'MPSectionCategory:acknowledgement';
115
+ case 'availability':
116
+ case 'data-availability':
117
+ return 'MPSectionCategory:availability';
118
+ case 'bibliography':
119
+ return 'MPSectionCategory:bibliography';
120
+ case 'conclusions':
121
+ return 'MPSectionCategory:conclusions';
122
+ case 'discussion':
123
+ return 'MPSectionCategory:discussion';
124
+ case 'endnotes':
125
+ return 'MPSectionCategory:endnotes';
126
+ case 'intro':
127
+ return 'MPSectionCategory:introduction';
128
+ case 'keywords':
129
+ return 'MPSectionCategory:keywords';
130
+ case 'materials':
131
+ case 'methods':
132
+ return 'MPSectionCategory:materials-method';
133
+ case 'results':
134
+ return 'MPSectionCategory:results';
135
+ case 'toc':
136
+ return 'MPSectionCategory:toc';
137
+ case 'floating-element':
138
+ return 'MPSectionCategory:floating-element';
139
+ case 'appendices':
140
+ return 'MPSectionCategory:appendices';
141
+ case 'competing-interests':
142
+ case 'conflict':
143
+ return 'MPSectionCategory:competing-interests';
144
+ case 'financial-disclosure':
145
+ return 'MPSectionCategory:financial-disclosure';
146
+ case 'con':
147
+ return 'MPSectionCategory:con';
148
+ case 'deceased':
149
+ return 'MPSectionCategory:deceased';
150
+ case 'equal':
151
+ return 'MPSectionCategory:equal';
152
+ case 'present-address':
153
+ return 'MPSectionCategory:present-address';
154
+ case 'presented-at':
155
+ return 'MPSectionCategory:presented-at';
156
+ case 'previously-at':
157
+ return 'MPSectionCategory:previously-at';
158
+ case 'supplementary-material':
159
+ return 'MPSectionCategory:supplementary-material';
160
+ case 'supported-by':
161
+ return 'MPSectionCategory:supported-by';
162
+ case 'ethics-statement':
163
+ return 'MPSectionCategory:ethics-statement';
164
+ default:
165
+ return undefined;
166
+ }
167
+ };
168
+ exports.chooseSectionCategoryByType = chooseSectionCategoryByType;
169
+ const chooseSectionCategory = (section) => {
170
+ const secType = section.getAttribute('sec-type');
171
+ const secCat = (0, exports.chooseSectionCategoryByType)(secType);
172
+ if (secCat) {
173
+ return secCat;
174
+ }
175
+ else {
176
+ const titleNode = section.firstElementChild;
177
+ if (titleNode && titleNode.nodeName === 'title' && titleNode.textContent) {
178
+ return (0, exports.chooseSectionCategoryFromTitle)(titleNode.textContent.trim().toLowerCase());
179
+ }
180
+ return undefined;
181
+ }
182
+ };
183
+ exports.chooseSectionCategory = chooseSectionCategory;
184
+ const chooseSectionCategoryFromTitle = (title) => {
185
+ if (!title) {
186
+ return undefined;
187
+ }
188
+ switch (title) {
189
+ case 'abstract':
190
+ return 'MPSectionCategory:abstract';
191
+ case 'acknowledgments':
192
+ case 'acknowledgements':
193
+ return 'MPSectionCategory:acknowledgement';
194
+ case 'availability':
195
+ case 'data availability':
196
+ return 'MPSectionCategory:availability';
197
+ case 'conclusions':
198
+ return 'MPSectionCategory:conclusions';
199
+ case 'discussion':
200
+ return 'MPSectionCategory:discussion';
201
+ case 'introduction':
202
+ return 'MPSectionCategory:introduction';
203
+ case 'methods':
204
+ case 'materials':
205
+ case 'materials and methods':
206
+ case 'materials & methods':
207
+ return 'MPSectionCategory:materials-method';
208
+ case 'results':
209
+ return 'MPSectionCategory:results';
210
+ case 'bibliography':
211
+ case 'references':
212
+ return 'MPSectionCategory:bibliography';
213
+ case 'conflict':
214
+ case 'conflict of interest':
215
+ case 'competing interests':
216
+ return 'MPSectionCategory:competing-interests';
217
+ case 'financial-disclosure':
218
+ case 'funding information':
219
+ return 'MPSectionCategory:financial-disclosure';
220
+ }
221
+ };
222
+ exports.chooseSectionCategoryFromTitle = chooseSectionCategoryFromTitle;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.xmlSerializer = void 0;
22
+ const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
23
+ exports.xmlSerializer = { serializeToString: w3c_xmlserializer_1.default };
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.loadSharedData = void 0;
27
+ const loadSharedData = (file) => {
28
+ var _a;
29
+ return (_a = `@manuscripts/data/dist/shared/${file}.json`, Promise.resolve().then(() => __importStar(require(_a)))).then((module) => module.default);
30
+ };
31
+ exports.loadSharedData = loadSharedData;
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2020 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.parseTEIGROBIDArticle = exports.parseBack = exports.parseFront = void 0;
19
+ const builders_1 = require("./builders");
20
+ const model_map_1 = require("./model-map");
21
+ const iterateSnapshot = function* (snapshot) {
22
+ for (let i = 0; i < snapshot.snapshotLength; i++) {
23
+ yield snapshot.snapshotItem(i);
24
+ }
25
+ };
26
+ const namespaces = new Map([
27
+ [null, 'http://www.tei-c.org/ns/1.0'],
28
+ ]);
29
+ const namespaceResolver = (prefix) => namespaces.get(prefix) || null;
30
+ const parseFront = (doc, addModel) => {
31
+ const headerNode = doc.evaluate('/TEI/teiHeader', doc, namespaceResolver, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue;
32
+ if (!headerNode) {
33
+ throw new Error('No header element found!');
34
+ }
35
+ const title = doc.evaluate('fileDesc/titleStmt/title', headerNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
36
+ const manuscript = (0, builders_1.buildManuscript)(title);
37
+ addModel(manuscript);
38
+ const affiliationsMap = new Map();
39
+ const authorNodes = doc.evaluate('fileDesc/sourceDesc/biblStruct/analytic/author', headerNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
40
+ for (const authorNode of iterateSnapshot(authorNodes)) {
41
+ const name = (0, builders_1.buildBibliographicName)({});
42
+ name.given = doc.evaluate('persName/forename', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
43
+ name.family = doc.evaluate('persName/surname', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
44
+ const contributor = (0, builders_1.buildContributor)(name, 'author', 1);
45
+ contributor.affiliations = [];
46
+ const affiliationNodes = doc.evaluate('affiliation', authorNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
47
+ for (const affiliationNode of iterateSnapshot(affiliationNodes)) {
48
+ const key = affiliationNode.getAttribute('key');
49
+ if (key) {
50
+ const affiliation = affiliationsMap.get(key);
51
+ if (affiliation) {
52
+ contributor.affiliations.push(affiliation._id);
53
+ }
54
+ else {
55
+ const affiliation = (0, builders_1.buildAffiliation)('', 1);
56
+ affiliation.institution = doc.evaluate('orgName[@type="institution"]', affiliationNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
57
+ affiliation.department = doc.evaluate('orgName[@type="department"]', affiliationNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
58
+ addModel(affiliation);
59
+ affiliationsMap.set(key, affiliation);
60
+ contributor.affiliations.push(affiliation._id);
61
+ }
62
+ }
63
+ }
64
+ addModel(contributor);
65
+ }
66
+ };
67
+ exports.parseFront = parseFront;
68
+ const chooseBibliographyItemType = (publicationType) => {
69
+ switch (publicationType) {
70
+ case 'book':
71
+ case 'thesis':
72
+ return publicationType;
73
+ case 'journal':
74
+ default:
75
+ return 'article-journal';
76
+ }
77
+ };
78
+ const parseBack = (doc, addModel) => {
79
+ const backNode = doc.evaluate('/TEI/text/back', doc, namespaceResolver, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue;
80
+ if (!backNode) {
81
+ return;
82
+ }
83
+ const referenceNodes = doc.evaluate('div[@type="references"]/listBibl/biblStruct', backNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
84
+ for (const referenceNode of iterateSnapshot(referenceNodes)) {
85
+ const bibliographyItem = (0, builders_1.buildBibliographyItem)({
86
+ type: chooseBibliographyItemType(null),
87
+ });
88
+ bibliographyItem.title = doc.evaluate('analytic/title', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
89
+ bibliographyItem.source = doc.evaluate('monogr/title', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
90
+ bibliographyItem.volume = doc.evaluate('monogr/imprint/biblScope[unit="volume"]', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
91
+ const fpage = doc.evaluate('monogr/imprint/biblScope[unit="page"]/@from', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
92
+ const lpage = doc.evaluate('monogr/imprint/biblScope[unit="page"]/@to', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
93
+ if (fpage) {
94
+ bibliographyItem.page = lpage ? `${fpage}-${lpage}` : fpage;
95
+ }
96
+ const date = doc.evaluate('monogr/imprint/date[type="published"]/@when', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
97
+ if (date) {
98
+ bibliographyItem.issued = (0, builders_1.buildBibliographicDate)({
99
+ 'date-parts': [date.split(/-/)],
100
+ });
101
+ }
102
+ const authorNodes = doc.evaluate('analytic/author', referenceNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
103
+ bibliographyItem.author = [];
104
+ for (const authorNode of iterateSnapshot(authorNodes)) {
105
+ const name = (0, builders_1.buildBibliographicName)({});
106
+ name.given = doc.evaluate('persName/forename', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
107
+ name.family = doc.evaluate('persName/surname', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
108
+ bibliographyItem.author.push(name);
109
+ }
110
+ addModel(bibliographyItem);
111
+ }
112
+ };
113
+ exports.parseBack = parseBack;
114
+ const parseTEIGROBIDArticle = (doc) => {
115
+ const modelMap = new Map();
116
+ const addModel = (0, model_map_1.addModelToMap)(modelMap);
117
+ (0, exports.parseFront)(doc, addModel);
118
+ (0, exports.parseBack)(doc, addModel);
119
+ return [...modelMap.values()];
120
+ };
121
+ exports.parseTEIGROBIDArticle = parseTEIGROBIDArticle;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.timestamp = void 0;
19
+ const timestamp = () => Math.floor(Date.now() / 1000);
20
+ exports.timestamp = timestamp;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2020 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.updateAttachments = exports.updateAttachmentPath = exports.updateIdentifiers = void 0;
19
+ const id_1 = require("./id");
20
+ const updateIdentifiers = async (data) => {
21
+ const idMap = new Map();
22
+ const updateIDs = (model) => {
23
+ const { _id, objectType } = model;
24
+ if (!objectType || !_id || !_id.match(/^MP.+:.+/)) {
25
+ return;
26
+ }
27
+ if (idMap.has(_id)) {
28
+ model._id = idMap.get(_id);
29
+ }
30
+ else {
31
+ model._id = (0, id_1.generateID)(objectType);
32
+ idMap.set(_id, model._id);
33
+ }
34
+ for (const value of Object.values(model)) {
35
+ if (Array.isArray(value)) {
36
+ value.forEach(updateIDs);
37
+ }
38
+ else {
39
+ updateIDs(value);
40
+ }
41
+ }
42
+ };
43
+ const replaceContent = (content) => {
44
+ content = content.replace(/MP\w+:[\w-]+/g, (match) => {
45
+ const value = idMap.get(match);
46
+ return value !== null && value !== void 0 ? value : match;
47
+ });
48
+ content = content.replace(/MP\w+_[\w-]+/g, (match) => {
49
+ const value = idMap.get(match.replace('_', ':'));
50
+ return value ? value.replace(':', '_') : match;
51
+ });
52
+ return content;
53
+ };
54
+ const updateContent = (model) => {
55
+ for (const [key, value] of Object.entries(model)) {
56
+ if (typeof value === 'object') {
57
+ updateContent(value);
58
+ }
59
+ else if (typeof value === 'string') {
60
+ model[key] = replaceContent(value);
61
+ }
62
+ }
63
+ };
64
+ for (const item of data) {
65
+ updateIDs(item);
66
+ }
67
+ for (const item of data) {
68
+ updateContent(item);
69
+ }
70
+ return { data, idMap };
71
+ };
72
+ exports.updateIdentifiers = updateIdentifiers;
73
+ const updateAttachmentPath = (oldPath, idMap) => {
74
+ const matches = oldPath.match(/^Data\/([^.]+)(.*)/);
75
+ if (matches) {
76
+ const [, prefix, suffix] = matches;
77
+ const id = idMap.get(prefix.replace('_', ':'));
78
+ if (id) {
79
+ const newPrefix = id.replace(':', '_');
80
+ return `Data/${newPrefix}${suffix}`;
81
+ }
82
+ }
83
+ };
84
+ exports.updateAttachmentPath = updateAttachmentPath;
85
+ const updateAttachments = async (zip, idMap) => {
86
+ for (const [oldPath, entry] of Object.entries(zip.files)) {
87
+ const newPath = (0, exports.updateAttachmentPath)(oldPath, idMap);
88
+ if (newPath) {
89
+ zip.file(newPath, await entry.async('blob')).remove(oldPath);
90
+ }
91
+ }
92
+ };
93
+ exports.updateAttachments = updateAttachments;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ export class MissingElement extends Error {
2
+ constructor(elementID) {
3
+ super(`${elementID} not found in the manuscripts data`);
4
+ this.name = 'MissingElement';
5
+ }
6
+ }
7
+ export class InvalidInput extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = 'InvalidInput';
11
+ }
12
+ }
@@ -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';