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

Mermaid diagrams fail to render #1450

Closed
chalin opened this issue Feb 28, 2023 · 3 comments · Fixed by #1451
Closed

Mermaid diagrams fail to render #1450

chalin opened this issue Feb 28, 2023 · 3 comments · Fixed by #1451
Labels
bug Something isn't working

Comments

@chalin
Copy link
Collaborator

chalin commented Feb 28, 2023

Since the following change has been applied, some previously working Mermaid diagrams report "syntax error":

But nothing has changed in the diagrams and the live Mermaid editor are fine with the Mermaid code.

I believe that the problem stems from the decision to render the code block as a <div> rather than <pre>:

<div class="mermaid">
{{- .Inner | safeHTML }}
</div>

Ok, after some digging, I've found that <pre> is _required, see Requirements for the Mermaid API:

image

References:

/cc @stephanlachnit @deining

@chalin chalin added the bug Something isn't working label Feb 28, 2023
@chalin chalin self-assigned this Feb 28, 2023
@chalin
Copy link
Collaborator Author

chalin commented Feb 28, 2023

Oh, I forgot to mention that the safeHTML also contributes to the diagram not rendering.

@deining
Copy link
Collaborator

deining commented Feb 28, 2023

Have a look at yesterday's commit to the hugDoc's repo:

gohugoio/hugoDocs@eddd25f

This commit does exactly does what you request: replacing <div> with <pre>. We should following and do the same in our repo.

From the commit message:

MermaidJS now specifies to write chart's markdown within a `pre` HTML tag to improve semantics.

Side note: hugoDocs are using ESM import for mermaid now:

gohugoio/hugoDocs@b2a23b6

@chalin
Copy link
Collaborator Author

chalin commented Feb 28, 2023

Oh great! Thanks for that reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants