-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle module style inclusion of local Mermaid v10 library #92
Comments
The current version does support both, according to the extension. |
Indeed, I missed that. However, still in the spirit of rendering diagrams offline, it seems that v9 is still being loaded off of Unpkg. In the dev tools, I see: 200 http://127.0.0.1:8000/site/js/mermaid.min.mjs Configuration:
- mermaid2:
arguments:
theme: |
^(JSON.parse(__md_get("__palette").index == 1)) ? "dark" : "light"
javascript: js/mermaid.min.mjs
$ cat mermaid-10.4.0.min.mjs
import { b9 as f } from "./mermaid-d733041c.js";
export {
f as default
}; HTML code generated (in a sub-directory, may be irrelevant though): <script type="module">import mermaid from "../js/mermaid.min.mjs"; mermaid.initialize();
window.mermaidConfig = {default: {
theme: (JSON.parse(__md_get("__palette").index == 1)) ? "dark" : "light",
startOnLoad: false
}};</script> |
The HTML generated seems correct? 🤔 (I do not know exactly what the dev tools report... could be what's in the cache?) |
I am not sure what happens, but the HTML looks fine to me? The best thing to do, would be to use |
The line that loads the library from Unpkg comes from the bundle ( I have the following in my configuration, which is the root cause of the behaviour: - pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:mermaid2.fence_mermaid_custom I added these lines after reading the associated documentation page: https://mkdocs-mermaid2.readthedocs.io/en/latest/superfences/#usage-for-the-material-theme If I remove this bit of configuration, Mermaid explodes telling me there’s a syntax error in my diagrams. I don’t know if v10 is retro-compatible with v9, I assumed it was. But the library is fully loaded off the local directory. Any suggestions of what the best next move is? |
Hmm... there seems to be something there. In need to check whether it's the expected behavior or not. |
You can also take a look at the example of a user configuration you provided here. The value of "format" must be set to |
Good point. There is indeed an inconsistency with the paragraph specifically written on Material, which quotes two requirements:
This needs to be sorted out: key question is, why that change of representation of the HTML code, in relation to Material. I don't remember what problem I was solving when I introduced it into the code. On condition that the issues/code documentation were kept sufficiently well on Github (that's the opportunity to test it), one should be able to follow the trail. |
Hi,
This is a follow-up to #90.
It’d be nice to be able to pick how the library passed to the
javascript
option will be imported.As of now, there’s support only for the regular
<script src="…" />
type of import, which works with Mermaid ≤ v9.Mermaid v10 uses a module, which requires a different style of import (untested):
Thanks!
The text was updated successfully, but these errors were encountered: