jupyter-book / mystmd

Command line tools for working with MyST Markdown.
https://mystmd.org/guide
MIT License
219 stars 64 forks source link

[Typst] Mermaid breaks Typst export #1436

Open roaldarbol opened 3 months ago

roaldarbol commented 3 months ago

Description

If one includes mermaid in a document and tries to export to Typst, the export fails. Here's the content I used, which caused export to fail.

::::{figure}
:label: intro-diagrams

(diagram-1)=
:::{mermaid}
flowchart TD
  A[Behavioural state] --> B[Behavioural episodes]
:::

(diagram-2)=
:::{mermaid}
flowchart TD
  A[Behavioural state] --> B[Behavioural episodes]
  C[Context] -.-> A & B
:::

(diagram-3)=
:::{mermaid}
flowchart TD
  A[Behavioural state] --> B[Behavioural episodes]
  C[Context, Light] -.-> A & B
  D[Context, Time] -.-> A & B
:::

::::
Log

Thesis on  main [!] via 🅒 Thesis took 12s ❯ myst build typst-thesis.md 📬 Performing exports: typst-thesis.md -> Exports/PhD-Thesis.pdf 📖 Built 00-Front-Matter/01-Declaration.md in 160 ms. 📖 Built 00-Front-Matter/02-Summary.md in 159 ms. 📖 Built 00-Front-Matter/03-Preface.md in 159 ms. 📖 Built 00-Front-Matter/04-Acknowledgements.md in 159 ms. 📖 Built 00-Front-Matter/05-Dedication.md in 159 ms. 📖 Built 00-Front-Matter/06-Glossary.md in 160 ms. 📖 Built 00-Front-Matter/00-Front-Page.md in 136 ms. 📖 Built 01-Chapters/01-Introduction.md in 670 ms. 📖 Built 01-Chapters/04-Chapter.md in 654 ms. 📖 Built 01-Chapters/05-Discussion.md in 649 ms. ⛔️ 01-Chapters/02-Chapter.md container of kind table contains no valid content besides caption, legend Valid content types include image, referenced notebook cell, table, code, iframe, subfigure ⛔️ 01-Chapters/02-Chapter.md container of kind table contains no valid content besides caption, legend Valid content types include image, referenced notebook cell, table, code, iframe, subfigure ⛔️ 01-Chapters/02-Chapter.md container of kind table contains no valid content besides caption, legend Valid content types include image, referenced notebook cell, table, code, iframe, subfigure ⚠️ 01-Chapters/02-Chapter.md unexpected figure content of type table found in legend node ⚠️ 01-Chapters/02-Chapter.md unexpected figure content of type table found in legend node ⚠️ 01-Chapters/02-Chapter.md unexpected figure content of type table found in legend node ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "beta" ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "95% ci1" ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "p-value" ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "contrast" ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "95% ci" ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "p-value" ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "characteristic" ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "moving" ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "idle" ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "beta" ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "95% ci1" ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "p-value" ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "beta" ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "95% ci1" ⚠️ 01-Chapters/02-Chapter.md Duplicate identifier in file "p-value" 📖 Built 01-Chapters/02-Chapter.md in 1.62 s. ⛔️ 01-Chapters/03-Chapter.md container of kind table contains no valid content besides caption, legend Valid content types include image, referenced notebook cell, table, code, iframe, subfigure ⛔️ 01-Chapters/03-Chapter.md container of kind table contains no valid content besides caption, legend Valid content types include image, referenced notebook cell, table, code, iframe, subfigure ⛔️ 01-Chapters/03-Chapter.md container of kind table contains no valid content besides caption, legend Valid content types include image, referenced notebook cell, table, code, iframe, subfigure ⚠️ 01-Chapters/03-Chapter.md unexpected figure content of type table found in legend node ⚠️ 01-Chapters/03-Chapter.md unexpected figure content of type table found in legend node ⚠️ 01-Chapters/03-Chapter.md unexpected figure content of type table found in legend node ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "ch3-eq1" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "p" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "icc" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "icc" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "spearmans rank" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "gaussian" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "beta" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "bayesian beta" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "rho" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "p" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "icc" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "p" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "icc" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "icc" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "stub_1_1" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "stub_1_2" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "stub_1_3" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "stub_1_4" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "stub_1_5" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "stub_1_6" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "stub_1_7" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "spearmans rank" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "gaussian" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "beta" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "bayesian beta" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "rho" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "p" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "icc" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "p" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "icc" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "icc" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "mr ~ trial + (1 | animal id)" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "stub_1_1" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "stub_1_2" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "stub_1_3" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "mr ~ trial + light regime + (1 | animal id)" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "stub_1_4" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "stub_1_5" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "stub_1_6" ⚠️ 01-Chapters/03-Chapter.md Duplicate identifier in file "stub_1_7" 📖 Built 01-Chapters/03-Chapter.md in 1.64 s. 📚 Built 12 pages for export (including 1 dependency) from /Users/roaldarbol/Filen/Thesis in 2.22 s. 🌠 Converting 2 images with extensions .pdf to supported formats .svg, .png, .jpg, .jpeg ⛔️ Unhandled Typst conversion for node of "glossary" ⛔️ typst-thesis.md multiple values for part 'abstract' found; ignoring value from 01-Chapters/03-Chapter.md ⛔️ Figure with no non-caption content: tbl:ch3:table_sr ⛔️ Figure with no non-caption content: tbl:ch3:table_mr_active ⛔️ Figure with no non-caption content: tbl:ch3:table_mr_passive ⛔️ typst-thesis.md multiple values for part 'abstract' found; ignoring value from 01-Chapters/04-Chapter.md ⛔️ typst-thesis.md multiple values for part 'abstract' found; ignoring value from 01-Chapters/02-Chapter.md ⛔️ Unhandled Typst conversion for node of "mermaid" ⛔️ Unhandled Typst conversion for node of "mermaid" ⛔️ Unhandled Typst conversion for node of "mermaid" ⛔️ Figure with no non-caption content: tbl:ch2:state_interaction ⛔️ Figure with no non-caption content: tbl:ch2:mod_light_marg ⛔️ Figure with no non-caption content: tbl:ch2:mod_light 📑 Exported typst in 5.61 s, copying to _build/temp/mystw7sQW8/PhD-Thesis.typ ⚠️ typst-thesis.md 'frontmatter' extra key ignored: exclude (at typst-thesis.md) error: missing argument: body ┌─ _build/temp/mystw7sQW8/PhD-Thesis-chapter.typ:52:13 │ 52 │ #subpar.grid(figure( │ ╭──────────────^ 53 │ │ ), , │ ╰─^ help: error occurred while importing this module ┌─ _build/temp/mystw7sQW8/PhD-Thesis.typ:71:9 │ 71 │ #include "PhD-Thesis-chapter.typ" │ ^^^^^^^^^^^^^^^^^^^^^^^^ Error: Command failed: typst compile "/Users/roaldarbol/Filen/Thesis/_build/temp/mystw7sQW8/PhD-Thesis.typ" error: missing argument: body ┌─ _build/temp/mystw7sQW8/PhD-Thesis-chapter.typ:52:13 │ 52 │ #subpar.grid(figure( │ ╭──────────────^ 53 │ │ ), , │ ╰─^ help: error occurred while importing this module ┌─ _build/temp/mystw7sQW8/PhD-Thesis.typ:71:9 │ 71 │ #include "PhD-Thesis-chapter.typ" │ ^^^^^^^^^^^^^^^^^^^^^^^^

Proposed solution

Maybe instead a soft warning?

Additional notes

myst v1.3.2

agoose77 commented 3 months ago

I'll try to finish this off monday; current idea is to use mmdc in our build step.