mermaid-ascii: Mermaid to ASCII art playground via Go WASM#295
Merged
Conversation
In-browser playground (mermaid-ascii.html) that renders Mermaid flowchart and sequence diagram source as ASCII / Unicode box-drawing art, using https://github.com/AlexanderGrooff/mermaid-ascii (MIT) compiled unmodified to WebAssembly with the standard Go toolchain (GOOS=js GOARCH=wasm). Follows the pattern of grok-mermaid.html but for the Go library: - mermaid-ascii/build_wasm.sh clones upstream at a pinned commit, strips the cobra CLI and gin web-server entry points (nothing else imports them), adds a syscall/js shim exporting renderMermaidAscii(), and builds a 3.7 MB module (wasm-opt -Oz; ~1.1 MB gzipped). - The page renders with the library's "html" style so classDef color:#hex classes work, sanitizing the unescaped span output via a strict tokenizer + textContent instead of innerHTML. - Examples cover the features this library actually supports: labeled edges, A --> B & C fan-out, subgraphs, <br> multi-line labels, classDef colors, and sequence diagrams with alt/loop/par fragments and notes (two examples reused from grok-mermaid where compatible). - Controls: ASCII-only toggle, node padding X/Y, box padding, copy as text, permalink via URL fragment. - tests/test_mermaid_ascii.py: 8 Playwright tests incl. an XSS probe. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UPeaso82zQbKb67TTSVQ2e
Contributor
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In-browser playground (mermaid-ascii.html) that renders Mermaid flowchart
and sequence diagram source as ASCII / Unicode box-drawing art, using
https://github.com/AlexanderGrooff/mermaid-ascii (MIT) compiled unmodified
to WebAssembly with the standard Go toolchain (GOOS=js GOARCH=wasm).
Follows the pattern of grok-mermaid.html but for the Go library:
the cobra CLI and gin web-server entry points (nothing else imports
them), adds a syscall/js shim exporting renderMermaidAscii(), and
builds a 3.7 MB module (wasm-opt -Oz; ~1.1 MB gzipped).
color:#hex classes work, sanitizing the unescaped span output via a
strict tokenizer + textContent instead of innerHTML.
edges, A --> B & C fan-out, subgraphs,
multi-line labels,
classDef colors, and sequence diagrams with alt/loop/par fragments
and notes (two examples reused from grok-mermaid where compatible).
text, permalink via URL fragment.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01UPeaso82zQbKb67TTSVQ2e