diff --git a/docs-site/integrations/remark-mermaid.mjs b/docs-site/integrations/remark-mermaid.mjs
index cd1e98b..cb2c2c2 100644
--- a/docs-site/integrations/remark-mermaid.mjs
+++ b/docs-site/integrations/remark-mermaid.mjs
@@ -14,6 +14,14 @@
* The source is escaped rather than interpolated. A label containing `<` or `&` is
* ordinary in these diagrams (`callers --> services`, `A & B`), and unescaped it
* would be parsed as markup and silently deleted before mermaid ever saw it.
+ *
+ * The wrapper is emitted **here, at build time**, and it is what the magnifier button
+ * hangs off. Two reasons it cannot be the `
` itself, and neither is cosmetic:
+ * `Head.astro`'s redraw assigns `node.textContent`, which destroys every child of the
+ * `
` on each theme toggle; and `pre.mermaid` scrolls horizontally, so a button
+ * positioned inside it would slide out of view on exactly the wide diagrams that need
+ * it most. A wrapper written by the transform is outside both problems and needs no
+ * DOM surgery in the browser.
*/
import { visit } from "unist-util-visit";
@@ -30,7 +38,10 @@ export default function remarkMermaid() {
if (node.lang !== "mermaid" || parent === undefined || index === undefined) return;
parent.children[index] = {
type: "html",
- value: `
${escape(node.value)}
`,
+ value:
+ `
` +
+ `
${escape(node.value)}
` +
+ `
`,
};
});
};
diff --git a/docs-site/src/components/Head.astro b/docs-site/src/components/Head.astro
index b7d4255..fd899a8 100644
--- a/docs-site/src/components/Head.astro
+++ b/docs-site/src/components/Head.astro
@@ -11,6 +11,12 @@
* The import is dynamic and guarded on there being a diagram, so mermaid (which is
* megabytes) is fetched on the fifteen architecture pages and on none of the other
* twenty-seven.
+ *
+ * The second half of the script is the magnifier: a diagram set at the width of a
+ * prose column is unreadable, and these are the pages where the diagram *is* the
+ * point. Every drawn diagram gets a button, and the button opens the SVG in a
+ * `