@fiduswriter/document 0.1.0-alpha.2 → 0.1.0-alpha.4

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 (410) hide show
  1. package/README.md +22 -1
  2. package/dist/bibliography/common.d.ts +92 -0
  3. package/dist/bibliography/common.d.ts.map +1 -0
  4. package/dist/bibliography/common.js +85 -0
  5. package/dist/bibliography/common.js.map +1 -0
  6. package/dist/bibliography/csl_bib.d.ts +3 -0
  7. package/dist/bibliography/csl_bib.d.ts.map +1 -0
  8. package/dist/bibliography/csl_bib.js +131 -0
  9. package/dist/bibliography/csl_bib.js.map +1 -0
  10. package/dist/citations/citeproc_sys.d.ts +13 -0
  11. package/dist/citations/citeproc_sys.d.ts.map +1 -0
  12. package/dist/citations/citeproc_sys.js +43 -0
  13. package/dist/citations/citeproc_sys.js.map +1 -0
  14. package/dist/citations/format.d.ts +23 -0
  15. package/dist/citations/format.d.ts.map +1 -0
  16. package/dist/citations/format.js +161 -0
  17. package/dist/citations/format.js.map +1 -0
  18. package/dist/editor/e2ee/encryptor.d.ts +123 -0
  19. package/dist/editor/e2ee/encryptor.d.ts.map +1 -0
  20. package/dist/editor/e2ee/encryptor.js +201 -0
  21. package/dist/editor/e2ee/encryptor.js.map +1 -0
  22. package/dist/exporter/docx/citations.d.ts +21 -0
  23. package/dist/exporter/docx/citations.d.ts.map +1 -0
  24. package/dist/exporter/docx/citations.js +154 -0
  25. package/dist/exporter/docx/citations.js.map +1 -0
  26. package/dist/exporter/docx/comments.d.ts +18 -0
  27. package/dist/exporter/docx/comments.d.ts.map +1 -0
  28. package/dist/exporter/docx/comments.js +137 -0
  29. package/dist/exporter/docx/comments.js.map +1 -0
  30. package/dist/exporter/docx/footnotes.d.ts +42 -0
  31. package/dist/exporter/docx/footnotes.d.ts.map +1 -0
  32. package/dist/exporter/docx/footnotes.js +182 -0
  33. package/dist/exporter/docx/footnotes.js.map +1 -0
  34. package/dist/exporter/docx/images.d.ts +14 -0
  35. package/dist/exporter/docx/images.d.ts.map +1 -0
  36. package/dist/exporter/docx/images.js +86 -0
  37. package/dist/exporter/docx/images.js.map +1 -0
  38. package/dist/exporter/docx/index.d.ts +22 -0
  39. package/dist/exporter/docx/index.d.ts.map +1 -0
  40. package/dist/exporter/docx/index.js +107 -0
  41. package/dist/exporter/docx/index.js.map +1 -0
  42. package/dist/exporter/docx/lists.d.ts +33 -0
  43. package/dist/exporter/docx/lists.d.ts.map +1 -0
  44. package/dist/exporter/docx/lists.js +229 -0
  45. package/dist/exporter/docx/lists.js.map +1 -0
  46. package/dist/exporter/docx/math.d.ts +13 -0
  47. package/dist/exporter/docx/math.d.ts.map +1 -0
  48. package/dist/exporter/docx/math.js +42 -0
  49. package/dist/exporter/docx/math.js.map +1 -0
  50. package/dist/exporter/docx/metadata.d.ts +14 -0
  51. package/dist/exporter/docx/metadata.d.ts.map +1 -0
  52. package/dist/exporter/docx/metadata.js +239 -0
  53. package/dist/exporter/docx/metadata.js.map +1 -0
  54. package/dist/exporter/docx/rels.d.ts +25 -0
  55. package/dist/exporter/docx/rels.d.ts.map +1 -0
  56. package/dist/exporter/docx/rels.js +168 -0
  57. package/dist/exporter/docx/rels.js.map +1 -0
  58. package/dist/exporter/docx/render.d.ts +20 -0
  59. package/dist/exporter/docx/render.d.ts.map +1 -0
  60. package/dist/exporter/docx/render.js +774 -0
  61. package/dist/exporter/docx/render.js.map +1 -0
  62. package/dist/exporter/docx/richtext.d.ts +25 -0
  63. package/dist/exporter/docx/richtext.d.ts.map +1 -0
  64. package/dist/exporter/docx/richtext.js +1052 -0
  65. package/dist/exporter/docx/richtext.js.map +1 -0
  66. package/dist/exporter/docx/tables.d.ts +14 -0
  67. package/dist/exporter/docx/tables.d.ts.map +1 -0
  68. package/dist/exporter/docx/tables.js +109 -0
  69. package/dist/exporter/docx/tables.js.map +1 -0
  70. package/dist/exporter/docx/tools.d.ts +3 -0
  71. package/dist/exporter/docx/tools.d.ts.map +1 -0
  72. package/dist/exporter/docx/tools.js +48 -0
  73. package/dist/exporter/docx/tools.js.map +1 -0
  74. package/dist/exporter/epub/index.d.ts +11 -0
  75. package/dist/exporter/epub/index.d.ts.map +1 -0
  76. package/dist/exporter/epub/index.js +102 -0
  77. package/dist/exporter/epub/index.js.map +1 -0
  78. package/dist/exporter/epub/templates.d.ts +32 -0
  79. package/dist/exporter/epub/templates.d.ts.map +1 -0
  80. package/dist/exporter/epub/templates.js +95 -0
  81. package/dist/exporter/epub/templates.js.map +1 -0
  82. package/dist/exporter/epub/tools.d.ts +5 -0
  83. package/dist/exporter/epub/tools.d.ts.map +1 -0
  84. package/dist/exporter/epub/tools.js +81 -0
  85. package/dist/exporter/epub/tools.js.map +1 -0
  86. package/dist/exporter/html/citations.d.ts +27 -0
  87. package/dist/exporter/html/citations.d.ts.map +1 -0
  88. package/dist/exporter/html/citations.js +91 -0
  89. package/dist/exporter/html/citations.js.map +1 -0
  90. package/dist/exporter/html/convert.d.ts +100 -0
  91. package/dist/exporter/html/convert.d.ts.map +1 -0
  92. package/dist/exporter/html/convert.js +718 -0
  93. package/dist/exporter/html/convert.js.map +1 -0
  94. package/dist/exporter/html/index.d.ts +61 -0
  95. package/dist/exporter/html/index.d.ts.map +1 -0
  96. package/dist/exporter/html/index.js +134 -0
  97. package/dist/exporter/html/index.js.map +1 -0
  98. package/dist/exporter/html/templates.d.ts +10 -0
  99. package/dist/exporter/html/templates.d.ts.map +1 -0
  100. package/dist/exporter/html/templates.js +21 -0
  101. package/dist/exporter/html/templates.js.map +1 -0
  102. package/dist/exporter/html/tools.d.ts +2 -0
  103. package/dist/exporter/html/tools.d.ts.map +1 -0
  104. package/dist/exporter/html/tools.js +49 -0
  105. package/dist/exporter/html/tools.js.map +1 -0
  106. package/dist/exporter/jats/bibliography.d.ts +2 -0
  107. package/dist/exporter/jats/bibliography.d.ts.map +1 -0
  108. package/dist/exporter/jats/bibliography.js +153 -0
  109. package/dist/exporter/jats/bibliography.js.map +1 -0
  110. package/dist/exporter/jats/citations.d.ts +14 -0
  111. package/dist/exporter/jats/citations.d.ts.map +1 -0
  112. package/dist/exporter/jats/citations.js +83 -0
  113. package/dist/exporter/jats/citations.js.map +1 -0
  114. package/dist/exporter/jats/convert.d.ts +45 -0
  115. package/dist/exporter/jats/convert.d.ts.map +1 -0
  116. package/dist/exporter/jats/convert.js +799 -0
  117. package/dist/exporter/jats/convert.js.map +1 -0
  118. package/dist/exporter/jats/index.d.ts +19 -0
  119. package/dist/exporter/jats/index.d.ts.map +1 -0
  120. package/dist/exporter/jats/index.js +66 -0
  121. package/dist/exporter/jats/index.js.map +1 -0
  122. package/dist/exporter/jats/templates.d.ts +16 -0
  123. package/dist/exporter/jats/templates.d.ts.map +1 -0
  124. package/dist/exporter/jats/templates.js +25 -0
  125. package/dist/exporter/jats/templates.js.map +1 -0
  126. package/dist/exporter/jats/text.d.ts +3 -0
  127. package/dist/exporter/jats/text.d.ts.map +1 -0
  128. package/dist/exporter/jats/text.js +72 -0
  129. package/dist/exporter/jats/text.js.map +1 -0
  130. package/dist/exporter/latex/convert.d.ts +27 -0
  131. package/dist/exporter/latex/convert.d.ts.map +1 -0
  132. package/dist/exporter/latex/convert.js +865 -0
  133. package/dist/exporter/latex/convert.js.map +1 -0
  134. package/dist/exporter/latex/escape_latex.d.ts +2 -0
  135. package/dist/exporter/latex/escape_latex.d.ts.map +1 -0
  136. package/dist/exporter/latex/escape_latex.js +20 -0
  137. package/dist/exporter/latex/escape_latex.js.map +1 -0
  138. package/dist/exporter/latex/index.d.ts +23 -0
  139. package/dist/exporter/latex/index.d.ts.map +1 -0
  140. package/dist/exporter/latex/index.js +57 -0
  141. package/dist/exporter/latex/index.js.map +1 -0
  142. package/dist/exporter/latex/readme.d.ts +2 -0
  143. package/dist/exporter/latex/readme.d.ts.map +1 -0
  144. package/dist/exporter/latex/readme.js +23 -0
  145. package/dist/exporter/latex/readme.js.map +1 -0
  146. package/dist/exporter/native/shrink.d.ts +21 -0
  147. package/dist/exporter/native/shrink.d.ts.map +1 -0
  148. package/dist/exporter/native/shrink.js +115 -0
  149. package/dist/exporter/native/shrink.js.map +1 -0
  150. package/dist/exporter/odt/citations.d.ts +18 -0
  151. package/dist/exporter/odt/citations.d.ts.map +1 -0
  152. package/dist/exporter/odt/citations.js +87 -0
  153. package/dist/exporter/odt/citations.js.map +1 -0
  154. package/dist/exporter/odt/footnotes.d.ts +25 -0
  155. package/dist/exporter/odt/footnotes.d.ts.map +1 -0
  156. package/dist/exporter/odt/footnotes.js +112 -0
  157. package/dist/exporter/odt/footnotes.js.map +1 -0
  158. package/dist/exporter/odt/images.d.ts +13 -0
  159. package/dist/exporter/odt/images.d.ts.map +1 -0
  160. package/dist/exporter/odt/images.js +98 -0
  161. package/dist/exporter/odt/images.js.map +1 -0
  162. package/dist/exporter/odt/index.d.ts +23 -0
  163. package/dist/exporter/odt/index.d.ts.map +1 -0
  164. package/dist/exporter/odt/index.js +99 -0
  165. package/dist/exporter/odt/index.js.map +1 -0
  166. package/dist/exporter/odt/math.d.ts +13 -0
  167. package/dist/exporter/odt/math.d.ts.map +1 -0
  168. package/dist/exporter/odt/math.js +48 -0
  169. package/dist/exporter/odt/math.js.map +1 -0
  170. package/dist/exporter/odt/metadata.d.ts +14 -0
  171. package/dist/exporter/odt/metadata.d.ts.map +1 -0
  172. package/dist/exporter/odt/metadata.js +203 -0
  173. package/dist/exporter/odt/metadata.js.map +1 -0
  174. package/dist/exporter/odt/render.d.ts +24 -0
  175. package/dist/exporter/odt/render.d.ts.map +1 -0
  176. package/dist/exporter/odt/render.js +644 -0
  177. package/dist/exporter/odt/render.js.map +1 -0
  178. package/dist/exporter/odt/richtext.d.ts +22 -0
  179. package/dist/exporter/odt/richtext.d.ts.map +1 -0
  180. package/dist/exporter/odt/richtext.js +728 -0
  181. package/dist/exporter/odt/richtext.js.map +1 -0
  182. package/dist/exporter/odt/styles.d.ts +33 -0
  183. package/dist/exporter/odt/styles.d.ts.map +1 -0
  184. package/dist/exporter/odt/styles.js +348 -0
  185. package/dist/exporter/odt/styles.js.map +1 -0
  186. package/dist/exporter/odt/track.d.ts +11 -0
  187. package/dist/exporter/odt/track.d.ts.map +1 -0
  188. package/dist/exporter/odt/track.js +59 -0
  189. package/dist/exporter/odt/track.js.map +1 -0
  190. package/dist/exporter/pandoc/citations.d.ts +17 -0
  191. package/dist/exporter/pandoc/citations.d.ts.map +1 -0
  192. package/dist/exporter/pandoc/citations.js +85 -0
  193. package/dist/exporter/pandoc/citations.js.map +1 -0
  194. package/dist/exporter/pandoc/convert.d.ts +38 -0
  195. package/dist/exporter/pandoc/convert.d.ts.map +1 -0
  196. package/dist/exporter/pandoc/convert.js +881 -0
  197. package/dist/exporter/pandoc/convert.js.map +1 -0
  198. package/dist/exporter/pandoc/index.d.ts +38 -0
  199. package/dist/exporter/pandoc/index.d.ts.map +1 -0
  200. package/dist/exporter/pandoc/index.js +67 -0
  201. package/dist/exporter/pandoc/index.js.map +1 -0
  202. package/dist/exporter/pandoc/readme.d.ts +2 -0
  203. package/dist/exporter/pandoc/readme.d.ts.map +1 -0
  204. package/dist/exporter/pandoc/readme.js +9 -0
  205. package/dist/exporter/pandoc/readme.js.map +1 -0
  206. package/dist/exporter/pandoc/tools.d.ts +6 -0
  207. package/dist/exporter/pandoc/tools.d.ts.map +1 -0
  208. package/dist/exporter/pandoc/tools.js +52 -0
  209. package/dist/exporter/pandoc/tools.js.map +1 -0
  210. package/dist/exporter/print/index.d.ts +9 -0
  211. package/dist/exporter/print/index.d.ts.map +1 -0
  212. package/dist/exporter/print/index.js +140 -0
  213. package/dist/exporter/print/index.js.map +1 -0
  214. package/dist/exporter/tools/doc_content.d.ts +7 -0
  215. package/dist/exporter/tools/doc_content.d.ts.map +1 -0
  216. package/dist/exporter/tools/doc_content.js +129 -0
  217. package/dist/exporter/tools/doc_content.js.map +1 -0
  218. package/dist/exporter/tools/file.d.ts +2 -0
  219. package/dist/exporter/tools/file.d.ts.map +1 -0
  220. package/dist/exporter/tools/file.js +10 -0
  221. package/dist/exporter/tools/file.js.map +1 -0
  222. package/dist/exporter/tools/json.d.ts +7 -0
  223. package/dist/exporter/tools/json.d.ts.map +1 -0
  224. package/dist/exporter/tools/json.js +82 -0
  225. package/dist/exporter/tools/json.js.map +1 -0
  226. package/dist/exporter/tools/svg.d.ts +2 -0
  227. package/dist/exporter/tools/svg.d.ts.map +1 -0
  228. package/dist/exporter/tools/svg.js +26 -0
  229. package/dist/exporter/tools/svg.js.map +1 -0
  230. package/dist/exporter/tools/xml.d.ts +41 -0
  231. package/dist/exporter/tools/xml.d.ts.map +1 -0
  232. package/dist/exporter/tools/xml.js +440 -0
  233. package/dist/exporter/tools/xml.js.map +1 -0
  234. package/dist/exporter/tools/xml_zip.d.ts +20 -0
  235. package/dist/exporter/tools/xml_zip.d.ts.map +1 -0
  236. package/dist/exporter/tools/xml_zip.js +86 -0
  237. package/dist/exporter/tools/xml_zip.js.map +1 -0
  238. package/dist/exporter/tools/zip.d.ts +21 -0
  239. package/dist/exporter/tools/zip.d.ts.map +1 -0
  240. package/dist/exporter/tools/zip.js +71 -0
  241. package/dist/exporter/tools/zip.js.map +1 -0
  242. package/dist/exporter/tools/zotero_csl.d.ts +10 -0
  243. package/dist/exporter/tools/zotero_csl.d.ts.map +1 -0
  244. package/dist/exporter/tools/zotero_csl.js +78 -0
  245. package/dist/exporter/tools/zotero_csl.js.map +1 -0
  246. package/dist/importer/citations.d.ts +25 -0
  247. package/dist/importer/citations.d.ts.map +1 -0
  248. package/dist/importer/citations.js +116 -0
  249. package/dist/importer/citations.js.map +1 -0
  250. package/dist/importer/docx/citations.d.ts +65 -0
  251. package/dist/importer/docx/citations.d.ts.map +1 -0
  252. package/dist/importer/docx/citations.js +106 -0
  253. package/dist/importer/docx/citations.js.map +1 -0
  254. package/dist/importer/docx/convert.d.ts +228 -0
  255. package/dist/importer/docx/convert.d.ts.map +1 -0
  256. package/dist/importer/docx/convert.js +1226 -0
  257. package/dist/importer/docx/convert.js.map +1 -0
  258. package/dist/importer/docx/helpers.d.ts +2 -0
  259. package/dist/importer/docx/helpers.d.ts.map +1 -0
  260. package/dist/importer/docx/helpers.js +10 -0
  261. package/dist/importer/docx/helpers.js.map +1 -0
  262. package/dist/importer/docx/omml2mathml.d.ts +7 -0
  263. package/dist/importer/docx/omml2mathml.d.ts.map +1 -0
  264. package/dist/importer/docx/omml2mathml.js +1239 -0
  265. package/dist/importer/docx/omml2mathml.js.map +1 -0
  266. package/dist/importer/docx/parse.d.ts +205 -0
  267. package/dist/importer/docx/parse.d.ts.map +1 -0
  268. package/dist/importer/docx/parse.js +663 -0
  269. package/dist/importer/docx/parse.js.map +1 -0
  270. package/dist/importer/native/get_images.d.ts +11 -0
  271. package/dist/importer/native/get_images.d.ts.map +1 -0
  272. package/dist/importer/native/get_images.js +64 -0
  273. package/dist/importer/native/get_images.js.map +1 -0
  274. package/dist/importer/native/update.d.ts +6 -0
  275. package/dist/importer/native/update.d.ts.map +1 -0
  276. package/dist/importer/native/update.js +26 -0
  277. package/dist/importer/native/update.js.map +1 -0
  278. package/dist/importer/odt/citations.d.ts +47 -0
  279. package/dist/importer/odt/citations.d.ts.map +1 -0
  280. package/dist/importer/odt/citations.js +79 -0
  281. package/dist/importer/odt/citations.js.map +1 -0
  282. package/dist/importer/odt/convert.d.ts +330 -0
  283. package/dist/importer/odt/convert.d.ts.map +1 -0
  284. package/dist/importer/odt/convert.js +1506 -0
  285. package/dist/importer/odt/convert.js.map +1 -0
  286. package/dist/importer/pandoc/convert.d.ts +84 -0
  287. package/dist/importer/pandoc/convert.d.ts.map +1 -0
  288. package/dist/importer/pandoc/convert.js +777 -0
  289. package/dist/importer/pandoc/convert.js.map +1 -0
  290. package/dist/importer/pandoc/helpers.d.ts +4 -0
  291. package/dist/importer/pandoc/helpers.d.ts.map +1 -0
  292. package/dist/importer/pandoc/helpers.js +75 -0
  293. package/dist/importer/pandoc/helpers.js.map +1 -0
  294. package/dist/importer/zip_analyzer.d.ts +25 -0
  295. package/dist/importer/zip_analyzer.d.ts.map +1 -0
  296. package/dist/importer/zip_analyzer.js +84 -0
  297. package/dist/importer/zip_analyzer.js.map +1 -0
  298. package/dist/index.d.ts +2 -0
  299. package/dist/index.d.ts.map +1 -0
  300. package/dist/index.js +2 -0
  301. package/dist/index.js.map +1 -0
  302. package/dist/mathlive/opf_includes.d.ts +2 -0
  303. package/dist/mathlive/opf_includes.d.ts.map +1 -0
  304. package/dist/mathlive/opf_includes.js +25 -0
  305. package/dist/mathlive/opf_includes.js.map +1 -0
  306. package/dist/schema/common/annotate.d.ts +59 -0
  307. package/dist/schema/common/annotate.d.ts.map +1 -0
  308. package/dist/schema/common/annotate.js +75 -0
  309. package/dist/schema/common/annotate.js.map +1 -0
  310. package/dist/schema/common/base.d.ts +109 -0
  311. package/dist/schema/common/base.d.ts.map +1 -0
  312. package/dist/schema/common/base.js +109 -0
  313. package/dist/schema/common/base.js.map +1 -0
  314. package/dist/schema/common/citation.d.ts +29 -0
  315. package/dist/schema/common/citation.d.ts.map +1 -0
  316. package/dist/schema/common/citation.js +62 -0
  317. package/dist/schema/common/citation.js.map +1 -0
  318. package/dist/schema/common/equation.d.ts +18 -0
  319. package/dist/schema/common/equation.d.ts.map +1 -0
  320. package/dist/schema/common/equation.js +32 -0
  321. package/dist/schema/common/equation.js.map +1 -0
  322. package/dist/schema/common/figure.d.ts +108 -0
  323. package/dist/schema/common/figure.d.ts.map +1 -0
  324. package/dist/schema/common/figure.js +176 -0
  325. package/dist/schema/common/figure.js.map +1 -0
  326. package/dist/schema/common/heading.d.ts +33 -0
  327. package/dist/schema/common/heading.d.ts.map +1 -0
  328. package/dist/schema/common/heading.js +41 -0
  329. package/dist/schema/common/heading.js.map +1 -0
  330. package/dist/schema/common/index.d.ts +11 -0
  331. package/dist/schema/common/index.d.ts.map +1 -0
  332. package/dist/schema/common/index.js +11 -0
  333. package/dist/schema/common/index.js.map +1 -0
  334. package/dist/schema/common/list.d.ts +83 -0
  335. package/dist/schema/common/list.d.ts.map +1 -0
  336. package/dist/schema/common/list.js +92 -0
  337. package/dist/schema/common/list.js.map +1 -0
  338. package/dist/schema/common/reference.d.ts +78 -0
  339. package/dist/schema/common/reference.d.ts.map +1 -0
  340. package/dist/schema/common/reference.js +97 -0
  341. package/dist/schema/common/reference.js.map +1 -0
  342. package/dist/schema/common/table.d.ts +92 -0
  343. package/dist/schema/common/table.d.ts.map +1 -0
  344. package/dist/schema/common/table.js +85 -0
  345. package/dist/schema/common/table.js.map +1 -0
  346. package/dist/schema/common/track.d.ts +131 -0
  347. package/dist/schema/common/track.d.ts.map +1 -0
  348. package/dist/schema/common/track.js +184 -0
  349. package/dist/schema/common/track.js.map +1 -0
  350. package/dist/schema/const.d.ts +3 -0
  351. package/dist/schema/const.d.ts.map +1 -0
  352. package/{src → dist}/schema/const.js +3 -3
  353. package/dist/schema/const.js.map +1 -0
  354. package/dist/schema/convert.d.ts +3 -0
  355. package/dist/schema/convert.d.ts.map +1 -0
  356. package/dist/schema/convert.js +1215 -0
  357. package/dist/schema/convert.js.map +1 -0
  358. package/dist/schema/document/content.d.ts +137 -0
  359. package/dist/schema/document/content.d.ts.map +1 -0
  360. package/dist/schema/document/content.js +177 -0
  361. package/dist/schema/document/content.js.map +1 -0
  362. package/dist/schema/document/index.d.ts +879 -0
  363. package/dist/schema/document/index.d.ts.map +1 -0
  364. package/dist/schema/document/index.js +68 -0
  365. package/dist/schema/document/index.js.map +1 -0
  366. package/dist/schema/document/structure.d.ts +273 -0
  367. package/dist/schema/document/structure.d.ts.map +1 -0
  368. package/dist/schema/document/structure.js +445 -0
  369. package/dist/schema/document/structure.js.map +1 -0
  370. package/dist/schema/export.d.ts +880 -0
  371. package/dist/schema/export.d.ts.map +1 -0
  372. package/dist/schema/export.js +16 -0
  373. package/dist/schema/export.js.map +1 -0
  374. package/dist/schema/footnotes.d.ts +499 -0
  375. package/dist/schema/footnotes.d.ts.map +1 -0
  376. package/dist/schema/footnotes.js +88 -0
  377. package/dist/schema/footnotes.js.map +1 -0
  378. package/dist/schema/footnotes_convert.d.ts +5 -0
  379. package/dist/schema/footnotes_convert.d.ts.map +1 -0
  380. package/dist/schema/footnotes_convert.js +26 -0
  381. package/dist/schema/footnotes_convert.js.map +1 -0
  382. package/dist/schema/i18n.d.ts +586 -0
  383. package/dist/schema/i18n.d.ts.map +1 -0
  384. package/dist/schema/i18n.js +585 -0
  385. package/dist/schema/i18n.js.map +1 -0
  386. package/dist/schema/index.d.ts +6 -0
  387. package/dist/schema/index.d.ts.map +1 -0
  388. package/dist/schema/index.js +6 -0
  389. package/dist/schema/index.js.map +1 -0
  390. package/dist/schema/mini_json.d.ts +5 -0
  391. package/dist/schema/mini_json.d.ts.map +1 -0
  392. package/dist/schema/mini_json.js +50 -0
  393. package/dist/schema/mini_json.js.map +1 -0
  394. package/dist/schema/text.d.ts +2 -0
  395. package/dist/schema/text.d.ts.map +1 -0
  396. package/dist/schema/text.js +23 -0
  397. package/dist/schema/text.js.map +1 -0
  398. package/dist/types.d.ts +122 -0
  399. package/dist/types.d.ts.map +1 -0
  400. package/dist/types.js +9 -0
  401. package/dist/types.js.map +1 -0
  402. package/package.json +48 -16
  403. package/scripts/export-schema.js +1 -1
  404. package/src/exporter/tools/{file.js → file.ts} +1 -1
  405. package/src/exporter/tools/{json.js → json.ts} +30 -19
  406. package/src/global.d.ts +11 -0
  407. package/src/schema/const.ts +58 -0
  408. package/src/types.ts +136 -0
  409. package/jest.config.js +0 -24
  410. /package/src/{index.js → index.ts} +0 -0
