Skip to content

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

@elac-safran

Description

@elac-safran

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions