badboy / mdbook-mermaid

A preprocessor for mdbook to add mermaid support
Mozilla Public License 2.0
306 stars 32 forks source link

mermaid V10 support #32

Closed suda-morris closed 8 months ago

suda-morris commented 1 year ago

According to https://github.com/mermaid-js/mermaid/releases/tag/v10.0.0 mermaid has dropped the CJS support.

friegger commented 1 year ago

Any update on this? Would it be an option to also allow downloading the latest or a specific version of mermaid when executing mdbook-mermaid install. Then it would not be necessary to touch mdbook-mermaid every time a new mermaid release is available.

badboy commented 1 year ago

mdbook-mermaid install is a convenience command to drop the required files into your folder. If you need a different, more recent version you can do that by downloadig it manually and putting the files in the right place.

I won't add more complex code for arbitrary downloads. I didn't have time to update to v10 yet and currently it's not a priority for me.

char101 commented 1 year ago

It's easy to add mermaid-js v10 manually

  1. Remove additional-js = ["mermaid.min.js", "mermaid-init.js"] from book.toml
  2. Create theme/head.hbs containing
    <script type="module">
    import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
    mermaid.initialize({ startOnLoad: true });
    </script>
yatesco commented 11 months ago

theme/head.hbs is relative to the project root (so theme is a sibling of src). This is just a note for those like me who stupidly added it to the transient 'book' directory and wondered why it kept disappearing ;-)

Works really well - thanks @char101

tetsushiawano commented 9 months ago

for me, this solution works on github pages, but when do print, it can not use the V10.

NTmatter commented 8 months ago

From a quick bit of playing, it seems like we can overwrite the local copy of mermaid. It gets picked up and used buy the build:

curl -LO https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js

Beware of local browser cache!