mgaitan / sphinxcontrib-mermaid

Mermaid diagrams in yours sphinx powered docs
http://sphinxcontrib-mermaid-demo.readthedocs.io/en/latest/
Other
335 stars 96 forks source link

mermaid cdn change? #110

Closed brownsarahm closed 1 year ago

brownsarahm commented 1 year ago

I am currently getting a CDN error on diagrams that worked previously.

I noticed that the mermaid.js docs use a different cdn now than what this package loads:

docs:

  <script type="module">
    import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
    mermaid.initialize({ startOnLoad: true });
  </script>

from building a jupyterbook with this extension:

<script src="https://unpkg.com/mermaid/dist/mermaid.min.js"></script>
    <script>mermaid.initialize({startOnLoad:true});</script>

I have verified that manually editing the built html makes the images render.

PyB1l commented 1 year ago

DO we have any updates on this?

reszelaz commented 1 year ago

I also hit the same issue.

blujan commented 1 year ago

It looks like the latest release of Mermaid no longer has mermaid.min.js, which breaks the js include. As a workaround, I was able to point to the previous Mermaid version by adding mermaid_version = "9.4.0" to conf.py to restore functionality.

brownsarahm commented 1 year ago

I got mine up and working for now using my forked copy of this package in my requirements.txt

rsenft1 commented 1 year ago

Any idea how to make this work with a jupyter book? I tried the suggestion in that issue for the requirements.txt but it did not work for me and I don't have a conf.py to modify. I tried adding it to my config.yml but it didn't work. :/

rsenft1 commented 1 year ago

Nevermind, can confirm that pasting the same line from your requirements.txt to mine does work!

brownsarahm commented 1 year ago

It looks like the latest release of Mermaid no longer has mermaid.min.js, which breaks the js include. As a workaround, I was able to point to the previous Mermaid version by adding mermaid_version = "9.4.0" to conf.py to restore functionality.

This issue is immediate cause of the diagrams not rendering, but separate from the fact that mermaid changed their recommended CDN. I can use 'latest' //this package defaults from the recommended cdn (jsdeliver vs unpkg).

andy-t-sp commented 1 year ago

For anybody else reading this because they have broken mermaid diagrams in their docs. Version 0.8.1 contains a fix https://github.com/mgaitan/sphinxcontrib-mermaid/releases/tag/0.8.1.

For me, fixing was as simple as editing my requrements.txt file, amending the sphinxcontrib-mermaid line to:

sphinxcontrib-mermaid==0.8.1

then running pip install -r requirements.txt in the terminal and then re-building the docs.

samonzeweb commented 1 year ago

The 0.8.1 seems to use the old asset url : https://github.com/mgaitan/sphinxcontrib-mermaid/blob/0.8.1/sphinxcontrib/mermaid.py#L386

andy-t-sp commented 1 year ago

The 0.8.1 seems to use the old asset url : https://github.com/mgaitan/sphinxcontrib-mermaid/blob/0.8.1/sphinxcontrib/mermaid.py#L386

My (limited) understanding is that mermaid v9.x is still available at the old asset URL, it's just the new v10 version that is not. So, by specifying mermaid v9.4.1, the 0.8.1 release of sphinxcontrib-mermaid, does fix the issue. Diff here

Disclaimer: I'm just a dev with some broken docs trying to sort out a sensible fix, not a maintainer, expert, or authority on the subject.

brownsarahm commented 1 year ago

updating the version will fix your docs, but it leaves you stuck on an old version of mermaid. I'm hoping the maintainer of this package will accept #111 because it's not ideal to be relying on an old version of mermaid.

andy-t-sp commented 1 year ago

Thanks, so for me, perhaps amending my requirements.txt sphinxcontrib-mermaid line to:

sphinxcontrib-mermaid > 0.7.1, < 1.0

would be best? Then I'll get working docs for now, and if/when a better fix comes in from your PR or elsewhere, then I'll get that as well.

I'm specifying the version to less than v1, because, as we've seen with mermaid, major version number changes are likely to be breaking changes, assuming the author follows the semantic versioning convention.

brownsarahm commented 1 year ago

No, fixing the version of this package probably wont fix the underlying issue, other than version 0.8.1 this package default to the "latest" version of mermaid, which to be clear, is the correct thing to do. We should use an intermediate package that fixes us to an old version of mermaid. You can either update to the latest version of this package which fixes you to an old version of mermaid, or like I did, manually modify this package to follow mermaid instructions.

You could even do as I did and point to my fork of this package.

Mermaid did not actually release breaking changes to their package. They changed how to access their code, the CDN.

mgaitan commented 1 year ago

I'm closing this as (partially) fixed by 0.8.1 version .

This was a consequence a (IMHO very bad) decition from Mermaid developer. Now they are reconsidering it and probably we'll be able to support mermaid >10 by default soon. https://github.com/mermaid-js/mermaid/discussions/4148