Skip to content

Replace Mermaid renderer with Merman - #82

Merged
minchenlee merged 5 commits into
minchenlee:mainfrom
chungchihhan:codex/merman-renderer
Oct 26, 2026
Merged

minchenlee merged 5 commits into
minchenlee:mainfrom
chungchihhan:codex/merman-renderer

Conversation

@chungchihhan

@chungchihhan chungchihhan commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Replace the existing Mermaid renderer with Merman 0.9.1 while retaining the native SVG-to-RGBA worker/cache pipeline. Use the resvg-safe SVG lowering for text labels and composite theme alpha before encoding RGB colors.

Flowcharts use the default Dagre layout. ELK is disabled and absent from the lockfile. There are no bundled icon packs or icon-registry setup, preview-modal/reading-width changes, or project status/backlog/plan changes in this diff.

Requires Rust 1.95+; README and dependency references are updated. Existing standalone LaTeX and DOT rendering remain unchanged. Integration coverage exercises CJK flowcharts, sequence/class/state/mindmap diagrams, theme overrides and raster output. The fixture and export example allow manual inspection.

Validation on the final diff

Command Passed Failed Ignored
cargo test --release --lib 547 0 1
cargo test --release --tests 627 0 2

The --tests total includes the library tests; the additional integration tests account for 80 passed and 1 ignored. Tests ran on macOS arm64. The first sandboxed integration run could not bind local IPC sockets; the same full command passed when run with local socket permissions.

cargo fmt --all --check and git diff --check also passed. Existing ambiguous-import, unused Section, and dependency future-compatibility warnings remain. Linux/Windows CI and Rust 1.95 itself were not run locally.

Known circle sizing, markdown-label formatting and pie-color differences remain outside this renderer-replacement scope, as requested in review.

@minchenlee

Copy link
Copy Markdown
Owner

Thanks for moving this to Merman — we reached the same conclusion independently. We ran a spike comparing Merman, the current renderer and Mermaid.js 12.2 on 12 fixtures × light/dark: Merman scores SSIM 0.860 against Mermaid.js (0.897 when both use dagre), versus 0.771 for the current renderer, and it renders everything, including sequence alt/loop blocks that the current renderer cannot parse. So we'd like to land Merman.

Before we can merge, could you narrow this PR?

  1. Merman only, dagre only. Please drop the layout-elk feature and EPL-2.0.txt. ELK is opt-in here anyway, so most diagrams don't change, and we'd rather not ship EPL-2.0 code in the MIT binary for now. We can revisit ELK later as an opt-in feature.
  2. No bundled icon packs. Please remove assets/mermaid-icons/ and the IconRegistry setup. Together they add ~10.4 MB of uncompressed JSON to the binary for a feature few documents use, and upstream Mermaid.js doesn't bundle these packs either. The AWS pack is CC BY-ND 2.0, and the renamed identifiers and removed XML IDs may count as derivative changes, which we can't accept.
  3. Separate PRs for the preview modal and the reading-width slider. They're unrelated to the renderer, and they conflict with the pointer-support PRs (MDV-048 P1: pointer correctness for overlays, plus pointer quick wins #70–MDV-048 P8c: sidebar peek hides at once and matches the docked sidebar; Quick Slot switch keeps the sidebar #81) currently in review (src/app/mod.rs, dispatch.rs, message.rs, chrome.rs). Smaller PRs will be much easier to rebase once those land.
  4. Please leave PROJECT_STATUS.md, docs/BACKLOG.md and docs/plans/ out of the PR. MDV-048 is already taken (pointer support), and we'll assign IDs and update the status docs on our side.
  5. Tests. Please run cargo test --release --lib and cargo test --release --tests on the final diff and paste the counts. Once the PR is narrowed, we'll approve the CI run so Linux and Windows get built too.

Known Merman differences from our spike (no need to fix in this PR; just so you know what to expect):

  • A flowchart circle node (((Render))) is drawn with r≈93 instead of ≈45.
  • Bold/italic/markdown labels render as plain text through the resvg-safe pipeline.
  • With theme: base, pie slices derive from primaryColor and come out very low-contrast in both themes; setting pie1…pie12 from the palette would fix it.

Thanks again — the Rust-only approach is a big improvement over the WebKit helper.

@chungchihhan chungchihhan changed the title Render Mermaid with Merman, offline AWS icons and preview controls Replace Mermaid renderer with Merman Oct 25, 2026
Resolve src/diagram.rs: keep both the Merman alpha-compositing test and
main's zoom-raster tests.
@minchenlee
minchenlee merged commit d76d058 into minchenlee:main Oct 26, 2026
5 checks passed
minchenlee added a commit that referenced this pull request Nov 10, 2026
docs: MDV-048 merged; plan completed; track #82 and #84
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.

2 participants