From 84ab26408d1e3065015255fc5e3d09d3655f06d4 Mon Sep 17 00:00:00 2001 From: Marko Vejnovic Date: Mon, 13 Jul 2026 21:50:58 +0000 Subject: [PATCH 1/2] fix(docs): render Mermaid/KaTeX on swup navigation, not only full load ExDoc uses swup for client-side page transitions, so DOMContentLoaded and the KaTeX auto-render onload fire only on the initial hard load. After any in-docs navigation (sidebar link, internal link, HexDocs search) both Mermaid diagrams and $$..$$ math were left as raw source. Drive all rendering from ExDoc's window `exdoc:loaded` event, which fires on the initial load and after every swup content swap. Also fix the Mermaid selector: ExDoc emits
, not 
.

Closes HYP-10 (#82).
---
 mix.exs | 69 +++++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 48 insertions(+), 21 deletions(-)

diff --git a/mix.exs b/mix.exs
index 4c4bdcb7..49b9564e 100644
--- a/mix.exs
+++ b/mix.exs
@@ -151,30 +151,57 @@ defmodule Hyper.MixProject do
     """
     
     
-    
+    
     
     
     """
   end

From 5567e2418ecab37f3683a53ae31add610aa535c2 Mon Sep 17 00:00:00 2001
From: Marko Vejnovic 
Date: Mon, 13 Jul 2026 23:34:25 +0000
Subject: [PATCH 2/2] refactor(docs): use ExDoc's canonical KaTeX/Mermaid
 recipe

Replace the hand-rolled DOM surgery with the snippet ExDoc's own README
prescribes: two `exdoc:loaded` listeners, KaTeX via renderMathInElement, and
Mermaid via mermaid.render() per 
 block. Drops the unused
\[ / \( delimiters (docs use only $ / $$), which removes the quad-backslash
heredoc escaping, and loads mermaid with defer to match the reference. Same
behavior, verified: KaTeX + Mermaid render on both hard load and swup nav.
---
 mix.exs | 81 ++++++++++++++++++++++++---------------------------------
 1 file changed, 34 insertions(+), 47 deletions(-)

diff --git a/mix.exs b/mix.exs
index 49b9564e..bc4c92c8 100644
--- a/mix.exs
+++ b/mix.exs
@@ -145,63 +145,50 @@ defmodule Hyper.MixProject do
     ]
   end
 
-  # Load Mermaid in the HTML docs and render any ```mermaid code fences as
-  # diagrams. ExDoc tags Mermaid blocks with the `mermaid` class.
+  # KaTeX (math) and Mermaid (diagrams) rendering for the HTML docs. This is the
+  # recipe ExDoc's own README prescribes: ExDoc navigates between pages with
+  # swup (client-side content swaps) and re-fires `exdoc:loaded` on window after
+  # every swap as well as on the initial load. Hanging rendering off that event
+  # -- rather than DOMContentLoaded / a script `onload`, which fire only once --
+  # is what keeps math and diagrams rendered as a reader navigates the docs.
   defp before_closing_body_tag(:html) do
     """
     
     
     
-    
+    
     
     """
   end