@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,36 @@
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
+ const versions = {
17
+ '1.1': {
18
+ publicId: '-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD with OASIS Tables with MathML3 v1.1 20151215//EN',
19
+ systemId: 'http://jats.nlm.nih.gov/archiving/1.1/JATS-archive-oasis-article1-mathml3.dtd',
20
+ },
21
+ '1.2d1': {
22
+ publicId: '-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD with OASIS Tables with MathML3 v1.2d1 20170631//EN',
23
+ systemId: 'http://jats.nlm.nih.gov/archiving/1.2d1/JATS-archive-oasis-article1-mathml3.dtd',
24
+ },
25
+ '1.2': {
26
+ publicId: '-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD with OASIS Tables with MathML3 v1.2 20190208//EN',
27
+ systemId: 'http://jats.nlm.nih.gov/archiving/1.2/JATS-archive-oasis-article1-mathml3.dtd',
28
+ },
29
+ };
30
+ export const supportedVersions = () => Object.keys(versions);
31
+ export const selectVersionIds = (version) => {
32
+ if (!(version in versions)) {
33
+ throw new Error(`Unknown version ${version}`);
34
+ }
35
+ return versions[version];
36
+ };
@@ -0,0 +1,22 @@
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 buildElementClass = (attrs) => {
17
+ const classes = ['MPElement'];
18
+ if (attrs.paragraphStyle) {
19
+ classes.push(attrs.paragraphStyle.replace(/:/g, '_'));
20
+ }
21
+ return classes.join(' ');
22
+ };
@@ -0,0 +1,43 @@
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
+ function decodeHTMLEntities(text) {
17
+ const entities = [
18
+ ['#x27', "'"],
19
+ ['#x2F', '/'],
20
+ ['#39', "'"],
21
+ ['#47', '/'],
22
+ ['nbsp', ' '],
23
+ ];
24
+ for (let i = 0; i < entities.length; i++) {
25
+ text = text.replace(new RegExp('&' + entities[i][0] + ';', 'g'), entities[i][1]);
26
+ }
27
+ return text;
28
+ }
29
+ export const nodeFromHTML = (html) => {
30
+ html = html.trim();
31
+ if (!html.length) {
32
+ return null;
33
+ }
34
+ const template = document.createElement('template');
35
+ template.innerHTML = html;
36
+ template.innerHTML = decodeHTMLEntities(template.innerHTML);
37
+ return template.content.firstChild;
38
+ };
39
+ export const textFromHTML = (html) => {
40
+ const template = document.createElement('template');
41
+ template.innerHTML = html;
42
+ return template.content.textContent;
43
+ };
@@ -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 const normalizeStyleName = (title) => title.replace(/\W+/, '-').toLowerCase();
17
+ export const buildStyledContentClass = (attrs, inlineStyle) => {
18
+ const classes = ['styled-content'];
19
+ if (inlineStyle && inlineStyle.title) {
20
+ classes.push(normalizeStyleName(inlineStyle.title));
21
+ }
22
+ return classes.join(' ');
23
+ };
@@ -0,0 +1,47 @@
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 TABLE_CELL_STYLES = [
17
+ 'backgroundColor',
18
+ 'border-top',
19
+ 'border-right',
20
+ 'border-bottom',
21
+ 'border-left',
22
+ 'verticalAlign',
23
+ 'textAlign',
24
+ ];
25
+ const dashify = (str) => {
26
+ return str
27
+ .trim()
28
+ .replace(/([a-z])([A-Z])/g, '$1-$2')
29
+ .replace(/\W/g, (m) => (/[À-ž]/.test(m) ? m : '-'))
30
+ .replace(/^-+|-+$/g, '')
31
+ .toLowerCase();
32
+ };
33
+ export const serializeTableCellStyles = (styles) => {
34
+ return Object.keys(styles)
35
+ .map((key) => styles[key] && `${dashify(key)}: ${styles[key]}`)
36
+ .filter(Boolean)
37
+ .join('; ');
38
+ };
39
+ const isStyleKey = (key) => TABLE_CELL_STYLES.includes(key);
40
+ export const getTableCellStyles = (styles) => {
41
+ return Object.entries(styles).reduce((acc, [key, value]) => {
42
+ if (isStyleKey(key)) {
43
+ acc[key] = value;
44
+ }
45
+ return acc;
46
+ }, {});
47
+ };
@@ -0,0 +1,59 @@
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 { isGraphicalAbstractSectionNode } from '../schema/nodes/graphical_abstract_section';
17
+ export function* iterateChildren(node, recurse = false) {
18
+ for (let i = 0; i < node.childCount; i++) {
19
+ const child = node.child(i);
20
+ yield child;
21
+ if (recurse) {
22
+ for (const grandchild of iterateChildren(child, true)) {
23
+ yield grandchild;
24
+ }
25
+ }
26
+ }
27
+ }
28
+ export const findNodePositions = (state, predicate) => {
29
+ const found = [];
30
+ state.doc.descendants((node, nodePos) => {
31
+ if (predicate(node)) {
32
+ found.push(nodePos);
33
+ }
34
+ return true;
35
+ });
36
+ return found;
37
+ };
38
+ export const isInGraphicalAbstractSection = ($pos) => {
39
+ for (let i = $pos.depth; i > 0; i--) {
40
+ const node = $pos.node(i);
41
+ if (isGraphicalAbstractSectionNode(node)) {
42
+ return true;
43
+ }
44
+ }
45
+ return false;
46
+ };
47
+ export const findParentNodeClosestToPos = ($pos, predicate) => {
48
+ for (let i = $pos.depth; i > 0; i--) {
49
+ const node = $pos.node(i);
50
+ if (predicate(node)) {
51
+ return {
52
+ pos: i > 0 ? $pos.before(i) : 0,
53
+ start: $pos.start(i),
54
+ depth: i,
55
+ node,
56
+ };
57
+ }
58
+ }
59
+ };
@@ -0,0 +1,12 @@
1
+ export const convertMathMLToSVG = async (mathml, display) => {
2
+ const { convertMathMLToSVG } = await import('./mathml-to-svg');
3
+ return convertMathMLToSVG(mathml, display);
4
+ };
5
+ export const convertTeXToMathML = async (tex, display) => {
6
+ const { convertTeXToMathML } = await import('./tex-to-mathml');
7
+ return convertTeXToMathML(tex, display);
8
+ };
9
+ export const convertTeXToSVG = async (tex, display) => {
10
+ const { convertTeXToSVG } = await import('./tex-to-svg');
11
+ return convertTeXToSVG(tex, display);
12
+ };
@@ -0,0 +1,17 @@
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 { AllPackages } from 'mathjax-full/js/input/tex/AllPackages';
17
+ export const packages = AllPackages.filter((name) => name !== 'html' && name !== 'bussproofs');
@@ -0,0 +1,52 @@
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 'mathjax-full/js/util/entities/all';
17
+ import { HTMLAdaptor } from 'mathjax-full/js/adaptors/HTMLAdaptor';
18
+ import { HTMLDocument } from 'mathjax-full/js/handlers/html/HTMLDocument';
19
+ import { MathML } from 'mathjax-full/js/input/mathml';
20
+ import { SVG } from 'mathjax-full/js/output/svg';
21
+ import { xmlSerializer } from '../transformer';
22
+ class ManuscriptsHTMLAdaptor extends HTMLAdaptor {
23
+ setAttribute(node, name, value, ns) {
24
+ if (name !== 'xmlns') {
25
+ ns ? node.setAttributeNS(ns, name, value) : node.setAttribute(name, value);
26
+ }
27
+ }
28
+ }
29
+ const InputJax = new MathML();
30
+ const OutputJax = new SVG({
31
+ fontCache: 'none',
32
+ });
33
+ const adaptor = new ManuscriptsHTMLAdaptor(window);
34
+ const doc = new HTMLDocument(document, adaptor, {
35
+ InputJax,
36
+ OutputJax,
37
+ });
38
+ doc.addStyleSheet();
39
+ export const convertMathMLToSVG = (mathml, display) => {
40
+ const item = doc.convert(mathml, {
41
+ display,
42
+ em: 16,
43
+ ex: 8,
44
+ containerWidth: 1000000,
45
+ lineWidth: 1000000,
46
+ scale: 1,
47
+ });
48
+ if (!item || !item.firstChild) {
49
+ return null;
50
+ }
51
+ return xmlSerializer.serializeToString(item.firstChild);
52
+ };
@@ -0,0 +1,45 @@
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 'mathjax-full/js/util/entities/all';
17
+ import { HTMLAdaptor } from 'mathjax-full/js/adaptors/HTMLAdaptor';
18
+ import { STATE } from 'mathjax-full/js/core/MathItem.js';
19
+ import { SerializedMmlVisitor } from 'mathjax-full/js/core/MmlTree/SerializedMmlVisitor';
20
+ import { HTMLDocument } from 'mathjax-full/js/handlers/html/HTMLDocument';
21
+ import { TeX } from 'mathjax-full/js/input/tex';
22
+ import { packages } from './mathjax-packages';
23
+ const InputJax = new TeX({
24
+ packages,
25
+ });
26
+ const adaptor = new HTMLAdaptor(window);
27
+ const doc = new HTMLDocument(document, adaptor, {
28
+ InputJax,
29
+ });
30
+ const visitor = new SerializedMmlVisitor();
31
+ export const convertTeXToMathML = (tex, display) => {
32
+ const item = doc.convert(tex, {
33
+ display,
34
+ em: 16,
35
+ ex: 8,
36
+ containerWidth: 1000000,
37
+ lineWidth: 1000000,
38
+ scale: 1,
39
+ end: STATE.CONVERT,
40
+ });
41
+ if (!item) {
42
+ return null;
43
+ }
44
+ return visitor.visitTree(item);
45
+ };
@@ -0,0 +1,55 @@
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 'mathjax-full/js/util/entities/all';
17
+ import { HTMLAdaptor } from 'mathjax-full/js/adaptors/HTMLAdaptor';
18
+ import { HTMLDocument } from 'mathjax-full/js/handlers/html/HTMLDocument';
19
+ import { TeX } from 'mathjax-full/js/input/tex';
20
+ import { SVG } from 'mathjax-full/js/output/svg';
21
+ import { xmlSerializer } from '../transformer';
22
+ import { packages } from './mathjax-packages';
23
+ class ManuscriptsHTMLAdaptor extends HTMLAdaptor {
24
+ setAttribute(node, name, value, ns) {
25
+ if (name !== 'xmlns') {
26
+ ns ? node.setAttributeNS(ns, name, value) : node.setAttribute(name, value);
27
+ }
28
+ }
29
+ }
30
+ const InputJax = new TeX({
31
+ packages,
32
+ });
33
+ const OutputJax = new SVG({
34
+ fontCache: 'none',
35
+ });
36
+ const adaptor = new ManuscriptsHTMLAdaptor(window);
37
+ const doc = new HTMLDocument(document, adaptor, {
38
+ InputJax,
39
+ OutputJax,
40
+ });
41
+ doc.addStyleSheet();
42
+ export const convertTeXToSVG = (tex, display) => {
43
+ const item = doc.convert(tex, {
44
+ display,
45
+ em: 16,
46
+ ex: 8,
47
+ containerWidth: 1000000,
48
+ lineWidth: 1000000,
49
+ scale: 1,
50
+ });
51
+ if (!item || !item.firstChild) {
52
+ return null;
53
+ }
54
+ return xmlSerializer.serializeToString(item.firstChild);
55
+ };
@@ -0,0 +1,27 @@
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 const GROUP_BLOCK = 'block';
17
+ export const GROUP_ELEMENT = 'element';
18
+ export const GROUP_EXECUTABLE = 'executable';
19
+ export const GROUP_LIST = 'list';
20
+ export const GROUP_SECTION = 'sections';
21
+ export const hasGroup = (nodeType, groupName) => {
22
+ const { group } = nodeType.spec;
23
+ if (!group) {
24
+ return false;
25
+ }
26
+ return group.split(/\s+/).includes(groupName);
27
+ };
@@ -0,0 +1,178 @@
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 { Schema } from 'prosemirror-model';
17
+ import { bold, code, italic, smallcaps, strikethrough, styled, subscript, superscript, tracked_delete, tracked_insert, underline, } from './marks';
18
+ import { attribution } from './nodes/attribution';
19
+ import { bibliographyElement } from './nodes/bibliography_element';
20
+ import { bibliographyItem } from './nodes/bibliography_item';
21
+ import { bibliographySection } from './nodes/bibliography_section';
22
+ import { blockquoteElement } from './nodes/blockquote_element';
23
+ import { caption } from './nodes/caption';
24
+ import { captionTitle } from './nodes/caption_title';
25
+ import { citation } from './nodes/citation';
26
+ import { comment } from './nodes/comment';
27
+ import { crossReference } from './nodes/cross_reference';
28
+ import { doc } from './nodes/doc';
29
+ import { equation } from './nodes/equation';
30
+ import { equationElement } from './nodes/equation_element';
31
+ import { figcaption } from './nodes/figcaption';
32
+ import { figure } from './nodes/figure';
33
+ import { figureElement } from './nodes/figure_element';
34
+ import { footnote } from './nodes/footnote';
35
+ import { footnotesElement } from './nodes/footnotes_element';
36
+ import { footnotesSection } from './nodes/footnotes_section';
37
+ import { graphicalAbstractSection } from './nodes/graphical_abstract_section';
38
+ import { hardBreak } from './nodes/hard_break';
39
+ import { highlightMarker } from './nodes/highlight_marker';
40
+ import { inlineEquation } from './nodes/inline_equation';
41
+ import { inlineFootnote } from './nodes/inline_footnote';
42
+ import { keywordsElement } from './nodes/keywords_element';
43
+ import { keywordsSection } from './nodes/keywords_section';
44
+ import { link } from './nodes/link';
45
+ import { bulletList, listItem, orderedList } from './nodes/list';
46
+ import { listing } from './nodes/listing';
47
+ import { listingElement } from './nodes/listing_element';
48
+ import { manuscript } from './nodes/manuscript';
49
+ import { missingFigure } from './nodes/missing_figure';
50
+ import { paragraph } from './nodes/paragraph';
51
+ import { placeholder } from './nodes/placeholder';
52
+ import { placeholderElement } from './nodes/placeholder_element';
53
+ import { pullquoteElement } from './nodes/pullquote_element';
54
+ import { section } from './nodes/section';
55
+ import { sectionLabel } from './nodes/section_label';
56
+ import { sectionTitle } from './nodes/section_title';
57
+ import { table, tableBody } from './nodes/table';
58
+ import { tableCol, tableColGroup } from './nodes/table_col';
59
+ import { tableElement } from './nodes/table_element';
60
+ import { tableCell, tableRow } from './nodes/table_row';
61
+ import { text } from './nodes/text';
62
+ import { tocElement } from './nodes/toc_element';
63
+ import { tocSection } from './nodes/toc_section';
64
+ export * from './groups';
65
+ export * from './types';
66
+ export * from './nodes/comment';
67
+ export * from './nodes/attribution';
68
+ export * from './nodes/bibliography_item';
69
+ export * from './nodes/bibliography_element';
70
+ export * from './nodes/bibliography_section';
71
+ export * from './nodes/blockquote_element';
72
+ export * from './nodes/caption';
73
+ export * from './nodes/caption_title';
74
+ export * from './nodes/citation';
75
+ export * from './nodes/cross_reference';
76
+ export * from './nodes/doc';
77
+ export * from './nodes/equation';
78
+ export * from './nodes/equation_element';
79
+ export * from './nodes/figcaption';
80
+ export * from './nodes/figure';
81
+ export * from './nodes/figure_element';
82
+ export * from './nodes/footnote';
83
+ export * from './nodes/footnotes_element';
84
+ export * from './nodes/footnotes_section';
85
+ export * from './nodes/graphical_abstract_section';
86
+ export * from './nodes/hard_break';
87
+ export * from './nodes/highlight_marker';
88
+ export * from './nodes/inline_equation';
89
+ export * from './nodes/inline_footnote';
90
+ export * from './nodes/keywords_element';
91
+ export * from './nodes/keywords_section';
92
+ export * from './nodes/link';
93
+ export * from './nodes/list';
94
+ export * from './nodes/listing';
95
+ export * from './nodes/listing_element';
96
+ export * from './nodes/manuscript';
97
+ export * from './nodes/missing_figure';
98
+ export * from './nodes/paragraph';
99
+ export * from './nodes/placeholder';
100
+ export * from './nodes/placeholder_element';
101
+ export * from './nodes/pullquote_element';
102
+ export * from './nodes/section';
103
+ export * from './nodes/section_title';
104
+ export * from './nodes/table';
105
+ export * from './nodes/table_col';
106
+ export * from './nodes/table_element';
107
+ export * from './nodes/table_row';
108
+ export * from './nodes/text';
109
+ export * from './nodes/toc_element';
110
+ export * from './nodes/toc_section';
111
+ export const schema = new Schema({
112
+ marks: {
113
+ bold,
114
+ code,
115
+ italic,
116
+ smallcaps,
117
+ strikethrough,
118
+ styled,
119
+ subscript,
120
+ superscript,
121
+ underline,
122
+ tracked_insert,
123
+ tracked_delete,
124
+ },
125
+ nodes: {
126
+ comment,
127
+ attribution,
128
+ bibliography_item: bibliographyItem,
129
+ bibliography_element: bibliographyElement,
130
+ bibliography_section: bibliographySection,
131
+ blockquote_element: blockquoteElement,
132
+ bullet_list: bulletList,
133
+ caption,
134
+ caption_title: captionTitle,
135
+ citation,
136
+ cross_reference: crossReference,
137
+ doc,
138
+ equation,
139
+ equation_element: equationElement,
140
+ figcaption,
141
+ figure,
142
+ figure_element: figureElement,
143
+ footnote,
144
+ footnotes_element: footnotesElement,
145
+ footnotes_section: footnotesSection,
146
+ graphical_abstract_section: graphicalAbstractSection,
147
+ hard_break: hardBreak,
148
+ highlight_marker: highlightMarker,
149
+ inline_equation: inlineEquation,
150
+ inline_footnote: inlineFootnote,
151
+ keywords_element: keywordsElement,
152
+ keywords_section: keywordsSection,
153
+ link,
154
+ list_item: listItem,
155
+ listing,
156
+ listing_element: listingElement,
157
+ manuscript,
158
+ missing_figure: missingFigure,
159
+ ordered_list: orderedList,
160
+ paragraph,
161
+ placeholder,
162
+ placeholder_element: placeholderElement,
163
+ pullquote_element: pullquoteElement,
164
+ section,
165
+ section_label: sectionLabel,
166
+ section_title: sectionTitle,
167
+ table,
168
+ table_body: tableBody,
169
+ table_cell: tableCell,
170
+ table_element: tableElement,
171
+ table_row: tableRow,
172
+ table_col: tableCol,
173
+ table_colgroup: tableColGroup,
174
+ text,
175
+ toc_element: tocElement,
176
+ toc_section: tocSection,
177
+ },
178
+ });