@@ -0,0 +1,718 @@
1
+ import { convertLatexToMathMl } from "mathlive";
2
+ import pretty from "pretty";
3
+ import { escapeText } from "fwtoolkit";
4
+ import { CATS } from "../../schema/i18n.js";
5
+ import { HTMLExporterCitations } from "./citations.js";
6
+ import { displayNumber } from "./tools.js";
7
+ export class HTMLExporterConvert {
8
+ constructor(docTitle, docSettings, docContent, htmlExportTemplate, imageDB, bibDB, csl, styleSheets, { xhtml = false, epub = false, relativeUrls = true, // Whether to use relative urls for images, css files, etc. Is used when bundled in HTML. Not in print.
9
+ footnoteNumbering = "decimal", affiliationNumbering = "alpha", idPrefix = "", footnoteOffset = 0, affiliationOffset = 0, figureOffset = {} } = {}) {
10
+ this.docTitle = docTitle;
11
+ this.docSettings = docSettings;
12
+ this.docContent = docContent;
13
+ this.htmlExportTemplate = htmlExportTemplate;
14
+ this.imageDB = imageDB;
15
+ this.bibDB = bibDB;
16
+ this.csl = csl;
17
+ this.styleSheets = styleSheets;
18
+ this.xhtml = xhtml;
19
+ this.epub = epub;
20
+ this.relativeUrls = relativeUrls;
21
+ this.footnoteNumbering = footnoteNumbering;
22
+ this.affiliationNumbering = affiliationNumbering;
23
+ this.endSlash = this.xhtml ? "/" : "";
24
+ this.imageIds = [];
25
+ this.categoryCounter = {}; // counters for each type of figure (figure/table/photo)
26
+ this.affiliations = {}; // affiliations of authors and editors
27
+ this.parCounter = 0;
28
+ this.headingCounter = 0;
29
+ this.currentSectionLevel = 0;
30
+ this.listCounter = 0;
31
+ this.orderedListLengths = [];
32
+ this.footnotes = [];
33
+ this.fnCounter = footnoteOffset;
34
+ this.affCounter = affiliationOffset;
35
+ this.metaData = {
36
+ title: this.docTitle,
37
+ authors: [],
38
+ abstract: false,
39
+ keywords: [],
40
+ copyright: {
41
+ licenses: []
42
+ },
43
+ toc: []
44
+ };
45
+ this.features = {
46
+ math: false,
47
+ bibliography: false
48
+ };
49
+ this.citations = {
50
+ type: "",
51
+ bibCSS: "",
52
+ bibHTML: "",
53
+ citationTexts: []
54
+ };
55
+ this.citInfos = [];
56
+ this.citationCount = 0;
57
+ this.extraStyleSheets = [];
58
+ this.idPrefix = idPrefix;
59
+ this.categoryCounter = Object.assign({}, figureOffset);
60
+ }
61
+ init() {
62
+ this.analyze(this.docContent);
63
+ return this.process();
64
+ }
65
+ async processCitInfos() {
66
+ const citationProcessor = new HTMLExporterCitations(this.docSettings, this.bibDB, this.csl);
67
+ const citations = await citationProcessor.init(this.citInfos);
68
+ this.citations = citations;
69
+ }
70
+ async process() {
71
+ if (this.citInfos.length) {
72
+ await this.processCitInfos();
73
+ }
74
+ if (this.citations.bibCSS.length) {
75
+ this.extraStyleSheets.push({
76
+ filename: this.relativeUrls ? "css/bibliography.css" : null,
77
+ contents: pretty(this.citations.bibCSS, {
78
+ ocd: true
79
+ })
80
+ });
81
+ }
82
+ if (this.features.math) {
83
+ this.extraStyleSheets.push({
84
+ filename: this.relativeUrls
85
+ ? "css/mathlive.css"
86
+ : staticUrl("css/libs/mathlive/mathlive.css")
87
+ });
88
+ }
89
+ const body = this.assembleBody();
90
+ const back = this.assembleBack();
91
+ const head = this.assembleHead();
92
+ const html = this.htmlExportTemplate({
93
+ head,
94
+ body,
95
+ back,
96
+ settings: this.docSettings,
97
+ lang: this.docSettings.language.split("-")[0],
98
+ xhtml: this.xhtml,
99
+ epub: this.epub
100
+ });
101
+ return {
102
+ html,
103
+ imageIds: this.imageIds,
104
+ extraStyleSheets: this.extraStyleSheets,
105
+ metaData: this.metaData
106
+ };
107
+ }
108
+ // Find information for meta tags in header
109
+ analyze(node) {
110
+ switch (node.type) {
111
+ case "citation":
112
+ this.citInfos.push(JSON.parse(JSON.stringify(node.attrs)));
113
+ break;
114
+ case "contributors_part":
115
+ if (node.attrs.metadata === "authors" && node.content) {
116
+ node.content.forEach(author => {
117
+ this.metaData.authors.push(author);
118
+ });
119
+ }
120
+ break;
121
+ case "doc":
122
+ this.metaData.copyright = node.attrs.copyright;
123
+ break;
124
+ case "heading1":
125
+ case "heading2":
126
+ case "heading3":
127
+ case "heading4":
128
+ case "heading5":
129
+ case "heading6": {
130
+ const level = Number.parseInt(node.type.slice(-1));
131
+ this.metaData.toc.push({
132
+ level,
133
+ id: node.attrs.id,
134
+ title: (node.content || [])
135
+ .map(subNode => this.walkJson(subNode))
136
+ .join("")
137
+ });
138
+ break;
139
+ }
140
+ case "equation":
141
+ case "figure_equation":
142
+ this.features.math = true;
143
+ break;
144
+ case "footnote":
145
+ node.attrs.footnote.forEach(child => this.analyze(child));
146
+ break;
147
+ case "richtext_part":
148
+ if (node.attrs.metadata === "abstract" &&
149
+ !node.attrs.language &&
150
+ this.metaData.abstract) {
151
+ this.metaData.abstract = this.walkJson(node);
152
+ }
153
+ break;
154
+ case "tags_part":
155
+ if (node.attrs.metadata === "keywords" && node.content) {
156
+ node.content.forEach(tag => {
157
+ this.metaData.keywords.push(tag.attrs.tag);
158
+ });
159
+ }
160
+ break;
161
+ case "title": {
162
+ const title = this.textWalkJson(node);
163
+ if (title.length) {
164
+ this.metaData.title = title;
165
+ }
166
+ this.metaData.toc.push({
167
+ docTitle: true,
168
+ level: 1,
169
+ id: "title",
170
+ title: title
171
+ });
172
+ break;
173
+ }
174
+ default:
175
+ break;
176
+ }
177
+ if (node.content) {
178
+ node.content.forEach(child => this.analyze(child));
179
+ }
180
+ }
181
+ assembleHead() {
182
+ let head = `<title>${escapeText(this.metaData.title)}</title>`;
183
+ if (this.metaData.authors.length) {
184
+ const authorString = this.metaData.authors
185
+ .map(author => {
186
+ if (author.firstname || author.lastname) {
187
+ const nameParts = [];
188
+ if (author.firstname) {
189
+ nameParts.push(author.firstname);
190
+ }
191
+ if (author.lastname) {
192
+ nameParts.push(author.lastname);
193
+ }
194
+ return nameParts.join(" ");
195
+ }
196
+ else if (author.institution) {
197
+ return author.institution;
198
+ }
199
+ })
200
+ .join(", ");
201
+ if (authorString.length) {
202
+ head += `<meta name="author" content="${escapeText(authorString)}"${this.endSlash}>`;
203
+ }
204
+ }
205
+ if (this.metaData.copyright.holder) {
206
+ head += `<link rel="schema.dcterms" href="http://purl.org/dc/terms/"${this.endSlash}>`;
207
+ const year = this.metaData.copyright.year
208
+ ? this.metaData.copyright.year
209
+ : new Date().getFullYear();
210
+ head += `<meta name="dcterms.dateCopyrighted" content="${year}"${this.endSlash}>`;
211
+ head += `<meta name="dcterms.rightsHolder" content="${escapeText(this.metaData.copyright.holder)}"${this.endSlash}>`;
212
+ // TODO: Add this.metaData.copyright.freeToRead if present
213
+ head += this.metaData.copyright.licenses
214
+ .map(license => `<link rel="license" href="${escapeText(license.url)}"${this.endSlash}>` // TODO: Add this.metaData.copyright.license.start info if present
215
+ )
216
+ .join("");
217
+ }
218
+ if (this.metaData.abstract.default) {
219
+ head += this.walkJson(this.metaData.abstract.default);
220
+ }
221
+ Object.keys(this.metaData.abstract)
222
+ .filter(language => language !== "default")
223
+ .forEach(language => {
224
+ head += this.walkJson(this.metaData.abstract[language]);
225
+ });
226
+ if (this.metaData.keywords.length) {
227
+ head += `<meta name="keywords" content="${escapeText(this.metaData.keywords.join(", "))}"${this.endSlash}>`;
228
+ }
229
+ head += this.styleSheets
230
+ .concat(this.extraStyleSheets)
231
+ .map(sheet => {
232
+ if (!sheet.filename && !sheet.contents) {
233
+ console.warn("No filename or contents for stylesheet.", sheet);
234
+ return "";
235
+ }
236
+ return sheet.filename
237
+ ? `<link rel="stylesheet" type="text/css" href="${sheet.filename}"${this.endSlash}>`
238
+ : `<style>${sheet.contents}</style>`;
239
+ })
240
+ .join("");
241
+ return head;
242
+ }
243
+ // Only allow for text output
244
+ textWalkJson(node) {
245
+ let content = "";
246
+ if (node.type === "text") {
247
+ content += escapeText(node.text).normalize("NFC");
248
+ }
249
+ else if (node.content) {
250
+ node.content.forEach(child => {
251
+ content += this.textWalkJson(child);
252
+ });
253
+ }
254
+ return content;
255
+ }
256
+ walkJson(node, options = {}) {
257
+ let start = "", content = "", end = "";
258
+ switch (node.type) {
259
+ case "doc":
260
+ break;
261
+ case "title":
262
+ start += `<div class="doc-part doc-title" id="${this.idPrefix}title">`;
263
+ end = "</div>" + end;
264
+ break;
265
+ case "heading_part":
266
+ start += `<div class="doc-part doc-heading doc-${node.attrs.id} ${node.attrs.metadata || "other"}" id="${this.idPrefix}${node.attrs.id}"${node.attrs.language ? ` lang="${node.attrs.language}"` : ""}>`;
267
+ end = "</div>" + end;
268
+ break;
269
+ case "contributor":
270
+ // Ignore - we deal with contributors_part instead.
271
+ break;
272
+ case "contributors_part":
273
+ if (node.content) {
274
+ start += `<div class="doc-part doc-contributors doc-${node.attrs.id} ${node.attrs.metadata || "other"}" id="${this.idPrefix}${node.attrs.id}"${node.attrs.language ? ` lang="${node.attrs.language}"` : ""}>`;
275
+ end = "</div>" + end;
276
+ let counter = 0;
277
+ const contributorOutputs = [];
278
+ node.content.forEach(childNode => {
279
+ const contributor = childNode.attrs;
280
+ let output = "";
281
+ if (contributor.firstname || contributor.lastname) {
282
+ output += `<span id="${this.idPrefix}${node.attrs.id}-${counter++}" class="person">`;
283
+ const nameParts = [];
284
+ if (contributor.firstname) {
285
+ nameParts.push(`<span class="firstname">${escapeText(contributor.firstname)}</span>`);
286
+ }
287
+ if (contributor.lastname) {
288
+ nameParts.push(`<span class="lastname">${escapeText(contributor.lastname)}</span>`);
289
+ }
290
+ if (nameParts.length) {
291
+ output += `<span class="name">${nameParts.join(" ")}</span>`;
292
+ }
293
+ if (contributor.institution) {
294
+ let affNumber;
295
+ if (this.affiliations[contributor.institution]) {
296
+ affNumber =
297
+ this.affiliations[contributor.institution];
298
+ }
299
+ else {
300
+ affNumber = ++this.affCounter;
301
+ this.affiliations[contributor.institution] =
302
+ affNumber;
303
+ }
304
+ const affNumberDisplay = displayNumber(affNumber, this.affiliationNumbering);
305
+ output += `<a class="affiliation" href="#aff-${affNumber}"${this.epub ? ' epub:type="noteref"' : ""}>${affNumberDisplay}</a>`;
306
+ }
307
+ if (contributor.id_type && contributor.id_value) {
308
+ output += `<span class="contributor-id">${escapeText(contributor.id_type)}: ${escapeText(contributor.id_value)}</span>`;
309
+ }
310
+ output += "</span>";
311
+ }
312
+ else if (contributor.institution) {
313
+ // There is an affiliation but no first/last name. We take this
314
+ // as a group collaboration.
315
+ output += `<span id="${this.idPrefix}${node.attrs.id}-${counter++}" class="group">`;
316
+ output += `<span class="name">${escapeText(contributor.institution)}</span>`;
317
+ output += "</span>";
318
+ }
319
+ contributorOutputs.push(output);
320
+ });
321
+ content += contributorOutputs.join(", ");
322
+ }
323
+ break;
324
+ case "tags_part":
325
+ if (node.content) {
326
+ start += `<div class="doc-part doc-tags doc-${node.attrs.id} doc-${node.attrs.metadata || "other"}" id="${this.idPrefix}${node.attrs.id}"${node.attrs.language ? ` lang="${node.attrs.language}"` : ""}>`;
327
+ end = "</div>" + end;
328
+ }
329
+ break;
330
+ case "tag":
331
+ content += `<span class='tag'>${escapeText(node.attrs.tag)}</span>`;
332
+ break;
333
+ case "richtext_part":
334
+ if (node.content) {
335
+ start += `<div class="doc-part doc-richtext doc-${node.attrs.id} doc-${node.attrs.metadata || "other"}" id="${this.idPrefix}${node.attrs.id}"${node.attrs.language ? ` lang="${node.attrs.language}"` : ""}>`;
336
+ end = "</div>" + end;
337
+ }
338
+ break;
339
+ case "table_of_contents":
340
+ start += `<div class="doc-part table-of-contents"><h1>${escapeText(node.attrs.title)}</h1>`;
341
+ content += this.metaData.toc
342
+ .map(item => `<h${item.level}><a href="#${item.id}">${item.title}</a></h${item.level}>`)
343
+ .join("");
344
+ end += "</div>";
345
+ break;
346
+ case "separator_part":
347
+ content += `<hr class="doc-part doc-separator doc-${node.attrs.id} doc-${node.attrs.metadata || "other"}" id="${this.idPrefix}${node.attrs.id}">`;
348
+ break;
349
+ case "table_part":
350
+ if (node.content) {
351
+ start += `<div class="doc-part doc-table doc-${node.attrs.id} doc-${node.attrs.metadata || "other"}" id="${this.idPrefix}${node.attrs.id}"${node.attrs.language ? ` lang="${node.attrs.language}"` : ""}>`;
352
+ end = "</div>" + end;
353
+ }
354
+ break;
355
+ case "paragraph":
356
+ start += `<p id="${this.idPrefix}p-${++this.parCounter}">`;
357
+ end = "</p>" + end;
358
+ break;
359
+ case "heading1":
360
+ case "heading2":
361
+ case "heading3":
362
+ case "heading4":
363
+ case "heading5":
364
+ case "heading6": {
365
+ const level = Number.parseInt(node.type.slice(-1));
366
+ start += `<h${level} id="${this.idPrefix}${node.attrs.id}">`;
367
+ end = `</h${level}>` + end;
368
+ break;
369
+ }
370
+ case "code_block": {
371
+ const attrs = [];
372
+ if (node.attrs.language) {
373
+ attrs.push(`data-language="${escapeText(node.attrs.language)}"`);
374
+ }
375
+ if (node.attrs.category) {
376
+ attrs.push(`data-category="${node.attrs.category}"`);
377
+ }
378
+ if (node.attrs.title) {
379
+ attrs.push(`data-title="${escapeText(node.attrs.title)}"`);
380
+ }
381
+ if (node.attrs.id) {
382
+ attrs.push(`data-id="${node.attrs.id}"`);
383
+ }
384
+ const attrString = attrs.length ? ` ${attrs.join(" ")}` : "";
385
+ // If there's a category, wrap in figure for proper numbering
386
+ if (node.attrs.category && node.attrs.id) {
387
+ const language = this.doc.attrs.language || "en-US";
388
+ const { CATS } = require("../../schema/i18n");
389
+ const categoryLabel = CATS[node.attrs.category]?.[language] ||
390
+ node.attrs.category;
391
+ // Count code blocks to get the number
392
+ const categories = {};
393
+ this.doc.descendants(n => {
394
+ if (n.type === "code_block" &&
395
+ n.attrs.category &&
396
+ n.attrs.id) {
397
+ if (!categories[n.attrs.category]) {
398
+ categories[n.attrs.category] = 0;
399
+ }
400
+ categories[n.attrs.category]++;
401
+ if (n.attrs.id === node.attrs.id) {
402
+ return false;
403
+ }
404
+ }
405
+ });
406
+ const number = categories[node.attrs.category] || 1;
407
+ const label = node.attrs.title
408
+ ? `${categoryLabel} ${number}: ${escapeText(node.attrs.title)}`
409
+ : `${categoryLabel} ${number}`;
410
+ start += `<figure class="code-block-figure" id="${this.idPrefix}${node.attrs.id}"><figcaption><span class="label">${label}</span></figcaption><pre${attrString}><code>`;
411
+ end = `</code></pre></figure>` + end;
412
+ }
413
+ else {
414
+ start += `<code${attrString}>`;
415
+ end = "</code>" + end;
416
+ }
417
+ break;
418
+ }
419
+ case "blockquote":
420
+ start += "<blockquote>";
421
+ end = "</blockquote>" + end;
422
+ break;
423
+ case "ordered_list": {
424
+ if (node.attrs.order == 1) {
425
+ start += `<ol id="${this.idPrefix}list-${++this.listCounter}">`;
426
+ }
427
+ else {
428
+ start += `<ol id="${this.idPrefix}list-${++this.listCounter}" start="${node.attrs.order}">`;
429
+ }
430
+ end = "</ol>" + end;
431
+ break;
432
+ }
433
+ case "bullet_list":
434
+ start += `<ul id="${this.idPrefix}list-${++this.listCounter}">`;
435
+ end = "</ul>" + end;
436
+ break;
437
+ case "list_item":
438
+ start += "<li>";
439
+ end = "</li>" + end;
440
+ break;
441
+ case "footnote": {
442
+ const footnoteNumber = ++this.fnCounter;
443
+ const footnoteNumberDisplay = displayNumber(footnoteNumber, this.footnoteNumbering);
444
+ content += `<a class="footnote"${this.epub ? ' epub:type="noteref"' : ""} href="#fn-${footnoteNumber}">${footnoteNumberDisplay}</a>`;
445
+ options = Object.assign({}, options);
446
+ options.inFootnote = true;
447
+ this.footnotes.push(this.walkJson({
448
+ type: "footnotecontainer",
449
+ attrs: {
450
+ id: `fn-${footnoteNumber}`,
451
+ label: footnoteNumberDisplay // Note: it's unclear whether the footnote number is required as a label
452
+ },
453
+ content: node.attrs.footnote
454
+ }, options));
455
+ break;
456
+ }
457
+ case "footnotecontainer":
458
+ start += `<aside class="footnote"${this.epub ? ' epub:type="footnote"' : ""} role="doc-footnote" id="${this.idPrefix}${node.attrs.id}"><label>${node.attrs.label}</label>`;
459
+ end = "</aside>" + end;
460
+ break;
461
+ case "text": {
462
+ let strong, em, underline, hyperlink, anchor, sup, sub, code;
463
+ // Check for hyperlink, bold/strong, italic/em and underline
464
+ if (node.marks) {
465
+ strong = node.marks.find(mark => mark.type === "strong");
466
+ em = node.marks.find(mark => mark.type === "em");
467
+ underline = node.marks.find(mark => mark.type === "underline");
468
+ hyperlink = node.marks.find(mark => mark.type === "link");
469
+ anchor = node.marks.find(mark => mark.type === "anchor");
470
+ sup = node.marks.find(mark => mark.type === "sup");
471
+ sub = node.marks.find(mark => mark.type === "sub");
472
+ code = node.marks.find(mark => mark.type === "code");
473
+ }
474
+ if (em) {
475
+ start += "<em>";
476
+ end = "</em>" + end;
477
+ }
478
+ if (strong) {
479
+ start += "<strong>";
480
+ end = "</strong>" + end;
481
+ }
482
+ if (underline) {
483
+ start += '<span class="underline">';
484
+ end = "</span>" + end;
485
+ }
486
+ if (sup) {
487
+ start += "<sup>";
488
+ end = "</sup>" + end;
489
+ }
490
+ if (sub) {
491
+ start += "<sub>";
492
+ end = "</sub>" + end;
493
+ }
494
+ if (code) {
495
+ start += "<code>";
496
+ end = "</code>" + end;
497
+ }
498
+ if (hyperlink) {
499
+ const href = hyperlink.attrs.href;
500
+ const link = href.startsWith("#")
501
+ ? `#${this.idPrefix}${href.slice(1)}`
502
+ : href;
503
+ start += `<a href="${link}">`;
504
+ end = "</a>" + end;
505
+ }
506
+ if (anchor) {
507
+ const id = anchor.attrs.id;
508
+ start += `<span class="anchor" id="${this.idPrefix}${id}" data-id="${this.idPrefix}${id}">`;
509
+ end = "</span>" + end;
510
+ }
511
+ content += escapeText(node.text).normalize("NFC");
512
+ break;
513
+ }
514
+ case "cross_reference": {
515
+ start += `<a class="reference" href="#${this.idPrefix}${node.attrs.id}">`;
516
+ content += escapeText(node.attrs.title || "MISSING TARGET");
517
+ end = "</a>" + end;
518
+ break;
519
+ }
520
+ case "citation": {
521
+ if (!this.citations.citationTexts.length) {
522
+ // There are no citations. This may happen while analyzing.
523
+ return "";
524
+ }
525
+ const citationText = this.citations.citationTexts[this.citationCount++];
526
+ if (options.inFootnote ||
527
+ this.citations.citationType !== "note") {
528
+ content += citationText;
529
+ }
530
+ else {
531
+ content += `<a class="footnote"${this.epub ? 'epub:type="noteref" ' : ""} href="#fn-${++this.fnCounter}">${this.fnCounter}</a>`;
532
+ this.footnotes.push(`<aside class="footnote"${this.epub ? 'epub:type="footnote" ' : ""} id="fn-${this.fnCounter}"><label>${this.fnCounter}</label><p id="${this.idPrefix}p-${++this.parCounter}">${citationText}</p></aside>`);
533
+ }
534
+ break;
535
+ }
536
+ case "figure": {
537
+ let imageUrl, copyright;
538
+ const image = node.content.find(node => node.type === "image")?.attrs
539
+ .image || false;
540
+ if (image !== false) {
541
+ this.imageIds.push(image);
542
+ const imageDBEntry = this.imageDB.db[image], filePathName = imageDBEntry.image;
543
+ copyright = imageDBEntry.copyright;
544
+ imageUrl = this.relativeUrls
545
+ ? `images/${filePathName.split("/").pop()}`
546
+ : filePathName;
547
+ }
548
+ const caption = node.attrs.caption
549
+ ? node.content.find(node => node.type === "figure_caption")
550
+ ?.content || []
551
+ : [];
552
+ if (node.attrs.category === "none" &&
553
+ imageUrl &&
554
+ !caption.length &&
555
+ (!copyright || !copyright.holder)) {
556
+ content += `<img id="${this.idPrefix}${node.attrs.id}" class="aligned-${node.attrs.aligned} image-width-${node.attrs.width}" src="${imageUrl}"${this.endSlash}>`;
557
+ }
558
+ else {
559
+ start += `<figure
560
+ id="${this.idPrefix}${node.attrs.id}"
561
+ class="aligned-${node.attrs.aligned} image-width-${node.attrs.width}"
562
+ data-aligned="${node.attrs.aligned}"
563
+ data-width="${node.attrs.width}"
564
+ data-category="${node.attrs.category}"
565
+ >`;
566
+ end = "</figure>" + end;
567
+ const equation = node.content.find(node => node.type === "figure_equation")?.attrs.equation;
568
+ if (image && copyright?.holder) {
569
+ let figureFooter = `<footer class="copyright ${copyright.freeToRead ? "free-to-read" : "not-free-to-read"}"><small>`;
570
+ figureFooter += "© ";
571
+ const year = copyright.year
572
+ ? copyright.year
573
+ : new Date().getFullYear();
574
+ figureFooter += `<span class="copyright-year">${year}</span> `;
575
+ figureFooter += `<span class="copyright-holder">${escapeText(copyright.holder)}</span> `;
576
+ figureFooter += copyright.licenses
577
+ .map(license => `<span class="license"><a rel="license"${license.start ? ` data-start="${license.start}"` : ""}>${escapeText(license.url)}</a></span>`)
578
+ .join("");
579
+ figureFooter += "</small></footer>";
580
+ end = figureFooter + end;
581
+ }
582
+ const category = node.attrs.category;
583
+ if (caption.length || category !== "none") {
584
+ let figcaption = "<figcaption>";
585
+ if (category !== "none") {
586
+ if (!this.categoryCounter[category]) {
587
+ this.categoryCounter[category] = 0;
588
+ }
589
+ const catCount = ++this.categoryCounter[category];
590
+ const catLabel = `${CATS[category][this.docSettings.language]} ${catCount}`;
591
+ figcaption += `<label>${escapeText(catLabel)}</label>`;
592
+ }
593
+ if (caption.length) {
594
+ figcaption += `<p>${caption.map(node => this.walkJson(node)).join("")}</p>`;
595
+ }
596
+ figcaption += "</figcaption>";
597
+ if (category === "table") {
598
+ start += figcaption;
599
+ }
600
+ else {
601
+ end = figcaption + end;
602
+ }
603
+ }
604
+ if (equation) {
605
+ start += `<div class="figure-equation" data-equation="${escapeText(equation)}"><math display="block">`;
606
+ end = "</math></div>" + end;
607
+ content = convertLatexToMathMl(equation);
608
+ }
609
+ else {
610
+ if (imageUrl) {
611
+ content += `<img src="${imageUrl}"${this.endSlash}>`;
612
+ }
613
+ }
614
+ }
615
+ break;
616
+ }
617
+ case "figure_caption":
618
+ // We are already dealing with this in the figure. Prevent content from being added a second time.
619
+ return "";
620
+ case "figure_equation":
621
+ // We are already dealing with this in the figure.
622
+ break;
623
+ case "image":
624
+ // We are already dealing with this in the figure.
625
+ break;
626
+ case "table": {
627
+ start += `<table
628
+ id="${this.idPrefix}${node.attrs.id}"
629
+ class="table-${node.attrs.width}
630
+ table-${node.attrs.aligned}
631
+ table-${node.attrs.layout}"
632
+ data-width="${node.attrs.width}"
633
+ data-aligned="${node.attrs.aligned}"
634
+ data-layout="${node.attrs.layout}"
635
+ data-category="${node.attrs.category}"
636
+ >`;
637
+ end = "</table>" + end;
638
+ const category = node.attrs.category;
639
+ if (category !== "none") {
640
+ if (!this.categoryCounter[category]) {
641
+ this.categoryCounter[category] = 0;
642
+ }
643
+ const catCount = ++this.categoryCounter[category];
644
+ const catLabel = `${CATS[category][this.docSettings.language]} ${catCount}`;
645
+ start += `<label>${escapeText(catLabel)}</label>`;
646
+ }
647
+ const caption = node.attrs.caption
648
+ ? node.content[0].content || []
649
+ : [];
650
+ if (caption.length) {
651
+ start += `<caption><p>${caption.map(node => this.walkJson(node)).join("")}</p></caption>`;
652
+ }
653
+ start += "<tbody>";
654
+ end = "</tbody>" + end;
655
+ break;
656
+ }
657
+ case "table_body":
658
+ // Pass through to table.
659
+ break;
660
+ case "table_caption":
661
+ // We already deal with this in 'table'.
662
+ return "";
663
+ case "table_row":
664
+ start += "<tr>";
665
+ end = "</tr>" + end;
666
+ break;
667
+ case "table_cell":
668
+ start += `<td${node.attrs.colspan === 1 ? "" : ` colspan="${node.attrs.colspan}"`}${node.attrs.rowspan === 1 ? "" : ` rowspan="${node.attrs.rowspan}"`}>`;
669
+ end = "</td>" + end;
670
+ break;
671
+ case "table_header":
672
+ start += `<th${node.attrs.colspan === 1 ? "" : ` colspan="${node.attrs.colspan}"`}${node.attrs.rowspan === 1 ? "" : ` rowspan="${node.attrs.rowspan}"`}>`;
673
+ end = "</th>" + end;
674
+ break;
675
+ case "equation":
676
+ start += '<span class="equation"><math>';
677
+ end = "</math></span>" + end;
678
+ content = convertLatexToMathMl(node.attrs.equation);
679
+ break;
680
+ case "hard_break":
681
+ content += `<br${this.endSlash}>`;
682
+ break;
683
+ default:
684
+ break;
685
+ }
686
+ if (!content.length && node.content) {
687
+ node.content.forEach(child => {
688
+ content += this.walkJson(child, options);
689
+ });
690
+ }
691
+ return start + content + end;
692
+ }
693
+ assembleBody() {
694
+ return `<div id="${this.idPrefix}body">${this.walkJson(this.docContent)}</div>`;
695
+ }
696
+ assembleBack() {
697
+ let back = "";
698
+ if (this.footnotes.length ||
699
+ this.citations.bibHTML.length ||
700
+ Object.keys(this.affiliations).length) {
701
+ back += `<div id="${this.idPrefix}back">`;
702
+ if (Object.keys(this.affiliations).length) {
703
+ back += `<section id="${this.idPrefix}affiliations" class="affiliations">${Object.entries(this.affiliations)
704
+ .map(([name, id]) => `<aside class="affiliation" id="aff-${id}"${this.epub ? 'epub:type="footnote"' : ""}><label>${displayNumber(id, this.affiliationNumbering)}</label> <div>${escapeText(name)}</div></aside>`)
705
+ .join("")}</section>`;
706
+ }
707
+ if (this.footnotes.length) {
708
+ back += `<section class="fnlist footnotes" role="doc-footnotes" id="${this.idPrefix}footnotes">${this.footnotes.join("")}</section>`;
709
+ }
710
+ if (this.citations.bibHTML.length) {
711
+ back += `<div id="${this.idPrefix}references" class="references">${this.citations.bibHTML}</div>`;
712
+ }
713
+ back += "</div>";
714
+ }
715
+ return back;
716
+ }
717
+ }
718
+ //# sourceMappingURL=convert.js.map