Skip to content

Render Mermaid diagrams in the viewer - #15

Draft
davidmoshal wants to merge 1 commit into
openknowledge-sh:mainfrom
davidmoshal:codex/render-mermaid-diagrams
Draft

Render Mermaid diagrams in the viewer#15
davidmoshal wants to merge 1 commit into
openknowledge-sh:mainfrom
davidmoshal:codex/render-mermaid-diagrams

Conversation

@davidmoshal

Copy link
Copy Markdown

Fixes #14

Summary

  • Render Mermaid fences in initial and dynamically stacked viewer panels.
  • Lazy-load pinned Mermaid 11.16.0 from embedded same-origin assets in strict mode.
  • Match viewer theme tokens and add contextual accessible names.
  • Preserve source plus inline errors for invalid diagrams.
  • Include the runtime and assets in default interactive HTML exports.
  • Add Node adapter tests, Go integration/export tests, documentation, notices, and licenses.

Root cause

Markdown recognized the fence, but the viewer emitted only a generic code block; no Mermaid runtime or attached-panel enhancement existed. Real-browser QA also caught that detached dynamic panels cannot safely render layout-dependent diagrams, so enhancement now runs after panel attachment.

Validation

  • pnpm test:cli
  • go test -race -shuffle=on -count=1 ./packages/cli/...
  • go vet ./packages/cli/...
  • source-built openknowledge validate Wiki
  • source-built Chrome QA: initial render, invalid fallback, later-valid isolation, stacked sequence diagram, theme switch, and mobile scroller
  • interactive HTML export Chrome QA
  • five-lane exact-SHA review plus independent debugging runtime audit

The vendored Mermaid bundle is approximately 3.4 MB but is fetched only when a Mermaid fence exists. Its version, MIT license, and SHA-256 are recorded in the third-party notices.

@filipdanisko

Copy link
Copy Markdown
Collaborator

@davidmoshal Thank you for the contribution, was thinking about adding myself! Will take a look at this soon!

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 fenced code blocks in the viewer and HTML exports

2 participants