Skip to content
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

Incorrect rendering due to wrong script sequence in HTML file #124

Open
elac-safran opened this issue Jun 1, 2023 · 3 comments
Open

Incorrect rendering due to wrong script sequence in HTML file #124

elac-safran opened this issue Jun 1, 2023 · 3 comments

Comments

@elac-safran
Copy link

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:

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.

@KenwoodFox
Copy link

I had this same issue! Reordering my plugins fixed it for me too, this is good to know! But an unfortunate bug.

@quentin-ag
Copy link

I am facing the same issue. @KenwoodFox you say that re-ordering plugins fixed it for you. Do you mean changing the position of "sphinxcontrib.mermaid" in the extensions list in conf.py? If so, how did you change the order to fix this issue?

@acbart
Copy link

acbart commented Mar 29, 2024

What a strange issue. I had the same issue, I needed to move mermaid to the top of the list:

extensions = ['sphinxcontrib.mermaid',
              'sphinx.ext.autodoc',
              'sphinx.ext.githubpages',
              'sphinxjp.themes.basicstrap',
              'sphinxcontrib.fulltoc',
              'sphinx_tabs.tabs',
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants