@fiduswriter/document 0.1.0-alpha.3 → 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,865 @@
1
+ import { BIBLIOGRAPHY_HEADERS, CATS } from "../../schema/i18n.js";
2
+ import { escapeLatexText } from "./escape_latex.js";
3
+ export class LatexExporterConvert {
4
+ constructor(exporter, imageDB, bibDB, settings) {
5
+ this.exporter = exporter;
6
+ this.settings = settings;
7
+ this.imageDB = imageDB;
8
+ this.bibDB = bibDB;
9
+ this.imageIds = [];
10
+ this.usedBibDB = {};
11
+ // While walking the tree, we take note of the kinds of features That
12
+ // are present in the file, so that we can assemble an preamble and
13
+ // epilogue based on our findings.
14
+ this.features = {};
15
+ this.internalLinks = [];
16
+ this.categoryCounter = {}; // counters for each type of figure (figure/table/photo)
17
+ this.authorsTex = "";
18
+ }
19
+ init(docContent) {
20
+ this.preWalkJson(docContent);
21
+ const rawTransformation = this.walkJson(docContent);
22
+ const body = this.postProcess(rawTransformation);
23
+ const copyright = this.assembleCopyright();
24
+ const preamble = this.assemblePreamble();
25
+ const epilogue = this.assembleEpilogue();
26
+ const latex = copyright +
27
+ this.docDeclaration +
28
+ preamble +
29
+ this.authorsTex +
30
+ "\n\\begin{document}\n" +
31
+ body +
32
+ epilogue +
33
+ "\n\\end{document}\n";
34
+ const returnObject = {
35
+ latex,
36
+ imageIds: this.imageIds,
37
+ usedBibDB: this.usedBibDB
38
+ };
39
+ return returnObject;
40
+ }
41
+ get docDeclaration() {
42
+ return "\\documentclass{article}\n";
43
+ }
44
+ // Check for things needed before creating raw transform
45
+ preWalkJson(node) {
46
+ switch (node.type) {
47
+ // Collect all internal links so that we only set the anchors for those
48
+ // that are being linked to.
49
+ case "text":
50
+ if (node.marks) {
51
+ const hyperlink = node.marks.find(mark => mark.type === "link");
52
+ if (hyperlink) {
53
+ const href = hyperlink.attrs.href;
54
+ if (href[0] === "#" &&
55
+ !this.internalLinks.includes(href)) {
56
+ this.internalLinks.push(href.slice(1));
57
+ }
58
+ }
59
+ }
60
+ break;
61
+ }
62
+ if (node.content) {
63
+ node.content.forEach(child => this.preWalkJson(child));
64
+ }
65
+ }
66
+ walkJson(node, options = {}) {
67
+ let start = "", content = "", end = "", placeFootnotesAfterBlock = false;
68
+ switch (node.type) {
69
+ case "doc":
70
+ break;
71
+ case "title":
72
+ start += "\n\\title{";
73
+ end = "}" + end;
74
+ break;
75
+ case "heading_part":
76
+ if (node.attrs.metadata === "subtitle" && node.content) {
77
+ start += "\n\\subtitle{";
78
+ end = "}" + end;
79
+ this.features.subtitle = true;
80
+ options = Object.assign({}, options);
81
+ options.ignoreHeading = true;
82
+ }
83
+ else if (!options.madeTitle) {
84
+ start += "\n\n\\maketitle\n";
85
+ options.madeTitle = true;
86
+ }
87
+ break;
88
+ case "contributor":
89
+ // Ignore - we deal with contributors_part instead.
90
+ break;
91
+ case "contributors_part":
92
+ if (node.content) {
93
+ const contributorLabels = {
94
+ authors: gettext("Authors"),
95
+ editors: gettext("Editors"),
96
+ translators: gettext("Translators"),
97
+ reviewers: gettext("Reviewers"),
98
+ contributors: gettext("Contributors")
99
+ };
100
+ const roleLabel = contributorLabels[node.attrs.metadata];
101
+ if (node.attrs.metadata === "authors") {
102
+ const authorsPerAffil = node.content
103
+ .map(node => {
104
+ const author = node.attrs, nameParts = [];
105
+ let affiliation = false;
106
+ if (author.firstname) {
107
+ nameParts.push(author.firstname);
108
+ }
109
+ if (author.lastname) {
110
+ nameParts.push(author.lastname);
111
+ }
112
+ if (nameParts.length && author.institution) {
113
+ affiliation = author.institution;
114
+ }
115
+ else if (author.institution) {
116
+ // We have an institution but no names. Use institution as name.
117
+ nameParts.push(author.institution);
118
+ }
119
+ return {
120
+ name: nameParts.join(" "),
121
+ affiliation,
122
+ email: author.email,
123
+ id_type: author.id_type,
124
+ id_value: author.id_value
125
+ };
126
+ })
127
+ .reduce((affils, author) => {
128
+ const affil = author.affiliation;
129
+ affils[affil] = affils[affil] || [];
130
+ affils[affil].push(author);
131
+ return affils;
132
+ }, {});
133
+ Object.values(authorsPerAffil).forEach(affil => {
134
+ affil.forEach(author => {
135
+ let thanks = "";
136
+ if (author.email) {
137
+ thanks += `\\thanks{${escapeLatexText(author.email)}}`;
138
+ }
139
+ if (author.id_type && author.id_value) {
140
+ thanks += `\\thanks{${escapeLatexText(author.id_type)}: ${escapeLatexText(author.id_value)}}`;
141
+ }
142
+ this.authorsTex += `\n\\author{${escapeLatexText(author.name)}${thanks}}`;
143
+ });
144
+ this.authorsTex += `\n\\affil{${affil[0].affiliation
145
+ ? escapeLatexText(affil[0].affiliation)
146
+ : ""}}`;
147
+ });
148
+ this.authorsTex += "\n\n";
149
+ this.features.authors = true;
150
+ }
151
+ else {
152
+ if (!options.madeTitle) {
153
+ start += "\n\n\\maketitle\n";
154
+ options.madeTitle = true;
155
+ }
156
+ const contributorNames = node.content
157
+ .map(contributorNode => {
158
+ const attrs = contributorNode.attrs;
159
+ const nameParts = [];
160
+ if (attrs.firstname) {
161
+ nameParts.push(attrs.firstname);
162
+ }
163
+ if (attrs.lastname) {
164
+ nameParts.push(attrs.lastname);
165
+ }
166
+ if (!nameParts.length && attrs.institution) {
167
+ // We have an institution but no names. Use institution as name.
168
+ nameParts.push(attrs.institution);
169
+ }
170
+ let name = nameParts.join(" ");
171
+ if (attrs.id_type && attrs.id_value) {
172
+ name += ` (${escapeLatexText(attrs.id_type)}: ${escapeLatexText(attrs.id_value)})`;
173
+ }
174
+ return name;
175
+ })
176
+ .filter(name => name.length)
177
+ .join(", ");
178
+ if (contributorNames.length) {
179
+ content += `\n\\noindent\\textbf{${roleLabel}:} ${contributorNames}\n\n`;
180
+ }
181
+ }
182
+ }
183
+ break;
184
+ case "tags_part":
185
+ if (node.content) {
186
+ if (node.attrs.metadata === "keywords") {
187
+ start += "\n\\keywords{";
188
+ end = "}" + end;
189
+ this.features.keywords = true;
190
+ }
191
+ else if (!options.madeTitle) {
192
+ start += "\n\n\\maketitle\n";
193
+ options.madeTitle = true;
194
+ }
195
+ content += node.content
196
+ .map(keyword => escapeLatexText(keyword.attrs.tag))
197
+ .join("\\sep ");
198
+ }
199
+ break;
200
+ case "tag":
201
+ // Ignore - we already took all the tags_part from the keywords node.
202
+ break;
203
+ case "richtext_part":
204
+ if (!options.madeTitle) {
205
+ start += "\n\n\\maketitle\n";
206
+ options.madeTitle = true;
207
+ }
208
+ if (node.content && node.attrs.metadata === "abstract") {
209
+ start += "\n\\begin{abstract}\n";
210
+ end = "\n\\end{abstract}\n" + end;
211
+ }
212
+ break;
213
+ case "table_of_contents":
214
+ start += "\n\n\\tableofcontents\n";
215
+ break;
216
+ case "separator_part":
217
+ case "table_part":
218
+ // part separators as in page breaks should usually already be handled
219
+ // by LaTeX and table parts will simply show the table inside of them.
220
+ break;
221
+ case "paragraph":
222
+ start += "\n\n";
223
+ end = "\n" + end;
224
+ break;
225
+ case "heading1":
226
+ case "heading2":
227
+ case "heading3":
228
+ case "heading4":
229
+ case "heading5":
230
+ case "heading6": {
231
+ if (options.ignoreHeading) {
232
+ break;
233
+ }
234
+ const level = Number.parseInt(node.type.slice(-1));
235
+ switch (level) {
236
+ case 1:
237
+ start += "\n\n\\section{";
238
+ break;
239
+ case 2:
240
+ start += "\n\n\\subsection{";
241
+ break;
242
+ case 3:
243
+ case 4:
244
+ case 5:
245
+ case 6:
246
+ // TODO: Add support for levels 4/5/6
247
+ start += "\n\n\\subsubsection{";
248
+ break;
249
+ }
250
+ end = `}\\label{${node.attrs.id}}\n\n` + end;
251
+ // Check if this heading is being linked to. If this is the case,
252
+ // place a protected hypertarget here that does not add an extra
253
+ // entry into the PDF TOC.
254
+ if (this.internalLinks.includes(node.attrs.id)) {
255
+ // Add a link target
256
+ end =
257
+ end +
258
+ `\\texorpdfstring{\\protect\\hypertarget{${node.attrs.id}}{}}{}`;
259
+ }
260
+ options = Object.assign({}, options);
261
+ options.noLineBreak = true;
262
+ if (!options.onlyFootnoteMarkers) {
263
+ placeFootnotesAfterBlock = true;
264
+ options.onlyFootnoteMarkers = true;
265
+ options.unplacedFootnotes = [];
266
+ }
267
+ break;
268
+ }
269
+ case "code_block": {
270
+ // Support language and category attributes
271
+ if (node.attrs.category && node.attrs.id) {
272
+ const language = this.doc.attrs.language || "en-US";
273
+ const { CATS } = require("../../schema/i18n");
274
+ const categoryLabel = CATS[node.attrs.category]?.[language] ||
275
+ node.attrs.category;
276
+ // Count code blocks to get the number
277
+ const categories = {};
278
+ this.doc.descendants(n => {
279
+ if (n.type === "code_block" &&
280
+ n.attrs.category &&
281
+ n.attrs.id) {
282
+ if (!categories[n.attrs.category]) {
283
+ categories[n.attrs.category] = 0;
284
+ }
285
+ categories[n.attrs.category]++;
286
+ if (n.attrs.id === node.attrs.id) {
287
+ return false;
288
+ }
289
+ }
290
+ });
291
+ const number = categories[node.attrs.category] || 1;
292
+ const caption = node.attrs.title
293
+ ? `${categoryLabel} ${number}: ${this.convertText(node.attrs.title)}`
294
+ : `${categoryLabel} ${number}`;
295
+ start += `\n\\begin{listing}\n\\caption{${caption}}\\label{${node.attrs.id}}\n\\begin{code}\n\n`;
296
+ end = `\n\n\\end{code}\n\\end{listing}\n` + end;
297
+ this.features.listing = true;
298
+ }
299
+ else if (node.attrs.language) {
300
+ start += `\n\\begin{code}[${this.convertText(node.attrs.language)}]\n\n`;
301
+ end = `\n\n\\end{code}\n` + end;
302
+ }
303
+ else {
304
+ start += "\n\\begin{code}\n\n";
305
+ end = "\n\n\\end{code}\n" + end;
306
+ }
307
+ this.features.code = true;
308
+ break;
309
+ }
310
+ case "blockquote":
311
+ start += "\n\\begin{quote}\n\n";
312
+ end = "\n\n\\end{quote}\n" + end;
313
+ break;
314
+ case "ordered_list":
315
+ if (node.attrs.order !== 1) {
316
+ start += `\n\\begin{enumerate}[start=${node.attrs.order}]`;
317
+ this.features.orderedListStart = true;
318
+ }
319
+ else {
320
+ start += "\n\\begin{enumerate}";
321
+ }
322
+ end = "\n\\end{enumerate}" + end;
323
+ if (!options.onlyFootnoteMarkers) {
324
+ placeFootnotesAfterBlock = true;
325
+ options = Object.assign({}, options);
326
+ options.onlyFootnoteMarkers = true;
327
+ options.unplacedFootnotes = [];
328
+ }
329
+ break;
330
+ case "bullet_list":
331
+ start += "\n\\begin{itemize}";
332
+ end = "\n\\end{itemize}" + end;
333
+ if (!options.onlyFootnoteMarkers) {
334
+ placeFootnotesAfterBlock = true;
335
+ options = Object.assign({}, options);
336
+ options.onlyFootnoteMarkers = true;
337
+ options.unplacedFootnotes = [];
338
+ }
339
+ break;
340
+ case "list_item":
341
+ start += "\n\\item ";
342
+ end = "\n" + end;
343
+ break;
344
+ case "footnote":
345
+ if (options.onlyFootnoteMarkers) {
346
+ // We are inside a headline or a list and can only place a
347
+ // footnote marker here. The footnote will have to be put
348
+ // beyond the block node instead.
349
+ start += "\\protect\\footnotemark{}";
350
+ options.unplacedFootnotes.push(node.attrs.footnote);
351
+ }
352
+ else {
353
+ if (!node.attrs.footnote.find(par => par.type === "figure")) {
354
+ // LaTeX doesn't allow figures in footnotes, so well move
355
+ // this footnote into the regular text.
356
+ start += "\\footnote{";
357
+ end = "}" + end;
358
+ }
359
+ let fnContent = "";
360
+ node.attrs.footnote.forEach(footPar => {
361
+ fnContent += this.walkJson(footPar, options);
362
+ });
363
+ content += fnContent.replace(/^\s+|\s+$/g, "");
364
+ }
365
+ break;
366
+ case "text": {
367
+ let strong, em, underline, hyperlink, anchor, sup, sub, code;
368
+ // Check for hyperlink, bold/strong, italic/em and underline
369
+ if (node.marks) {
370
+ strong = node.marks.find(mark => mark.type === "strong");
371
+ em = node.marks.find(mark => mark.type === "em");
372
+ underline = node.marks.find(mark => mark.type === "underline");
373
+ hyperlink = node.marks.find(mark => mark.type === "link");
374
+ anchor = node.marks.find(mark => mark.type === "anchor");
375
+ sup = node.marks.find(mark => mark.type === "sup");
376
+ sub = node.marks.find(mark => mark.type === "sub");
377
+ code = node.marks.find(mark => mark.type === "code");
378
+ }
379
+ if (em) {
380
+ start += "\\emph{";
381
+ end = "}" + end;
382
+ }
383
+ if (strong) {
384
+ start += "\\textbf{";
385
+ end = "}" + end;
386
+ }
387
+ if (underline) {
388
+ start += "\\underline{";
389
+ end = "}" + end;
390
+ }
391
+ if (sup) {
392
+ start += "\\textsuperscript{";
393
+ end = "}" + end;
394
+ }
395
+ if (sub) {
396
+ start += "\\textsubscript{";
397
+ end = "}" + end;
398
+ }
399
+ if (code) {
400
+ start += "\\texttt{";
401
+ end = "}" + end;
402
+ }
403
+ if (hyperlink) {
404
+ const href = hyperlink.attrs.href;
405
+ if (href[0] === "#") {
406
+ // Internal link
407
+ start += `\\hyperlink{${href.slice(1)}}{`;
408
+ }
409
+ else {
410
+ // External link
411
+ start += `\\href{${href}}{`;
412
+ }
413
+ end = "}" + end;
414
+ this.features.hyperlinks = true;
415
+ }
416
+ if (anchor && this.internalLinks.includes(anchor.attrs.id)) {
417
+ // Add a link target
418
+ start += `\\hypertarget{${anchor.attrs.id}}{`;
419
+ end = "}" + end;
420
+ }
421
+ content += escapeLatexText(node.text);
422
+ break;
423
+ }
424
+ case "cross_reference": {
425
+ content += `\\hyperref[${node.attrs.id}]{${node.attrs.title || "MISSING TARGET"}}`;
426
+ this.features.hyperlinks = true;
427
+ break;
428
+ }
429
+ case "citation": {
430
+ const references = node.attrs.references;
431
+ const format = node.attrs.format;
432
+ let citationCommand = "\\" + format;
433
+ if (references.length > 1 &&
434
+ references.every(ref => !ref.locator && !ref.prefix)) {
435
+ // multi source citation without page numbers or text before.
436
+ const citationEntryKeys = [];
437
+ const allCitationItemsPresent = references
438
+ .map(ref => ref.id)
439
+ .every(citationEntry => {
440
+ const bibDBEntry = this.bibDB.db[citationEntry];
441
+ if (bibDBEntry) {
442
+ if (!bibDBEntry) {
443
+ // Not present in bibliography database, skip it.
444
+ // TODO: Throw an error?
445
+ return false;
446
+ }
447
+ if (!this.usedBibDB[citationEntry]) {
448
+ const citationKey = this.createUniqueCitationKey(bibDBEntry.entry_key);
449
+ this.usedBibDB[citationEntry] =
450
+ Object.assign({}, bibDBEntry);
451
+ this.usedBibDB[citationEntry].entry_key =
452
+ citationKey;
453
+ }
454
+ citationEntryKeys.push(this.usedBibDB[citationEntry].entry_key);
455
+ }
456
+ return true;
457
+ });
458
+ if (allCitationItemsPresent) {
459
+ citationCommand += `{${citationEntryKeys.join(",")}}`;
460
+ }
461
+ else {
462
+ citationCommand = false;
463
+ }
464
+ }
465
+ else {
466
+ if (references.length > 1) {
467
+ citationCommand += "s"; // Switching from \autocite to \autocites
468
+ }
469
+ const allCitationItemsPresent = references.every(ref => {
470
+ const bibDBEntry = this.bibDB.db[ref.id];
471
+ if (!bibDBEntry) {
472
+ // Not present in bibliography database, skip it.
473
+ // TODO: Throw an error?
474
+ return false;
475
+ }
476
+ if (ref.prefix) {
477
+ citationCommand += `[${ref.prefix}]`;
478
+ if (!ref.locator) {
479
+ citationCommand += "[]";
480
+ }
481
+ }
482
+ if (ref.locator) {
483
+ citationCommand += `[${ref.locator}]`;
484
+ }
485
+ citationCommand += "{";
486
+ if (!this.usedBibDB[ref.id]) {
487
+ const citationKey = this.createUniqueCitationKey(bibDBEntry.entry_key);
488
+ this.usedBibDB[ref.id] = Object.assign({}, bibDBEntry);
489
+ this.usedBibDB[ref.id].entry_key = citationKey;
490
+ }
491
+ citationCommand += this.usedBibDB[ref.id].entry_key;
492
+ citationCommand += "}";
493
+ return true;
494
+ });
495
+ if (!allCitationItemsPresent) {
496
+ citationCommand = false;
497
+ }
498
+ }
499
+ if (citationCommand) {
500
+ content += citationCommand;
501
+ this.features.citations = true;
502
+ }
503
+ break;
504
+ }
505
+ case "figure": {
506
+ const category = node.attrs.category;
507
+ const captionContent = node.attrs.caption
508
+ ? node.content.find(node => node.type === "figure_caption")
509
+ ?.content || []
510
+ : [];
511
+ let caption;
512
+ if (category !== "none") {
513
+ if (!this.categoryCounter[category]) {
514
+ this.categoryCounter[category] = 1;
515
+ }
516
+ const catCount = this.categoryCounter[category]++;
517
+ const catLabel = `${CATS[category][this.settings.language]} ${catCount}`;
518
+ if (captionContent.length) {
519
+ caption = `${catLabel}: ${captionContent.map(node => this.walkJson(node)).join("")}`;
520
+ }
521
+ else {
522
+ caption = catLabel;
523
+ }
524
+ }
525
+ else {
526
+ caption = captionContent
527
+ .map(node => this.walkJson(node))
528
+ .join("");
529
+ }
530
+ let innerFigure = "";
531
+ let copyright;
532
+ const image = node.content.find(node => node.type === "image")?.attrs
533
+ .image || false;
534
+ if (image) {
535
+ this.imageIds.push(image);
536
+ const imageDBEntry = this.imageDB.db[image], filePathName = imageDBEntry.image, filename = filePathName.split("/").pop();
537
+ copyright = imageDBEntry.copyright;
538
+ if (filename.split(".").pop() === "svg") {
539
+ innerFigure += `\\includesvg[width=${Number.parseInt(node.attrs.width) / 100}\\textwidth]{${filename}}\n`;
540
+ this.features.SVGs = true;
541
+ }
542
+ else {
543
+ innerFigure += `\\scaledgraphics{${filename}}{${Number.parseInt(node.attrs.width) / 100}}\n`;
544
+ this.features.images = true;
545
+ }
546
+ }
547
+ else {
548
+ const equation = node.content.find(node => node.type === "figure_equation")?.attrs.equation || "";
549
+ innerFigure += `\\begin{displaymath}\n${equation}\n\\end{displaymath}\n`;
550
+ }
551
+ if (category === "table") {
552
+ const aligned = node.attrs.width === "100" ? "left" : node.attrs.aligned;
553
+ if (aligned === "center") {
554
+ start += "\n\n\\begin{center}";
555
+ end = "\n\n\\end{center}\n" + end;
556
+ }
557
+ else if (aligned === "right") {
558
+ start += "\n\n{\\raggedleft"; // This is not a typo - raggedleft = aligned: right
559
+ end = "\n\n}\n" + end;
560
+ } // aligned === 'left' is default
561
+ start += "\n\\begin{table}\n";
562
+ content += caption.length ? `\\caption*{${caption}}` : "";
563
+ content += `\\label{${node.attrs.id}}\n${innerFigure}`;
564
+ end = "\\end{table}\n" + end;
565
+ }
566
+ else {
567
+ // TODO: handle photo figure types in a special way
568
+ if (node.attrs.width === "100" ||
569
+ node.attrs.aligned === "center") {
570
+ start += "\n\\begin{figure}\n";
571
+ end = "\\end{figure}\n" + end;
572
+ }
573
+ else {
574
+ const aligned = node.attrs.aligned[0];
575
+ start += `\n\\begin{wrapfigure}{${aligned}}{${Number.parseInt(node.attrs.width) / 100}\\textwidth}\n`;
576
+ end = "\\end{wrapfigure}\n" + end;
577
+ this.features.wrapfig = true;
578
+ }
579
+ content += `${innerFigure}${caption.length ? `\\caption*{${caption}}` : ""}\\label{${node.attrs.id}}\n`;
580
+ }
581
+ if (copyright?.holder) {
582
+ content += `% © ${copyright.year ? copyright.year : new Date().getFullYear()} ${copyright.holder}\n`;
583
+ }
584
+ if (copyright?.licenses.length) {
585
+ copyright.licenses.forEach(license => {
586
+ content += `% ${license.title}: ${license.url}${license.start ? ` (${license.start})\n` : ""}\n`;
587
+ });
588
+ }
589
+ if (this.internalLinks.includes(node.attrs.id)) {
590
+ // Add a link target
591
+ end =
592
+ `\\texorpdfstring{\\protect\\hypertarget{${node.attrs.id}}{}}{}\n` +
593
+ end;
594
+ }
595
+ this.features.captions = true;
596
+ break;
597
+ }
598
+ case "figure_caption":
599
+ // We are already dealing with this in the figure. Prevent content from being added a second time.
600
+ return "";
601
+ case "figure_equation":
602
+ // We are already dealing with this in the figure.
603
+ break;
604
+ case "image":
605
+ // We are already dealing with this in the figure.
606
+ break;
607
+ case "table":
608
+ if (node.content?.length) {
609
+ const category = node.attrs.category;
610
+ const captionContent = node.attrs.caption
611
+ ? node.content[0].content || []
612
+ : [];
613
+ let caption;
614
+ if (category !== "none") {
615
+ if (!this.categoryCounter[category]) {
616
+ this.categoryCounter[category] = 1;
617
+ }
618
+ const catCount = this.categoryCounter[category]++;
619
+ const catLabel = `${CATS[category][this.settings.language]} ${catCount}`;
620
+ if (captionContent.length) {
621
+ caption = `${catLabel}: ${captionContent.map(node => this.walkJson(node)).join("")}`;
622
+ }
623
+ else {
624
+ caption = catLabel;
625
+ }
626
+ }
627
+ else {
628
+ caption = captionContent
629
+ .map(node => this.walkJson(node))
630
+ .join("");
631
+ }
632
+ let columns = 1;
633
+ if (node.content.length > 1 &&
634
+ node.content[1].content?.length) {
635
+ columns = node.content[1].content[0].content.reduce((columns, node) => columns + node.attrs.colspan, 0);
636
+ }
637
+ const aligned = node.attrs.width === "100" ? "left" : node.attrs.aligned;
638
+ if (aligned === "center") {
639
+ start += "\n\n\\begin{center}";
640
+ end = "\n\n\\end{center}\n" + end;
641
+ }
642
+ else if (aligned === "right") {
643
+ start += "\n\n{\\raggedleft"; // This is not a typo - raggedleft = aligned: right
644
+ end = "\n\n}\n";
645
+ } // aligned === 'left' is default
646
+ if (caption.length) {
647
+ start += "\n\\begin{table}\n";
648
+ start += `\\caption*{${caption}}\\label{${node.attrs.id}}`;
649
+ end = "\\end{table}\n" + end;
650
+ this.features.captions = true;
651
+ }
652
+ start += `\n\n\\begin{tabu} to ${node.attrs.width === "100"
653
+ ? ""
654
+ : Number.parseInt(node.attrs.width) / 100}\\textwidth { |${"X|".repeat(columns)} }\n\\hline\n\n`;
655
+ end = "\\hline\n\n\\end{tabu}" + end;
656
+ this.features.tables = true;
657
+ }
658
+ break;
659
+ case "table_body":
660
+ // Pass through to table.
661
+ break;
662
+ case "table_caption":
663
+ // We already deal with this in 'table'.
664
+ return "";
665
+ case "table_row":
666
+ end += " \\\\\n";
667
+ break;
668
+ case "table_cell":
669
+ case "table_header":
670
+ if (node.attrs.colspan > 1) {
671
+ start += `\\multicolumn{${node.attrs.colspan}}{c}{`;
672
+ end += "}";
673
+ }
674
+ // TODO: these multirow outputs don't work very well with longer text.
675
+ // If there is another alternative, please change!
676
+ if (node.attrs.rowspan > 1) {
677
+ start += `\\multirow{${node.attrs.rowspan}}{*}{`;
678
+ end += "}";
679
+ this.features.rowspan = true;
680
+ }
681
+ end += " & ";
682
+ break;
683
+ case "equation":
684
+ content += `$${node.attrs.equation}$`;
685
+ break;
686
+ case "hard_break":
687
+ if (!options.noLineBreak) {
688
+ content += "\n\n";
689
+ }
690
+ break;
691
+ default:
692
+ break;
693
+ }
694
+ if (node.content) {
695
+ node.content.forEach(child => {
696
+ content += this.walkJson(child, options);
697
+ });
698
+ }
699
+ if (placeFootnotesAfterBlock && options.unplacedFootnotes?.length) {
700
+ // There are footnotes that needed to be placed behind the node.
701
+ // This happens in the case of headlines and lists.
702
+ end += `\\addtocounter{footnote}{-${options.unplacedFootnotes.length}}`;
703
+ options.unplacedFootnotes.forEach(footnote => {
704
+ end += "\\stepcounter{footnote}\n";
705
+ end += "\\footnotetext{";
706
+ let fnContent = "";
707
+ footnote.forEach(footPar => {
708
+ fnContent += this.walkJson(footPar, options);
709
+ });
710
+ end += fnContent.replace(/^\s+|\s+$/g, "");
711
+ end += "}";
712
+ });
713
+ options.unplacedFootnotes = [];
714
+ }
715
+ if (["table_cell", "table_header"].includes(node.type) &&
716
+ node.attrs.rowspan > 1) {
717
+ // \multirow doesn't allow multiple paragraphs.
718
+ content = content.trim().replace(/\n\n/g, " \\\\ ");
719
+ }
720
+ return start + content + end;
721
+ }
722
+ // The database doesn't ensure that citation keys are unique.
723
+ // So here we need to make sure that the same key is not used twice in one
724
+ // document.
725
+ createUniqueCitationKey(suggestedKey) {
726
+ const usedKeys = Object.keys(this.usedBibDB).map(key => {
727
+ return this.usedBibDB[key].entry_key;
728
+ });
729
+ if (usedKeys.includes(suggestedKey)) {
730
+ suggestedKey += "X";
731
+ return this.createUniqueCitationKey(suggestedKey);
732
+ }
733
+ else {
734
+ return suggestedKey;
735
+ }
736
+ }
737
+ postProcess(latex) {
738
+ return (latex
739
+ // join blocks of the same type that follow oneanother.
740
+ .replace(/\\end{code}\n\n\\begin{code}\n\n/g, "")
741
+ .replace(/\\end{quote}\n\n\\begin{quote}\n\n/g, "")
742
+ // Remove the last divider in any any table row.
743
+ .replace(/& {2}\\\\/g, "\\\\")
744
+ // Remove new lines between table cells.
745
+ .replace(/\n & \n\n/g, " & ")
746
+ // Remove new lines within itemization
747
+ .replace(/\\item \n\n/g, "\\item "));
748
+ }
749
+ assembleEpilogue() {
750
+ let epilogue = "";
751
+ if (this.features.citations) {
752
+ const bibliographyHeader = this.settings.bibliography_header[this.settings.language] ||
753
+ BIBLIOGRAPHY_HEADERS[this.settings.language];
754
+ epilogue += `\n\n\\printbibliography[title={${escapeLatexText(bibliographyHeader)}}]`;
755
+ }
756
+ return epilogue;
757
+ }
758
+ assembleCopyright() {
759
+ let note = "";
760
+ if (this.settings.copyright) {
761
+ if (this.settings.copyright.holder) {
762
+ note += `% © ${this.settings.copyright.year ? this.settings.copyright.year : new Date().getFullYear()} ${this.settings.copyright.holder}\n`;
763
+ }
764
+ if (this.settings.copyright.licenses.length) {
765
+ this.settings.copyright.licenses.forEach(license => {
766
+ note += `% ${license.url}${license.start ? ` (${license.start})` : ""}\n`;
767
+ });
768
+ }
769
+ }
770
+ if (note.length) {
771
+ note += "\n\n";
772
+ }
773
+ return note;
774
+ }
775
+ assemblePreamble() {
776
+ let preamble = "";
777
+ if (this.features.subtitle) {
778
+ preamble += `
779
+ \n\\usepackage{titling}
780
+ \n\\newcommand{\\subtitle}[1]{%
781
+ \n\t\\posttitle{%
782
+ \n\t\t\\par\\end{center}
783
+ \n\t\t\\begin{center}\\large#1\\end{center}
784
+ \n\t\t\\vskip 0.5em}%
785
+ }
786
+ `;
787
+ }
788
+ if (this.features.authors) {
789
+ preamble += `
790
+ \n\\usepackage{authblk}
791
+ \n\\makeatletter
792
+ \n\\let\\@fnsymbol\\@alph
793
+ \n\\makeatother
794
+ `;
795
+ }
796
+ if (this.features.keywords) {
797
+ preamble += `
798
+ \n\\def\\keywords{\\vspace{.5em}
799
+ \n{\\textit{Keywords}:\\,\\relax%
800
+ \n}}
801
+ \n\\def\\endkeywords{\\par}
802
+ \n\\newcommand{\\sep}{, }
803
+ `;
804
+ }
805
+ if (this.features.hyperlinks) {
806
+ preamble += "\n\\usepackage{hyperref}";
807
+ }
808
+ if (this.features.captions) {
809
+ preamble += "\n\\usepackage{caption}";
810
+ }
811
+ if (this.features.wrapfig) {
812
+ preamble += "\n\\usepackage{wrapfig}";
813
+ }
814
+ if (this.features.citations) {
815
+ preamble += `
816
+ \n\\usepackage[backend=biber,hyperref=false,citestyle=authoryear,bibstyle=authoryear]{biblatex}
817
+ \n\\bibliography{bibliography}
818
+ `;
819
+ }
820
+ if (this.features.SVGs) {
821
+ preamble += "\n\\usepackage{svg}";
822
+ }
823
+ if (this.features.images) {
824
+ preamble += "\n\\usepackage{graphicx}";
825
+ // The following scales graphics down to text width, but not scaling them up if they are smaller
826
+ preamble += `
827
+ \n\\usepackage{calc}
828
+ \n\\newlength{\\imgwidth}
829
+ \n\\newcommand\\scaledgraphics[2]{%
830
+ \n\\settowidth{\\imgwidth}{\\includegraphics{#1}}%
831
+ \n\\setlength{\\imgwidth}{\\minof{\\imgwidth}{#2\\textwidth}}%
832
+ \n\\includegraphics[width=\\imgwidth,height=\\textheight,keepaspectratio]{#1}%
833
+ \n}
834
+ `;
835
+ }
836
+ if (this.features.tables) {
837
+ preamble += "\n\\usepackage{tabu}";
838
+ }
839
+ if (this.features.orderedListStart) {
840
+ preamble += "\n\\usepackage{enumitem}";
841
+ }
842
+ if (this.features.rowspan) {
843
+ preamble += "\n\\usepackage{multirow}";
844
+ }
845
+ if (this.features.code) {
846
+ // See https://tex.stackexchange.com/questions/445424/making-a-multiline-code-environment
847
+ preamble += `
848
+ \n\\usepackage{xcolor}
849
+ \\definecolor{mygray}{gray}{0.9}
850
+ \\usepackage{fvextra}
851
+ \\usepackage{tcolorbox}
852
+ \\newenvironment{code}%
853
+ {\\VerbatimEnvironment
854
+ \\begin{tcolorbox}[colback=mygray, boxsep=0pt, arc=0pt, boxrule=0pt]
855
+ \\begin{Verbatim}[fontsize=\\scriptsize, commandchars=\\\\\\{\\},
856
+ breaklines, breakafter=*, breaksymbolsep=0.5em,
857
+ breakaftersymbolpre={\\,\\tiny\\ensuremath{\\rfloor}}]}%
858
+ {\\end{Verbatim}%
859
+ \\end{tcolorbox}}
860
+ `;
861
+ }
862
+ return preamble;
863
+ }
864
+ }
865
+ //# sourceMappingURL=convert.js.map