Skip to content

Conversation

@jimsynz
Copy link
Contributor

@jimsynz jimsynz commented Jan 12, 2026

Summary

  • Moves mermaid.js script from before_closing_head_tag to before_closing_body_tag
  • Ensures mermaid runs after DOM content is loaded so it can find and transform code blocks
  • Keeps Plausible analytics in the head tag where it belongs

Problem

Mermaid diagrams in hexdocs were rendering as code blocks instead of images because the script was loaded in the <head> before the DOM content was available.

Solution

ExDoc's before_closing_body_tag option ensures the script runs after all page content is loaded, allowing mermaid to find elements with class="mermaid" and render them as diagrams.

Closes #287

Test plan

  • mix check --no-retry passes
  • mix docs builds successfully
  • Generated HTML shows mermaid script correctly placed before </body>

…ering

Mermaid diagrams were rendering as code blocks instead of images because
the script was loaded in the head tag before the DOM content was available.
Moving to `before_closing_body_tag` ensures the script runs after all
page content is loaded, allowing mermaid to find and transform the code
blocks.

Closes #287
@jimsynz jimsynz merged commit 0fb2f63 into main Jan 12, 2026
23 checks passed
@jimsynz jimsynz deleted the fix/mermaid-rendering branch January 12, 2026 23:01
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

Successfully merging this pull request may close these issues.

Render mermaid diagrams on hexdoc

1 participant