Skip to content

Commit b8a800c

Browse files
Kyome22claude
andcommitted
Add Mermaid.js integration section to README
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 887fe5f commit b8a800c

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,40 @@ loadMarkdown("./content.md", document.getElementById("content")).then(() => hljs
278278

279279
---
280280

281+
## Diagrams with Mermaid
282+
283+
lobster.js renders fenced ` ```mermaid ` blocks as `<code class="language-mermaid">`. After `loadMarkdown()` resolves, replace those elements with Mermaid's expected `<div class="mermaid">` and call `mermaid.run()`.
284+
285+
````markdown
286+
```mermaid
287+
flowchart LR
288+
A[Plan] --> B[Delay] --> C[Cancel] --> D[Apologize] --> A
289+
```
290+
````
291+
292+
```html
293+
<script type="module">
294+
import { loadMarkdown } from "https://hacknock.github.io/lobsterjs/lobster.js";
295+
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
296+
297+
mermaid.initialize({ startOnLoad: false });
298+
299+
await loadMarkdown("./content.md", document.getElementById("content"));
300+
301+
document.querySelectorAll("code.language-mermaid").forEach(code => {
302+
const wrapper = code.closest(".lbs-code-block");
303+
const div = document.createElement("div");
304+
div.className = "mermaid";
305+
div.textContent = code.textContent;
306+
(wrapper ?? code).replaceWith(div);
307+
});
308+
309+
await mermaid.run();
310+
</script>
311+
```
312+
313+
---
314+
281315
## Claude Code skills
282316
283317
If you use [Claude Code](https://claude.ai/code), this repository ships two slash commands in `.claude/commands/`:

0 commit comments

Comments
 (0)