-
Notifications
You must be signed in to change notification settings - Fork 102
Description
Mermaid diagram is not rendered; the produced HTML document shows the mermaid code in raw text.
After investigation, it appears the error comes from a bad ordering of the script directive in the HTML file, caused by a side-effect when sphinxcontrib.mermaid
is used with other sphinx extensions.
In my case (from conf.py
file):
extensions = [
"nbsphinx",
"sphinx_mdinclude",
"sphinx_copybutton",
"sphinx.ext.autosummary",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"mermaid",
]
I join two versions of a minimal example, where the relevant script directives have been swapped (one OK, the other buggy).
example.zip
By fiddling around with the code, I found that lowering priority (from 500 to 100, say) did the job, in:
sphinxcontrib-mermaid/sphinxcontrib/mermaid.py
Lines 509 to 510 in 6f8de39
app.add_config_value("mermaid_js_priority", 500, "html") | |
app.add_config_value("mermaid_init_js_priority", 500, "html") |
However, this is not a satisfying solution. As it turns out, the solution proposed in #76 works perfectly, and is much more robust.