@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.
- package/README.md +22 -1
- package/dist/bibliography/common.d.ts +92 -0
- package/dist/bibliography/common.d.ts.map +1 -0
- package/dist/bibliography/common.js +85 -0
- package/dist/bibliography/common.js.map +1 -0
- package/dist/bibliography/csl_bib.d.ts +3 -0
- package/dist/bibliography/csl_bib.d.ts.map +1 -0
- package/dist/bibliography/csl_bib.js +131 -0
- package/dist/bibliography/csl_bib.js.map +1 -0
- package/dist/citations/citeproc_sys.d.ts +13 -0
- package/dist/citations/citeproc_sys.d.ts.map +1 -0
- package/dist/citations/citeproc_sys.js +43 -0
- package/dist/citations/citeproc_sys.js.map +1 -0
- package/dist/citations/format.d.ts +23 -0
- package/dist/citations/format.d.ts.map +1 -0
- package/dist/citations/format.js +161 -0
- package/dist/citations/format.js.map +1 -0
- package/dist/editor/e2ee/encryptor.d.ts +123 -0
- package/dist/editor/e2ee/encryptor.d.ts.map +1 -0
- package/dist/editor/e2ee/encryptor.js +201 -0
- package/dist/editor/e2ee/encryptor.js.map +1 -0
- package/dist/exporter/docx/citations.d.ts +21 -0
- package/dist/exporter/docx/citations.d.ts.map +1 -0
- package/dist/exporter/docx/citations.js +154 -0
- package/dist/exporter/docx/citations.js.map +1 -0
- package/dist/exporter/docx/comments.d.ts +18 -0
- package/dist/exporter/docx/comments.d.ts.map +1 -0
- package/dist/exporter/docx/comments.js +137 -0
- package/dist/exporter/docx/comments.js.map +1 -0
- package/dist/exporter/docx/footnotes.d.ts +42 -0
- package/dist/exporter/docx/footnotes.d.ts.map +1 -0
- package/dist/exporter/docx/footnotes.js +182 -0
- package/dist/exporter/docx/footnotes.js.map +1 -0
- package/dist/exporter/docx/images.d.ts +14 -0
- package/dist/exporter/docx/images.d.ts.map +1 -0
- package/dist/exporter/docx/images.js +86 -0
- package/dist/exporter/docx/images.js.map +1 -0
- package/dist/exporter/docx/index.d.ts +22 -0
- package/dist/exporter/docx/index.d.ts.map +1 -0
- package/dist/exporter/docx/index.js +107 -0
- package/dist/exporter/docx/index.js.map +1 -0
- package/dist/exporter/docx/lists.d.ts +33 -0
- package/dist/exporter/docx/lists.d.ts.map +1 -0
- package/dist/exporter/docx/lists.js +229 -0
- package/dist/exporter/docx/lists.js.map +1 -0
- package/dist/exporter/docx/math.d.ts +13 -0
- package/dist/exporter/docx/math.d.ts.map +1 -0
- package/dist/exporter/docx/math.js +42 -0
- package/dist/exporter/docx/math.js.map +1 -0
- package/dist/exporter/docx/metadata.d.ts +14 -0
- package/dist/exporter/docx/metadata.d.ts.map +1 -0
- package/dist/exporter/docx/metadata.js +239 -0
- package/dist/exporter/docx/metadata.js.map +1 -0
- package/dist/exporter/docx/rels.d.ts +25 -0
- package/dist/exporter/docx/rels.d.ts.map +1 -0
- package/dist/exporter/docx/rels.js +168 -0
- package/dist/exporter/docx/rels.js.map +1 -0
- package/dist/exporter/docx/render.d.ts +20 -0
- package/dist/exporter/docx/render.d.ts.map +1 -0
- package/dist/exporter/docx/render.js +774 -0
- package/dist/exporter/docx/render.js.map +1 -0
- package/dist/exporter/docx/richtext.d.ts +25 -0
- package/dist/exporter/docx/richtext.d.ts.map +1 -0
- package/dist/exporter/docx/richtext.js +1052 -0
- package/dist/exporter/docx/richtext.js.map +1 -0
- package/dist/exporter/docx/tables.d.ts +14 -0
- package/dist/exporter/docx/tables.d.ts.map +1 -0
- package/dist/exporter/docx/tables.js +109 -0
- package/dist/exporter/docx/tables.js.map +1 -0
- package/dist/exporter/docx/tools.d.ts +3 -0
- package/dist/exporter/docx/tools.d.ts.map +1 -0
- package/dist/exporter/docx/tools.js +48 -0
- package/dist/exporter/docx/tools.js.map +1 -0
- package/dist/exporter/epub/index.d.ts +11 -0
- package/dist/exporter/epub/index.d.ts.map +1 -0
- package/dist/exporter/epub/index.js +102 -0
- package/dist/exporter/epub/index.js.map +1 -0
- package/dist/exporter/epub/templates.d.ts +32 -0
- package/dist/exporter/epub/templates.d.ts.map +1 -0
- package/dist/exporter/epub/templates.js +95 -0
- package/dist/exporter/epub/templates.js.map +1 -0
- package/dist/exporter/epub/tools.d.ts +5 -0
- package/dist/exporter/epub/tools.d.ts.map +1 -0
- package/dist/exporter/epub/tools.js +81 -0
- package/dist/exporter/epub/tools.js.map +1 -0
- package/dist/exporter/html/citations.d.ts +27 -0
- package/dist/exporter/html/citations.d.ts.map +1 -0
- package/dist/exporter/html/citations.js +91 -0
- package/dist/exporter/html/citations.js.map +1 -0
- package/dist/exporter/html/convert.d.ts +100 -0
- package/dist/exporter/html/convert.d.ts.map +1 -0
- package/dist/exporter/html/convert.js +718 -0
- package/dist/exporter/html/convert.js.map +1 -0
- package/dist/exporter/html/index.d.ts +61 -0
- package/dist/exporter/html/index.d.ts.map +1 -0
- package/dist/exporter/html/index.js +134 -0
- package/dist/exporter/html/index.js.map +1 -0
- package/dist/exporter/html/templates.d.ts +10 -0
- package/dist/exporter/html/templates.d.ts.map +1 -0
- package/dist/exporter/html/templates.js +21 -0
- package/dist/exporter/html/templates.js.map +1 -0
- package/dist/exporter/html/tools.d.ts +2 -0
- package/dist/exporter/html/tools.d.ts.map +1 -0
- package/dist/exporter/html/tools.js +49 -0
- package/dist/exporter/html/tools.js.map +1 -0
- package/dist/exporter/jats/bibliography.d.ts +2 -0
- package/dist/exporter/jats/bibliography.d.ts.map +1 -0
- package/dist/exporter/jats/bibliography.js +153 -0
- package/dist/exporter/jats/bibliography.js.map +1 -0
- package/dist/exporter/jats/citations.d.ts +14 -0
- package/dist/exporter/jats/citations.d.ts.map +1 -0
- package/dist/exporter/jats/citations.js +83 -0
- package/dist/exporter/jats/citations.js.map +1 -0
- package/dist/exporter/jats/convert.d.ts +45 -0
- package/dist/exporter/jats/convert.d.ts.map +1 -0
- package/dist/exporter/jats/convert.js +799 -0
- package/dist/exporter/jats/convert.js.map +1 -0
- package/dist/exporter/jats/index.d.ts +19 -0
- package/dist/exporter/jats/index.d.ts.map +1 -0
- package/dist/exporter/jats/index.js +66 -0
- package/dist/exporter/jats/index.js.map +1 -0
- package/dist/exporter/jats/templates.d.ts +16 -0
- package/dist/exporter/jats/templates.d.ts.map +1 -0
- package/dist/exporter/jats/templates.js +25 -0
- package/dist/exporter/jats/templates.js.map +1 -0
- package/dist/exporter/jats/text.d.ts +3 -0
- package/dist/exporter/jats/text.d.ts.map +1 -0
- package/dist/exporter/jats/text.js +72 -0
- package/dist/exporter/jats/text.js.map +1 -0
- package/dist/exporter/latex/convert.d.ts +27 -0
- package/dist/exporter/latex/convert.d.ts.map +1 -0
- package/dist/exporter/latex/convert.js +865 -0
- package/dist/exporter/latex/convert.js.map +1 -0
- package/dist/exporter/latex/escape_latex.d.ts +2 -0
- package/dist/exporter/latex/escape_latex.d.ts.map +1 -0
- package/dist/exporter/latex/escape_latex.js +20 -0
- package/dist/exporter/latex/escape_latex.js.map +1 -0
- package/dist/exporter/latex/index.d.ts +23 -0
- package/dist/exporter/latex/index.d.ts.map +1 -0
- package/dist/exporter/latex/index.js +57 -0
- package/dist/exporter/latex/index.js.map +1 -0
- package/dist/exporter/latex/readme.d.ts +2 -0
- package/dist/exporter/latex/readme.d.ts.map +1 -0
- package/dist/exporter/latex/readme.js +23 -0
- package/dist/exporter/latex/readme.js.map +1 -0
- package/dist/exporter/native/shrink.d.ts +21 -0
- package/dist/exporter/native/shrink.d.ts.map +1 -0
- package/dist/exporter/native/shrink.js +115 -0
- package/dist/exporter/native/shrink.js.map +1 -0
- package/dist/exporter/odt/citations.d.ts +18 -0
- package/dist/exporter/odt/citations.d.ts.map +1 -0
- package/dist/exporter/odt/citations.js +87 -0
- package/dist/exporter/odt/citations.js.map +1 -0
- package/dist/exporter/odt/footnotes.d.ts +25 -0
- package/dist/exporter/odt/footnotes.d.ts.map +1 -0
- package/dist/exporter/odt/footnotes.js +112 -0
- package/dist/exporter/odt/footnotes.js.map +1 -0
- package/dist/exporter/odt/images.d.ts +13 -0
- package/dist/exporter/odt/images.d.ts.map +1 -0
- package/dist/exporter/odt/images.js +98 -0
- package/dist/exporter/odt/images.js.map +1 -0
- package/dist/exporter/odt/index.d.ts +23 -0
- package/dist/exporter/odt/index.d.ts.map +1 -0
- package/dist/exporter/odt/index.js +99 -0
- package/dist/exporter/odt/index.js.map +1 -0
- package/dist/exporter/odt/math.d.ts +13 -0
- package/dist/exporter/odt/math.d.ts.map +1 -0
- package/dist/exporter/odt/math.js +48 -0
- package/dist/exporter/odt/math.js.map +1 -0
- package/dist/exporter/odt/metadata.d.ts +14 -0
- package/dist/exporter/odt/metadata.d.ts.map +1 -0
- package/dist/exporter/odt/metadata.js +203 -0
- package/dist/exporter/odt/metadata.js.map +1 -0
- package/dist/exporter/odt/render.d.ts +24 -0
- package/dist/exporter/odt/render.d.ts.map +1 -0
- package/dist/exporter/odt/render.js +644 -0
- package/dist/exporter/odt/render.js.map +1 -0
- package/dist/exporter/odt/richtext.d.ts +22 -0
- package/dist/exporter/odt/richtext.d.ts.map +1 -0
- package/dist/exporter/odt/richtext.js +728 -0
- package/dist/exporter/odt/richtext.js.map +1 -0
- package/dist/exporter/odt/styles.d.ts +33 -0
- package/dist/exporter/odt/styles.d.ts.map +1 -0
- package/dist/exporter/odt/styles.js +348 -0
- package/dist/exporter/odt/styles.js.map +1 -0
- package/dist/exporter/odt/track.d.ts +11 -0
- package/dist/exporter/odt/track.d.ts.map +1 -0
- package/dist/exporter/odt/track.js +59 -0
- package/dist/exporter/odt/track.js.map +1 -0
- package/dist/exporter/pandoc/citations.d.ts +17 -0
- package/dist/exporter/pandoc/citations.d.ts.map +1 -0
- package/dist/exporter/pandoc/citations.js +85 -0
- package/dist/exporter/pandoc/citations.js.map +1 -0
- package/dist/exporter/pandoc/convert.d.ts +38 -0
- package/dist/exporter/pandoc/convert.d.ts.map +1 -0
- package/dist/exporter/pandoc/convert.js +881 -0
- package/dist/exporter/pandoc/convert.js.map +1 -0
- package/dist/exporter/pandoc/index.d.ts +38 -0
- package/dist/exporter/pandoc/index.d.ts.map +1 -0
- package/dist/exporter/pandoc/index.js +67 -0
- package/dist/exporter/pandoc/index.js.map +1 -0
- package/dist/exporter/pandoc/readme.d.ts +2 -0
- package/dist/exporter/pandoc/readme.d.ts.map +1 -0
- package/dist/exporter/pandoc/readme.js +9 -0
- package/dist/exporter/pandoc/readme.js.map +1 -0
- package/dist/exporter/pandoc/tools.d.ts +6 -0
- package/dist/exporter/pandoc/tools.d.ts.map +1 -0
- package/dist/exporter/pandoc/tools.js +52 -0
- package/dist/exporter/pandoc/tools.js.map +1 -0
- package/dist/exporter/print/index.d.ts +9 -0
- package/dist/exporter/print/index.d.ts.map +1 -0
- package/dist/exporter/print/index.js +140 -0
- package/dist/exporter/print/index.js.map +1 -0
- package/dist/exporter/tools/doc_content.d.ts +7 -0
- package/dist/exporter/tools/doc_content.d.ts.map +1 -0
- package/dist/exporter/tools/doc_content.js +129 -0
- package/dist/exporter/tools/doc_content.js.map +1 -0
- package/dist/exporter/tools/file.d.ts +2 -0
- package/dist/exporter/tools/file.d.ts.map +1 -0
- package/dist/exporter/tools/file.js +10 -0
- package/dist/exporter/tools/file.js.map +1 -0
- package/dist/exporter/tools/json.d.ts +7 -0
- package/dist/exporter/tools/json.d.ts.map +1 -0
- package/dist/exporter/tools/json.js +82 -0
- package/dist/exporter/tools/json.js.map +1 -0
- package/dist/exporter/tools/svg.d.ts +2 -0
- package/dist/exporter/tools/svg.d.ts.map +1 -0
- package/dist/exporter/tools/svg.js +26 -0
- package/dist/exporter/tools/svg.js.map +1 -0
- package/dist/exporter/tools/xml.d.ts +41 -0
- package/dist/exporter/tools/xml.d.ts.map +1 -0
- package/dist/exporter/tools/xml.js +440 -0
- package/dist/exporter/tools/xml.js.map +1 -0
- package/dist/exporter/tools/xml_zip.d.ts +20 -0
- package/dist/exporter/tools/xml_zip.d.ts.map +1 -0
- package/dist/exporter/tools/xml_zip.js +86 -0
- package/dist/exporter/tools/xml_zip.js.map +1 -0
- package/dist/exporter/tools/zip.d.ts +21 -0
- package/dist/exporter/tools/zip.d.ts.map +1 -0
- package/dist/exporter/tools/zip.js +71 -0
- package/dist/exporter/tools/zip.js.map +1 -0
- package/dist/exporter/tools/zotero_csl.d.ts +10 -0
- package/dist/exporter/tools/zotero_csl.d.ts.map +1 -0
- package/dist/exporter/tools/zotero_csl.js +78 -0
- package/dist/exporter/tools/zotero_csl.js.map +1 -0
- package/dist/importer/citations.d.ts +25 -0
- package/dist/importer/citations.d.ts.map +1 -0
- package/dist/importer/citations.js +116 -0
- package/dist/importer/citations.js.map +1 -0
- package/dist/importer/docx/citations.d.ts +65 -0
- package/dist/importer/docx/citations.d.ts.map +1 -0
- package/dist/importer/docx/citations.js +106 -0
- package/dist/importer/docx/citations.js.map +1 -0
- package/dist/importer/docx/convert.d.ts +228 -0
- package/dist/importer/docx/convert.d.ts.map +1 -0
- package/dist/importer/docx/convert.js +1226 -0
- package/dist/importer/docx/convert.js.map +1 -0
- package/dist/importer/docx/helpers.d.ts +2 -0
- package/dist/importer/docx/helpers.d.ts.map +1 -0
- package/dist/importer/docx/helpers.js +10 -0
- package/dist/importer/docx/helpers.js.map +1 -0
- package/dist/importer/docx/omml2mathml.d.ts +7 -0
- package/dist/importer/docx/omml2mathml.d.ts.map +1 -0
- package/dist/importer/docx/omml2mathml.js +1239 -0
- package/dist/importer/docx/omml2mathml.js.map +1 -0
- package/dist/importer/docx/parse.d.ts +205 -0
- package/dist/importer/docx/parse.d.ts.map +1 -0
- package/dist/importer/docx/parse.js +663 -0
- package/dist/importer/docx/parse.js.map +1 -0
- package/dist/importer/native/get_images.d.ts +11 -0
- package/dist/importer/native/get_images.d.ts.map +1 -0
- package/dist/importer/native/get_images.js +64 -0
- package/dist/importer/native/get_images.js.map +1 -0
- package/dist/importer/native/update.d.ts +6 -0
- package/dist/importer/native/update.d.ts.map +1 -0
- package/dist/importer/native/update.js +26 -0
- package/dist/importer/native/update.js.map +1 -0
- package/dist/importer/odt/citations.d.ts +47 -0
- package/dist/importer/odt/citations.d.ts.map +1 -0
- package/dist/importer/odt/citations.js +79 -0
- package/dist/importer/odt/citations.js.map +1 -0
- package/dist/importer/odt/convert.d.ts +330 -0
- package/dist/importer/odt/convert.d.ts.map +1 -0
- package/dist/importer/odt/convert.js +1506 -0
- package/dist/importer/odt/convert.js.map +1 -0
- package/dist/importer/pandoc/convert.d.ts +84 -0
- package/dist/importer/pandoc/convert.d.ts.map +1 -0
- package/dist/importer/pandoc/convert.js +777 -0
- package/dist/importer/pandoc/convert.js.map +1 -0
- package/dist/importer/pandoc/helpers.d.ts +4 -0
- package/dist/importer/pandoc/helpers.d.ts.map +1 -0
- package/dist/importer/pandoc/helpers.js +75 -0
- package/dist/importer/pandoc/helpers.js.map +1 -0
- package/dist/importer/zip_analyzer.d.ts +25 -0
- package/dist/importer/zip_analyzer.d.ts.map +1 -0
- package/dist/importer/zip_analyzer.js +84 -0
- package/dist/importer/zip_analyzer.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/mathlive/opf_includes.d.ts +2 -0
- package/dist/mathlive/opf_includes.d.ts.map +1 -0
- package/dist/mathlive/opf_includes.js +25 -0
- package/dist/mathlive/opf_includes.js.map +1 -0
- package/dist/schema/common/annotate.d.ts +59 -0
- package/dist/schema/common/annotate.d.ts.map +1 -0
- package/dist/schema/common/annotate.js +75 -0
- package/dist/schema/common/annotate.js.map +1 -0
- package/dist/schema/common/base.d.ts +109 -0
- package/dist/schema/common/base.d.ts.map +1 -0
- package/dist/schema/common/base.js +109 -0
- package/dist/schema/common/base.js.map +1 -0
- package/dist/schema/common/citation.d.ts +29 -0
- package/dist/schema/common/citation.d.ts.map +1 -0
- package/dist/schema/common/citation.js +62 -0
- package/dist/schema/common/citation.js.map +1 -0
- package/dist/schema/common/equation.d.ts +18 -0
- package/dist/schema/common/equation.d.ts.map +1 -0
- package/dist/schema/common/equation.js +32 -0
- package/dist/schema/common/equation.js.map +1 -0
- package/dist/schema/common/figure.d.ts +108 -0
- package/dist/schema/common/figure.d.ts.map +1 -0
- package/dist/schema/common/figure.js +176 -0
- package/dist/schema/common/figure.js.map +1 -0
- package/dist/schema/common/heading.d.ts +33 -0
- package/dist/schema/common/heading.d.ts.map +1 -0
- package/dist/schema/common/heading.js +41 -0
- package/dist/schema/common/heading.js.map +1 -0
- package/dist/schema/common/index.d.ts +11 -0
- package/dist/schema/common/index.d.ts.map +1 -0
- package/dist/schema/common/index.js +11 -0
- package/dist/schema/common/index.js.map +1 -0
- package/dist/schema/common/list.d.ts +83 -0
- package/dist/schema/common/list.d.ts.map +1 -0
- package/dist/schema/common/list.js +92 -0
- package/dist/schema/common/list.js.map +1 -0
- package/dist/schema/common/reference.d.ts +78 -0
- package/dist/schema/common/reference.d.ts.map +1 -0
- package/dist/schema/common/reference.js +97 -0
- package/dist/schema/common/reference.js.map +1 -0
- package/dist/schema/common/table.d.ts +92 -0
- package/dist/schema/common/table.d.ts.map +1 -0
- package/dist/schema/common/table.js +85 -0
- package/dist/schema/common/table.js.map +1 -0
- package/dist/schema/common/track.d.ts +131 -0
- package/dist/schema/common/track.d.ts.map +1 -0
- package/dist/schema/common/track.js +184 -0
- package/dist/schema/common/track.js.map +1 -0
- package/dist/schema/const.d.ts +3 -0
- package/dist/schema/const.d.ts.map +1 -0
- package/{src → dist}/schema/const.js +3 -3
- package/dist/schema/const.js.map +1 -0
- package/dist/schema/convert.d.ts +3 -0
- package/dist/schema/convert.d.ts.map +1 -0
- package/dist/schema/convert.js +1215 -0
- package/dist/schema/convert.js.map +1 -0
- package/dist/schema/document/content.d.ts +137 -0
- package/dist/schema/document/content.d.ts.map +1 -0
- package/dist/schema/document/content.js +177 -0
- package/dist/schema/document/content.js.map +1 -0
- package/dist/schema/document/index.d.ts +879 -0
- package/dist/schema/document/index.d.ts.map +1 -0
- package/dist/schema/document/index.js +68 -0
- package/dist/schema/document/index.js.map +1 -0
- package/dist/schema/document/structure.d.ts +273 -0
- package/dist/schema/document/structure.d.ts.map +1 -0
- package/dist/schema/document/structure.js +445 -0
- package/dist/schema/document/structure.js.map +1 -0
- package/dist/schema/export.d.ts +880 -0
- package/dist/schema/export.d.ts.map +1 -0
- package/dist/schema/export.js +16 -0
- package/dist/schema/export.js.map +1 -0
- package/dist/schema/footnotes.d.ts +499 -0
- package/dist/schema/footnotes.d.ts.map +1 -0
- package/dist/schema/footnotes.js +88 -0
- package/dist/schema/footnotes.js.map +1 -0
- package/dist/schema/footnotes_convert.d.ts +5 -0
- package/dist/schema/footnotes_convert.d.ts.map +1 -0
- package/dist/schema/footnotes_convert.js +26 -0
- package/dist/schema/footnotes_convert.js.map +1 -0
- package/dist/schema/i18n.d.ts +586 -0
- package/dist/schema/i18n.d.ts.map +1 -0
- package/dist/schema/i18n.js +585 -0
- package/dist/schema/i18n.js.map +1 -0
- package/dist/schema/index.d.ts +6 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +6 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/mini_json.d.ts +5 -0
- package/dist/schema/mini_json.d.ts.map +1 -0
- package/dist/schema/mini_json.js +50 -0
- package/dist/schema/mini_json.js.map +1 -0
- package/dist/schema/text.d.ts +2 -0
- package/dist/schema/text.d.ts.map +1 -0
- package/dist/schema/text.js +23 -0
- package/dist/schema/text.js.map +1 -0
- package/dist/types.d.ts +122 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -16
- package/scripts/export-schema.js +1 -1
- package/src/exporter/tools/{file.js → file.ts} +1 -1
- package/src/exporter/tools/{json.js → json.ts} +30 -19
- package/src/global.d.ts +11 -0
- package/src/schema/const.ts +58 -0
- package/src/types.ts +136 -0
- package/jest.config.js +0 -24
- /package/src/{index.js → index.ts} +0 -0
|
@@ -0,0 +1,799 @@
|
|
|
1
|
+
import { convertLatexToMathMl } from "mathlive";
|
|
2
|
+
import { escapeText } from "fwtoolkit";
|
|
3
|
+
import { CATS } from "../../schema/i18n.js";
|
|
4
|
+
import { removeHidden } from "../tools/doc_content.js";
|
|
5
|
+
import { JATSExporterCitations } from "./citations.js";
|
|
6
|
+
import { convertText } from "./text.js";
|
|
7
|
+
export class JATSExporterConverter {
|
|
8
|
+
constructor(type, doc, csl, imageDB, bibDB) {
|
|
9
|
+
this.type = type;
|
|
10
|
+
this.doc = doc;
|
|
11
|
+
this.csl = csl;
|
|
12
|
+
this.imageDB = imageDB;
|
|
13
|
+
this.bibDB = bibDB;
|
|
14
|
+
this.imageIds = [];
|
|
15
|
+
this.categoryCounter = {}; // counters for each type of figure (figure/table/photo)
|
|
16
|
+
this.affiliations = {}; // affiliations of authors and editors
|
|
17
|
+
this.affCounter = 0;
|
|
18
|
+
this.parCounter = 0;
|
|
19
|
+
this.headingCounter = 0;
|
|
20
|
+
this.currentSectionLevel = 0;
|
|
21
|
+
this.listCounter = 0;
|
|
22
|
+
this.orderedListLengths = [];
|
|
23
|
+
this.footnotes = [];
|
|
24
|
+
this.fnCounter = 0;
|
|
25
|
+
this.frontMatter = {
|
|
26
|
+
title: {},
|
|
27
|
+
subtitle: {},
|
|
28
|
+
contributors: [],
|
|
29
|
+
abstract: {},
|
|
30
|
+
keywords: [],
|
|
31
|
+
tags: [],
|
|
32
|
+
copyright: {
|
|
33
|
+
licenses: []
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
this.citInfos = [];
|
|
37
|
+
this.citationCount = 0;
|
|
38
|
+
this.citations = new JATSExporterCitations(this.doc, this.bibDB, this.csl);
|
|
39
|
+
}
|
|
40
|
+
init() {
|
|
41
|
+
const docContent = removeHidden(this.doc.content);
|
|
42
|
+
this.preWalkJson(docContent);
|
|
43
|
+
this.findAllCitations(docContent);
|
|
44
|
+
return this.citations.init(this.citInfos).then(() => {
|
|
45
|
+
const front = this.type === "article"
|
|
46
|
+
? this.assembleArticleFront()
|
|
47
|
+
: this.assembleBookPartFront();
|
|
48
|
+
const body = this.assembleBody(docContent);
|
|
49
|
+
const back = this.assembleBack();
|
|
50
|
+
return {
|
|
51
|
+
front,
|
|
52
|
+
body,
|
|
53
|
+
back,
|
|
54
|
+
imageIds: this.imageIds
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// Remove items from the body that should be in the front.
|
|
59
|
+
preWalkJson(node, parentNode = false) {
|
|
60
|
+
switch (node.type) {
|
|
61
|
+
case "doc":
|
|
62
|
+
this.frontMatter.copyright = node.attrs.copyright;
|
|
63
|
+
break;
|
|
64
|
+
case "title":
|
|
65
|
+
this.frontMatter.title["default"] = node;
|
|
66
|
+
parentNode.content = parentNode.content.filter(child => child !== node);
|
|
67
|
+
break;
|
|
68
|
+
case "heading_part":
|
|
69
|
+
if (["title", "subtitle"].includes(node.attrs.metadata) &&
|
|
70
|
+
!this.frontMatter[node.attrs.metadata][node.attrs.language || "default"] &&
|
|
71
|
+
node.content &&
|
|
72
|
+
node.content.length) {
|
|
73
|
+
// We only take the first instance of title/subtitle per language
|
|
74
|
+
this.frontMatter[node.attrs.metadata][node.attrs.language || "default"] = {
|
|
75
|
+
type: node.attrs.language
|
|
76
|
+
? `trans_${node.attrs.metadata}`
|
|
77
|
+
: node.attrs.metadata,
|
|
78
|
+
attrs: {
|
|
79
|
+
id: node.content[0].attrs.id,
|
|
80
|
+
language: node.attrs.language
|
|
81
|
+
},
|
|
82
|
+
content: node.content[0].content
|
|
83
|
+
};
|
|
84
|
+
parentNode.content = parentNode.content.filter(child => child !== node);
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
case "richtext_part":
|
|
88
|
+
if (node.attrs.metadata === "abstract" &&
|
|
89
|
+
!this.frontMatter.abstract[node.attrs.language || "default"]) {
|
|
90
|
+
// We only take the first instance of abstract per language
|
|
91
|
+
this.frontMatter.abstract[node.attrs.language || "default"] = {
|
|
92
|
+
type: node.attrs.language
|
|
93
|
+
? "trans_abstract"
|
|
94
|
+
: "abstract",
|
|
95
|
+
attrs: {
|
|
96
|
+
id: node.attrs.id,
|
|
97
|
+
language: node.attrs.language
|
|
98
|
+
},
|
|
99
|
+
content: node.content
|
|
100
|
+
};
|
|
101
|
+
parentNode.content = parentNode.content.filter(child => child !== node);
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
case "tags_part":
|
|
105
|
+
if (node.attrs.metadata === "keywords" && node.content) {
|
|
106
|
+
this.frontMatter.keywords.push({
|
|
107
|
+
type: "keywords",
|
|
108
|
+
attrs: {
|
|
109
|
+
language: node.attrs.language
|
|
110
|
+
},
|
|
111
|
+
content: node.content
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
this.frontMatter.tags.push(node);
|
|
116
|
+
}
|
|
117
|
+
parentNode.content = parentNode.content.filter(child => child !== node);
|
|
118
|
+
break;
|
|
119
|
+
case "contributors_part":
|
|
120
|
+
this.frontMatter.contributors.push(node);
|
|
121
|
+
parentNode.content = parentNode.content.filter(child => child !== node);
|
|
122
|
+
break;
|
|
123
|
+
default:
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
if (node.content) {
|
|
127
|
+
node.content.forEach(child => this.preWalkJson(child, node));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
findAllCitations(docContent) {
|
|
131
|
+
// We need to look for citations in the same order they will be found in front + body
|
|
132
|
+
// to get the formatting right.
|
|
133
|
+
if (this.frontMatter.subtitle.default) {
|
|
134
|
+
this.findCitations(this.frontMatter.subtitle.default);
|
|
135
|
+
}
|
|
136
|
+
Object.keys(this.frontMatter.title)
|
|
137
|
+
.filter(language => language !== "default")
|
|
138
|
+
.forEach(language => {
|
|
139
|
+
this.findCitations(this.frontMatter.title[language]);
|
|
140
|
+
if (this.frontMatter.subtitle[language]) {
|
|
141
|
+
this.findCitations(this.frontMatter.subtitle[language]);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
if (this.frontMatter.abstract.default) {
|
|
145
|
+
this.findCitations(this.frontMatter.abstract.default);
|
|
146
|
+
}
|
|
147
|
+
Object.keys(this.frontMatter.abstract)
|
|
148
|
+
.filter(language => language !== "default")
|
|
149
|
+
.forEach(language => {
|
|
150
|
+
this.findCitations(this.frontMatter.abstract[language]);
|
|
151
|
+
});
|
|
152
|
+
this.findCitations(docContent);
|
|
153
|
+
}
|
|
154
|
+
findCitations(node) {
|
|
155
|
+
switch (node.type) {
|
|
156
|
+
case "citation":
|
|
157
|
+
this.citInfos.push(JSON.parse(JSON.stringify(node.attrs)));
|
|
158
|
+
break;
|
|
159
|
+
case "footnote":
|
|
160
|
+
node.attrs.footnote.forEach(child => this.findCitations(child));
|
|
161
|
+
break;
|
|
162
|
+
default:
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
if (node.content) {
|
|
166
|
+
node.content.forEach(child => this.findCitations(child));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
assembleArticleFront() {
|
|
170
|
+
let front = "<front>";
|
|
171
|
+
front +=
|
|
172
|
+
"<journal-meta><journal-id></journal-id><issn></issn></journal-meta>"; // Required by DTD
|
|
173
|
+
front += "<article-meta>";
|
|
174
|
+
if (this.frontMatter.tags.length) {
|
|
175
|
+
front += `<article-categories>${this.frontMatter.tags.map(node => this.walkJson(node)).join("")}</article-categories>`;
|
|
176
|
+
}
|
|
177
|
+
Object.keys(this.frontMatter.subtitle)
|
|
178
|
+
.filter(language => language !== "default")
|
|
179
|
+
.forEach(language => {
|
|
180
|
+
// Making sure there is a title for each subtitle
|
|
181
|
+
if (!this.frontMatter.title[language]) {
|
|
182
|
+
this.frontMatter.title[language] = {
|
|
183
|
+
type: "trans_title",
|
|
184
|
+
attrs: { language }
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
front += "<title-group>";
|
|
189
|
+
front += this.walkJson(this.frontMatter.title.default);
|
|
190
|
+
if (this.frontMatter.subtitle.default) {
|
|
191
|
+
front += this.walkJson(this.frontMatter.subtitle.default);
|
|
192
|
+
}
|
|
193
|
+
Object.keys(this.frontMatter.title)
|
|
194
|
+
.filter(language => language !== "default")
|
|
195
|
+
.forEach(language => {
|
|
196
|
+
front += `<trans-title-group @xml:lang="${language}">`;
|
|
197
|
+
front += this.walkJson(this.frontMatter.title[language]);
|
|
198
|
+
if (this.frontMatter.subtitle[language]) {
|
|
199
|
+
front += this.walkJson(this.frontMatter.subtitle[language]);
|
|
200
|
+
}
|
|
201
|
+
front += "</trans-title-group>";
|
|
202
|
+
});
|
|
203
|
+
front += "</title-group>";
|
|
204
|
+
this.frontMatter.contributors.forEach(contributors => {
|
|
205
|
+
front += this.walkJson(contributors);
|
|
206
|
+
});
|
|
207
|
+
Object.entries(this.affiliations).forEach(([institution, index]) => (front += `<aff id="aff${index}"><institution>${escapeText(institution)}</institution></aff>`));
|
|
208
|
+
// https://validator.jats4r.org/ requires a <permissions> element here, but is OK with it being empty.
|
|
209
|
+
if (this.frontMatter.copyright.holder) {
|
|
210
|
+
front += "<permissions>";
|
|
211
|
+
const year = this.frontMatter.copyright.year
|
|
212
|
+
? this.frontMatter.copyright.year
|
|
213
|
+
: new Date().getFullYear();
|
|
214
|
+
front += `<copyright-year>${year}</copyright-year>`;
|
|
215
|
+
front += `<copyright-holder>${escapeText(this.frontMatter.copyright.holder)}</copyright-holder>`;
|
|
216
|
+
if (this.frontMatter.copyright.freeToRead) {
|
|
217
|
+
front += "<ali:free_to_read/>";
|
|
218
|
+
}
|
|
219
|
+
front += this.frontMatter.copyright.licenses
|
|
220
|
+
.map(license => `<license><ali:license_ref${license.start ? ` start_date="${license.start}"` : ""}>${escapeText(license.url)}</ali:license_ref></license>`)
|
|
221
|
+
.join("");
|
|
222
|
+
front += "</permissions>";
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
front += "<permissions/>";
|
|
226
|
+
}
|
|
227
|
+
if (this.frontMatter.abstract.default) {
|
|
228
|
+
front += this.walkJson(this.frontMatter.abstract.default);
|
|
229
|
+
front += this.closeSections(0);
|
|
230
|
+
}
|
|
231
|
+
Object.keys(this.frontMatter.abstract)
|
|
232
|
+
.filter(language => language !== "default")
|
|
233
|
+
.forEach(language => {
|
|
234
|
+
front += this.walkJson(this.frontMatter.abstract[language]);
|
|
235
|
+
front += this.closeSections(0);
|
|
236
|
+
});
|
|
237
|
+
this.frontMatter.keywords.forEach(keywords => {
|
|
238
|
+
front += this.walkJson(keywords);
|
|
239
|
+
});
|
|
240
|
+
front += "</article-meta></front>";
|
|
241
|
+
return front;
|
|
242
|
+
}
|
|
243
|
+
assembleBookPartFront() {
|
|
244
|
+
let front = "<front-matter><book-part-meta>";
|
|
245
|
+
if (this.frontMatter.tags.length) {
|
|
246
|
+
front += `<subj-group>${this.frontMatter.tags.map(node => this.walkJson(node)).join("")}</subj-group>`;
|
|
247
|
+
}
|
|
248
|
+
Object.keys(this.frontMatter.subtitle)
|
|
249
|
+
.filter(language => language !== "default")
|
|
250
|
+
.forEach(language => {
|
|
251
|
+
// Making sure there is a title for each subtitle
|
|
252
|
+
if (!this.frontMatter.title[language]) {
|
|
253
|
+
this.frontMatter.title[language] = {
|
|
254
|
+
type: "trans_title",
|
|
255
|
+
attrs: { language }
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
front += "<title-group>";
|
|
260
|
+
front += this.walkJson(this.frontMatter.title.default);
|
|
261
|
+
if (this.frontMatter.subtitle.default) {
|
|
262
|
+
front += this.walkJson(this.frontMatter.subtitle.default);
|
|
263
|
+
}
|
|
264
|
+
Object.keys(this.frontMatter.title)
|
|
265
|
+
.filter(language => language !== "default")
|
|
266
|
+
.forEach(language => {
|
|
267
|
+
front += `<trans-title-group @xml:lang="${language}">`;
|
|
268
|
+
front += this.walkJson(this.frontMatter.title[language]);
|
|
269
|
+
if (this.frontMatter.subtitle[language]) {
|
|
270
|
+
front += this.walkJson(this.frontMatter.subtitle[language]);
|
|
271
|
+
}
|
|
272
|
+
front += "</trans-title-group>";
|
|
273
|
+
});
|
|
274
|
+
front += "</title-group>";
|
|
275
|
+
this.frontMatter.contributors.forEach(contributors => {
|
|
276
|
+
front += this.walkJson(contributors);
|
|
277
|
+
});
|
|
278
|
+
Object.entries(this.affiliations).forEach(([institution, index]) => (front += `<aff id="aff${index}"><institution>${escapeText(institution)}</institution></aff>`));
|
|
279
|
+
// https://validator.jats4r.org/ requires a <permissions> element here, but is OK with it being empty.
|
|
280
|
+
if (this.frontMatter.copyright.holder) {
|
|
281
|
+
front += "<permissions>";
|
|
282
|
+
const year = this.frontMatter.copyright.year
|
|
283
|
+
? this.frontMatter.copyright.year
|
|
284
|
+
: new Date().getFullYear();
|
|
285
|
+
front += `<copyright-year>${year}</copyright-year>`;
|
|
286
|
+
front += `<copyright-holder>${escapeText(this.frontMatter.copyright.holder)}</copyright-holder>`;
|
|
287
|
+
if (this.frontMatter.copyright.freeToRead) {
|
|
288
|
+
front += "<ali:free_to_read/>";
|
|
289
|
+
}
|
|
290
|
+
front += this.frontMatter.copyright.licenses
|
|
291
|
+
.map(license => `<license><ali:license_ref${license.start ? ` start_date="${license.start}"` : ""}>${escapeText(license.url)}</ali:license_ref></license>`)
|
|
292
|
+
.join("");
|
|
293
|
+
front += "</permissions>";
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
front += "<permissions/>";
|
|
297
|
+
}
|
|
298
|
+
if (this.frontMatter.abstract.default) {
|
|
299
|
+
front += this.walkJson(this.frontMatter.abstract.default);
|
|
300
|
+
front += this.closeSections(0);
|
|
301
|
+
}
|
|
302
|
+
Object.keys(this.frontMatter.abstract)
|
|
303
|
+
.filter(language => language !== "default")
|
|
304
|
+
.forEach(language => {
|
|
305
|
+
front += this.walkJson(this.frontMatter.abstract[language]);
|
|
306
|
+
front += this.closeSections(0);
|
|
307
|
+
});
|
|
308
|
+
this.frontMatter.keywords.forEach(keywords => {
|
|
309
|
+
front += this.walkJson(keywords);
|
|
310
|
+
});
|
|
311
|
+
front += "</book-part-meta></front-matter>";
|
|
312
|
+
return front;
|
|
313
|
+
}
|
|
314
|
+
walkJson(node, options = {}) {
|
|
315
|
+
let start = "", content = "", end = "";
|
|
316
|
+
switch (node.type) {
|
|
317
|
+
case "doc":
|
|
318
|
+
break;
|
|
319
|
+
case "title":
|
|
320
|
+
if (this.type === "article") {
|
|
321
|
+
start += "<article-title>";
|
|
322
|
+
end = "</article-title>" + end;
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
start += "<title>";
|
|
326
|
+
end = "</title>" + end;
|
|
327
|
+
}
|
|
328
|
+
options = Object.assign({}, options);
|
|
329
|
+
options.breakAllowed = true;
|
|
330
|
+
break;
|
|
331
|
+
case "trans_title":
|
|
332
|
+
start += "<trans-title>";
|
|
333
|
+
end = "</trans-title>" + end;
|
|
334
|
+
options = Object.assign({}, options);
|
|
335
|
+
options.breakAllowed = true;
|
|
336
|
+
break;
|
|
337
|
+
case "subtitle":
|
|
338
|
+
if (node.content) {
|
|
339
|
+
start += "<subtitle>";
|
|
340
|
+
end = "</subtitle>" + end;
|
|
341
|
+
options = Object.assign({}, options);
|
|
342
|
+
options.breakAllowed = true;
|
|
343
|
+
}
|
|
344
|
+
break;
|
|
345
|
+
case "trans_subtitle":
|
|
346
|
+
if (node.content) {
|
|
347
|
+
start += "<trans-subtitle>";
|
|
348
|
+
end = "</trans-subtitle>" + end;
|
|
349
|
+
options = Object.assign({}, options);
|
|
350
|
+
options.breakAllowed = true;
|
|
351
|
+
}
|
|
352
|
+
break;
|
|
353
|
+
case "heading_part":
|
|
354
|
+
// Ignore - we deal with the heading inside
|
|
355
|
+
break;
|
|
356
|
+
case "contributor":
|
|
357
|
+
// Ignore - we deal with contributors_part instead.
|
|
358
|
+
break;
|
|
359
|
+
case "contributors_part":
|
|
360
|
+
if (node.content) {
|
|
361
|
+
const contributorTypes = {
|
|
362
|
+
authors: "author",
|
|
363
|
+
editors: "editor",
|
|
364
|
+
translators: "translator",
|
|
365
|
+
reviewers: "reviewer",
|
|
366
|
+
contributors: "contributor"
|
|
367
|
+
};
|
|
368
|
+
const contributorType = contributorTypes[node.attrs.metadata] || "other";
|
|
369
|
+
start += `<contrib-group content-type="${contributorType}">`;
|
|
370
|
+
end = "</contrib-group>" + end;
|
|
371
|
+
const contributorTypeId = node.attrs.id;
|
|
372
|
+
let counter = 1;
|
|
373
|
+
node.content.forEach(childNode => {
|
|
374
|
+
const contributor = childNode.attrs;
|
|
375
|
+
if (contributor.firstname || contributor.lastname) {
|
|
376
|
+
content += `<contrib id="${contributorTypeId}-${counter++}" contrib-type="person">`;
|
|
377
|
+
content += "<name>";
|
|
378
|
+
if (contributor.lastname) {
|
|
379
|
+
content += `<surname>${escapeText(contributor.lastname)}</surname>`;
|
|
380
|
+
}
|
|
381
|
+
if (contributor.firstname) {
|
|
382
|
+
content += `<given-names>${escapeText(contributor.firstname)}</given-names>`;
|
|
383
|
+
}
|
|
384
|
+
content += "</name>";
|
|
385
|
+
if (contributor.institution) {
|
|
386
|
+
let affNumber;
|
|
387
|
+
if (this.affiliations[contributor.institution]) {
|
|
388
|
+
affNumber =
|
|
389
|
+
this.affiliations[contributor.institution];
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
affNumber = ++this.affCounter;
|
|
393
|
+
this.affiliations[contributor.institution] =
|
|
394
|
+
affNumber;
|
|
395
|
+
}
|
|
396
|
+
content += `<xref ref-type="aff" rid="aff${affNumber}" />`;
|
|
397
|
+
}
|
|
398
|
+
if (contributor.id_type && contributor.id_value) {
|
|
399
|
+
const idType = escapeText(contributor.id_type.toLowerCase());
|
|
400
|
+
content += `<contrib-id contrib-id-type="${idType}">${escapeText(contributor.id_value)}</contrib-id>`;
|
|
401
|
+
}
|
|
402
|
+
content += "</contrib>";
|
|
403
|
+
}
|
|
404
|
+
else if (contributor.institution) {
|
|
405
|
+
// There is an affiliation but no first/last name. We take this
|
|
406
|
+
// as a group collaboration.
|
|
407
|
+
content += `<contrib id="${contributorTypeId}-${counter++}" contrib-type="group">`;
|
|
408
|
+
content += `<collab><named-content content-type="name">${escapeText(contributor.institution)}</named-content></collab>`;
|
|
409
|
+
if (contributor.id_type && contributor.id_value) {
|
|
410
|
+
const idType = escapeText(contributor.id_type.toLowerCase());
|
|
411
|
+
content += `<contrib-id contrib-id-type="${idType}">${escapeText(contributor.id_value)}</contrib-id>`;
|
|
412
|
+
}
|
|
413
|
+
content += "</contrib>";
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
break;
|
|
418
|
+
case "tags_part":
|
|
419
|
+
if (node.content) {
|
|
420
|
+
start += `<subj-group subj-group-type="${node.attrs.id}"${node.attrs.language ? ` xml:lang="${node.attrs.language}"` : ""}>`;
|
|
421
|
+
end = "</subj-group>" + end;
|
|
422
|
+
}
|
|
423
|
+
break;
|
|
424
|
+
case "keywords":
|
|
425
|
+
if (node.content) {
|
|
426
|
+
start += `<kwd-group${node.attrs.language ? ` xml:lang="${node.attrs.language}"` : ""}>`;
|
|
427
|
+
end = "</kwd-group>" + end;
|
|
428
|
+
options = Object.assign({}, options);
|
|
429
|
+
options.inKeywords = true;
|
|
430
|
+
}
|
|
431
|
+
break;
|
|
432
|
+
case "tag":
|
|
433
|
+
if (options.inKeywords) {
|
|
434
|
+
content += `<kwd>${node.attrs.tag}</kwd>`;
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
content += `<subject>${node.attrs.tag}</subject>`;
|
|
438
|
+
}
|
|
439
|
+
break;
|
|
440
|
+
case "abstract":
|
|
441
|
+
if (node.content) {
|
|
442
|
+
start += "<abstract>";
|
|
443
|
+
end = "</abstract>" + end;
|
|
444
|
+
}
|
|
445
|
+
break;
|
|
446
|
+
case "trans_abstract":
|
|
447
|
+
if (node.content) {
|
|
448
|
+
start += `<trans-abstract xml:lang="${node.attrs.language}">`;
|
|
449
|
+
end = "</trans-abstract>" + end;
|
|
450
|
+
}
|
|
451
|
+
break;
|
|
452
|
+
case "richtext_part":
|
|
453
|
+
if (node.attrs.metadata) {
|
|
454
|
+
options = Object.assign({}, options);
|
|
455
|
+
options.partMetadata = node.attrs.metadata;
|
|
456
|
+
}
|
|
457
|
+
break;
|
|
458
|
+
case "table_of_contents":
|
|
459
|
+
// TODO: Not sure what to use here.
|
|
460
|
+
break;
|
|
461
|
+
case "separator_part":
|
|
462
|
+
case "table_part":
|
|
463
|
+
// part separators as in page breaks should usually already be handled
|
|
464
|
+
// by JATS renderer and table parts will simply show the table inside of them.
|
|
465
|
+
break;
|
|
466
|
+
case "paragraph":
|
|
467
|
+
start += `<p id="p-${++this.parCounter}">`;
|
|
468
|
+
end = "</p>" + end;
|
|
469
|
+
break;
|
|
470
|
+
case "heading1":
|
|
471
|
+
case "heading2":
|
|
472
|
+
case "heading3":
|
|
473
|
+
case "heading4":
|
|
474
|
+
case "heading5":
|
|
475
|
+
case "heading6": {
|
|
476
|
+
if (options.ignoreHeading) {
|
|
477
|
+
break;
|
|
478
|
+
}
|
|
479
|
+
else if (options.inFootnote) {
|
|
480
|
+
// only allows <p> block level elements https://jats.nlm.nih.gov/archiving/tag-library/1.2/element/fn.html
|
|
481
|
+
start += `<p id="p-${++this.parCounter}">`;
|
|
482
|
+
end = "</p>" + end;
|
|
483
|
+
break;
|
|
484
|
+
}
|
|
485
|
+
const metadata = options.partMetadata;
|
|
486
|
+
if (metadata) {
|
|
487
|
+
// the metadata should only be applied once within a part.
|
|
488
|
+
delete options.partMetadata;
|
|
489
|
+
}
|
|
490
|
+
const level = Number.parseInt(node.type.slice(-1));
|
|
491
|
+
if (this.currentSectionLevel > level - 1) {
|
|
492
|
+
start += this.closeSections(level - 1);
|
|
493
|
+
}
|
|
494
|
+
while (this.currentSectionLevel < level) {
|
|
495
|
+
this.currentSectionLevel++;
|
|
496
|
+
if (this.currentSectionLevel === level) {
|
|
497
|
+
start += `<sec id="${node.attrs.id}"${metadata ? ` sec-type="${metadata}"` : ""}>`;
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
start += `<sec id="h-${++this.headingCounter}">`;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
start += "<title>";
|
|
504
|
+
end = "</title>" + end;
|
|
505
|
+
options = Object.assign({}, options);
|
|
506
|
+
options.breakAllowed = true;
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
case "code_block":
|
|
510
|
+
if (options.inFootnote) {
|
|
511
|
+
// only allows <p> block level elements https://jats.nlm.nih.gov/archiving/tag-library/1.2/element/fn.html
|
|
512
|
+
start += `<p id="p-${++this.parCounter}">`;
|
|
513
|
+
end = "</p>" + end;
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
start += "<code>";
|
|
517
|
+
end = "</code>" + end;
|
|
518
|
+
break;
|
|
519
|
+
case "blockquote":
|
|
520
|
+
start += "<disp-quote>";
|
|
521
|
+
end = "</disp-quote>" + end;
|
|
522
|
+
break;
|
|
523
|
+
case "ordered_list": {
|
|
524
|
+
if (options.inFootnote) {
|
|
525
|
+
// only allows <p> block level elements https://jats.nlm.nih.gov/archiving/tag-library/1.2/element/fn.html
|
|
526
|
+
break;
|
|
527
|
+
}
|
|
528
|
+
const continuedListEndNumber = node.attrs.order - 1;
|
|
529
|
+
let lastListIndex;
|
|
530
|
+
// TODO: deal with lists that have an order number other than 1 that do not continue previous lists. Currently not possible in JATS
|
|
531
|
+
if (continuedListEndNumber) {
|
|
532
|
+
lastListIndex = this.orderedListLengths.lastIndexOf(continuedListEndNumber);
|
|
533
|
+
// const lastListReverseIndex = this.orderedListLengths.slice().reverse().findIndex(length => length === continuedListEndNumber)
|
|
534
|
+
// if (lastListReverseIndex !== undefined) {
|
|
535
|
+
// lastListIndex = this.orderedListLengths.length-lastListReverseIndex
|
|
536
|
+
// }
|
|
537
|
+
}
|
|
538
|
+
if (lastListIndex > -1) {
|
|
539
|
+
start += `<list list-type="order" id="list-${++this.listCounter}" continued-from="list-${lastListIndex}">`;
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
start += `<list list-type="order" id="list-${++this.listCounter}">`;
|
|
543
|
+
}
|
|
544
|
+
options = Object.assign({}, options);
|
|
545
|
+
options.inOrderedList = this.listCounter;
|
|
546
|
+
this.orderedListLengths[options.inOrderedList] =
|
|
547
|
+
continuedListEndNumber;
|
|
548
|
+
end = "</list>" + end;
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
case "bullet_list":
|
|
552
|
+
if (options.inFootnote) {
|
|
553
|
+
// only allows <p> block level elements https://jats.nlm.nih.gov/archiving/tag-library/1.2/element/fn.html
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
556
|
+
start += `<list list-type="bullet" id="list-${++this.listCounter}">`;
|
|
557
|
+
end = "</list>" + end;
|
|
558
|
+
options = Object.assign({}, options);
|
|
559
|
+
delete options.inOrderedList;
|
|
560
|
+
break;
|
|
561
|
+
case "list_item":
|
|
562
|
+
if (options.inFootnote) {
|
|
563
|
+
// only allows <p> block level elements https://jats.nlm.nih.gov/archiving/tag-library/1.2/element/fn.html
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
if (options.inOrderedList !== undefined) {
|
|
567
|
+
this.orderedListLengths[options.inOrderedList] += 1;
|
|
568
|
+
}
|
|
569
|
+
start += "<list-item>";
|
|
570
|
+
end = "</list-item>" + end;
|
|
571
|
+
break;
|
|
572
|
+
case "footnote":
|
|
573
|
+
content += `<xref ref-type="fn" rid="fn-${++this.fnCounter}">${this.fnCounter}</xref>`;
|
|
574
|
+
options = Object.assign({}, options);
|
|
575
|
+
options.inFootnote = true;
|
|
576
|
+
this.footnotes.push(this.walkJson({
|
|
577
|
+
type: "footnotecontainer",
|
|
578
|
+
attrs: {
|
|
579
|
+
id: `fn-${this.fnCounter}`,
|
|
580
|
+
label: this.fnCounter // Note: it's unclear whether the footnote number is required as a label
|
|
581
|
+
},
|
|
582
|
+
content: node.attrs.footnote
|
|
583
|
+
}, options));
|
|
584
|
+
break;
|
|
585
|
+
case "footnotecontainer":
|
|
586
|
+
start += `<fn id="${node.attrs.id}"><label>${node.attrs.label}</label>`;
|
|
587
|
+
end = "</fn>" + end;
|
|
588
|
+
break;
|
|
589
|
+
case "text": {
|
|
590
|
+
content += convertText(node);
|
|
591
|
+
break;
|
|
592
|
+
}
|
|
593
|
+
case "cross_reference": {
|
|
594
|
+
start += `<xref rid="${node.attrs.id}">`;
|
|
595
|
+
content += escapeText(node.attrs.title || "MISSING TARGET");
|
|
596
|
+
end = "</xref>" + end;
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
case "citation": {
|
|
600
|
+
const citationText = this.citations.citationTexts[this.citationCount++];
|
|
601
|
+
if (options.inFootnote ||
|
|
602
|
+
this.citations.citFm.citationType !== "note") {
|
|
603
|
+
content += citationText;
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
content += `<xref ref-type="fn" rid="fn-${++this.fnCounter}">${this.fnCounter}</xref>`;
|
|
607
|
+
this.footnotes.push(`<fn id="fn-${this.fnCounter}"><label>${this.fnCounter}</label><p id="p-${++this.parCounter}">${citationText}</p></fn>`);
|
|
608
|
+
}
|
|
609
|
+
break;
|
|
610
|
+
}
|
|
611
|
+
case "figure": {
|
|
612
|
+
// Note: width and alignment are not stored due to lack of corresponding attributes in JATS.
|
|
613
|
+
if (options.inFootnote) {
|
|
614
|
+
// only allows <p> block level elements https://jats.nlm.nih.gov/archiving/tag-library/1.2/element/fn.html
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
617
|
+
let imageFilename, copyright;
|
|
618
|
+
const image = node.content.find(node => node.type === "image")?.attrs
|
|
619
|
+
.image || false;
|
|
620
|
+
if (image !== false) {
|
|
621
|
+
this.imageIds.push(image);
|
|
622
|
+
const imageDBEntry = this.imageDB.db[image], filePathName = imageDBEntry.image;
|
|
623
|
+
copyright = imageDBEntry.copyright;
|
|
624
|
+
imageFilename = filePathName.split("/").pop();
|
|
625
|
+
}
|
|
626
|
+
const caption = node.attrs.caption
|
|
627
|
+
? node.content.find(node => node.type === "figure_caption")
|
|
628
|
+
?.content || []
|
|
629
|
+
: [];
|
|
630
|
+
if (node.attrs.category === "none" &&
|
|
631
|
+
imageFilename &&
|
|
632
|
+
!caption.length &&
|
|
633
|
+
(!copyright || !copyright.holder)) {
|
|
634
|
+
content += `<graphic id="${node.attrs.id}" position="anchor" xlink:href="${imageFilename}">`;
|
|
635
|
+
content += `<alt-text>${escapeText(caption.map(node => node.text || "").join("") || imageFilename)}</alt-text>`;
|
|
636
|
+
content += "</graphic>";
|
|
637
|
+
}
|
|
638
|
+
else {
|
|
639
|
+
start += `<fig id="${node.attrs.id}">`;
|
|
640
|
+
end = "</fig>" + end;
|
|
641
|
+
const category = node.attrs.category;
|
|
642
|
+
if (category !== "none") {
|
|
643
|
+
if (!this.categoryCounter[category]) {
|
|
644
|
+
this.categoryCounter[category] = 0;
|
|
645
|
+
}
|
|
646
|
+
const catCount = ++this.categoryCounter[category];
|
|
647
|
+
const catLabel = `${CATS[category][this.doc.settings.language]} ${catCount}`;
|
|
648
|
+
start += `<label>${escapeText(catLabel)}</label>`;
|
|
649
|
+
}
|
|
650
|
+
if (caption.length) {
|
|
651
|
+
start += `<caption><p>${caption.map(node => this.walkJson(node)).join("")}</p></caption>`;
|
|
652
|
+
}
|
|
653
|
+
const equation = node.content.find(node => node.type === "figure_equation")?.attrs.equation;
|
|
654
|
+
if (equation) {
|
|
655
|
+
start += "<disp-formula>";
|
|
656
|
+
end = "</disp-formula>" + end;
|
|
657
|
+
const equationML = convertLatexToMathMl(equation);
|
|
658
|
+
content = `
|
|
659
|
+
<alternatives>
|
|
660
|
+
<tex-math><![CDATA[${equation}]]></tex-math>
|
|
661
|
+
<mml:math>${equationML}</mml:math>
|
|
662
|
+
</alternatives>
|
|
663
|
+
`;
|
|
664
|
+
}
|
|
665
|
+
else {
|
|
666
|
+
if (copyright?.holder) {
|
|
667
|
+
start += "<permissions>";
|
|
668
|
+
const year = copyright.year
|
|
669
|
+
? copyright.year
|
|
670
|
+
: new Date().getFullYear();
|
|
671
|
+
start += `<copyright-year>${year}</copyright-year>`;
|
|
672
|
+
start += `<copyright-holder>${escapeText(copyright.holder)}</copyright-holder>`;
|
|
673
|
+
if (copyright.freeToRead) {
|
|
674
|
+
start += "<ali:free_to_read/>";
|
|
675
|
+
}
|
|
676
|
+
start += copyright.licenses
|
|
677
|
+
.map(license => `<license><ali:license_ref${license.start ? ` start_date="${license.start}"` : ""}>${escapeText(license.url)}</ali:license_ref></license>`)
|
|
678
|
+
.join("");
|
|
679
|
+
start += "</permissions>";
|
|
680
|
+
}
|
|
681
|
+
if (imageFilename) {
|
|
682
|
+
content += `<graphic position="anchor" xlink:href="${imageFilename}">`;
|
|
683
|
+
content += `<alt-text>${escapeText(caption.map(node => node.text || "").join("") || imageFilename)}</alt-text>`;
|
|
684
|
+
content += "</graphic>";
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
break;
|
|
689
|
+
}
|
|
690
|
+
case "figure_caption":
|
|
691
|
+
// We are already dealing with this in the figure. Prevent content from being added a second time.
|
|
692
|
+
return "";
|
|
693
|
+
case "figure_equation":
|
|
694
|
+
// We are already dealing with this in the figure.
|
|
695
|
+
break;
|
|
696
|
+
case "image":
|
|
697
|
+
// We are already dealing with this in the figure.
|
|
698
|
+
break;
|
|
699
|
+
case "table": {
|
|
700
|
+
// Note: We ignore right/left/center aligned and table layout
|
|
701
|
+
if (options.inFootnote) {
|
|
702
|
+
// only allows <p> block level elements https://jats.nlm.nih.gov/archiving/tag-library/1.2/element/fn.html
|
|
703
|
+
break;
|
|
704
|
+
}
|
|
705
|
+
start += `<table-wrap id="${node.attrs.id}">`;
|
|
706
|
+
end = "</table-wrap>" + end;
|
|
707
|
+
const category = node.attrs.category;
|
|
708
|
+
if (category !== "none") {
|
|
709
|
+
if (!this.categoryCounter[category]) {
|
|
710
|
+
this.categoryCounter[category] = 0;
|
|
711
|
+
}
|
|
712
|
+
const catCount = ++this.categoryCounter[category];
|
|
713
|
+
const catLabel = `${CATS[category][this.doc.settings.language]} ${catCount}`;
|
|
714
|
+
start += `<label>${escapeText(catLabel)}</label>`;
|
|
715
|
+
}
|
|
716
|
+
const caption = node.attrs.caption
|
|
717
|
+
? node.content[0].content || []
|
|
718
|
+
: [];
|
|
719
|
+
if (caption.length) {
|
|
720
|
+
start += `<caption><p>${caption.map(node => this.walkJson(node)).join("")}</p></caption>`;
|
|
721
|
+
}
|
|
722
|
+
start += `<table width="${node.attrs.width}%"><tbody>`;
|
|
723
|
+
end = "</tbody></table>" + end;
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
726
|
+
case "table_body":
|
|
727
|
+
// Pass through to table.
|
|
728
|
+
break;
|
|
729
|
+
case "table_caption":
|
|
730
|
+
// We already deal with this in 'table'.
|
|
731
|
+
return "";
|
|
732
|
+
case "table_row":
|
|
733
|
+
start += "<tr>";
|
|
734
|
+
end = "</tr>" + end;
|
|
735
|
+
break;
|
|
736
|
+
case "table_cell":
|
|
737
|
+
start += `<td${node.attrs.colspan === 1 ? "" : ` colspan="${node.attrs.colspan}"`}${node.attrs.rowspan === 1 ? "" : ` rowspan="${node.attrs.rowspan}"`}>`;
|
|
738
|
+
end = "</td>" + end;
|
|
739
|
+
break;
|
|
740
|
+
case "table_header":
|
|
741
|
+
start += `<th${node.attrs.colspan === 1 ? "" : ` colspan="${node.attrs.colspan}"`}${node.attrs.rowspan === 1 ? "" : ` rowspan="${node.attrs.rowspan}"`}>`;
|
|
742
|
+
end = "</th>" + end;
|
|
743
|
+
break;
|
|
744
|
+
case "equation": {
|
|
745
|
+
start += "<inline-formula>";
|
|
746
|
+
end = "</inline-formula>" + end;
|
|
747
|
+
const equationML = convertLatexToMathMl(node.attrs.equation);
|
|
748
|
+
content = `
|
|
749
|
+
<alternatives>
|
|
750
|
+
<tex-math><![CDATA[${node.attrs.equation}]]></tex-math>
|
|
751
|
+
<mml:math>${equationML}</mml:math>
|
|
752
|
+
</alternatives>
|
|
753
|
+
`;
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
case "hard_break":
|
|
757
|
+
// Forbidden inside of most elements. We only render it if explicitly allowed.
|
|
758
|
+
// https://jats.nlm.nih.gov/publishing/tag-library/1.3/element/break.html
|
|
759
|
+
if (options.breakAllowed) {
|
|
760
|
+
content += "<break />";
|
|
761
|
+
}
|
|
762
|
+
else {
|
|
763
|
+
content += " ";
|
|
764
|
+
}
|
|
765
|
+
break;
|
|
766
|
+
default:
|
|
767
|
+
break;
|
|
768
|
+
}
|
|
769
|
+
if (!content.length && node.content) {
|
|
770
|
+
node.content.forEach(child => {
|
|
771
|
+
content += this.walkJson(child, options);
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
return start + content + end;
|
|
775
|
+
}
|
|
776
|
+
closeSections(targetLevel) {
|
|
777
|
+
let returnValue = "";
|
|
778
|
+
while (this.currentSectionLevel > targetLevel) {
|
|
779
|
+
returnValue += "</sec>";
|
|
780
|
+
this.currentSectionLevel--;
|
|
781
|
+
}
|
|
782
|
+
return returnValue;
|
|
783
|
+
}
|
|
784
|
+
assembleBody(docContent) {
|
|
785
|
+
return `<body id="body">${this.walkJson(docContent) + this.closeSections(0)}</body>`;
|
|
786
|
+
}
|
|
787
|
+
assembleBack() {
|
|
788
|
+
let back = "<back>";
|
|
789
|
+
if (this.footnotes.length) {
|
|
790
|
+
back += `<fn-group>${this.footnotes.join("")}</fn-group>`;
|
|
791
|
+
}
|
|
792
|
+
if (this.citations.jatsBib.length) {
|
|
793
|
+
back += `<ref-list>${this.citations.jatsBib}</ref-list>`;
|
|
794
|
+
}
|
|
795
|
+
back += "</back>";
|
|
796
|
+
return back;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
//# sourceMappingURL=convert.js.map
|