markdown: Update merman renderer to 0.6#57967
Conversation
|
Thanks for the PR (and the excellent library)! I'm OOO but will review when I'm back. Would be very happy to remove as much of the post-processing logic as possible, so looking forward to it 😁 |
|
I've pushed a commit to fix the incorrect colors and a few other issues. But if any of that looks redundant given some features of merman 0.6 feel free to change it. This was the minimal change to keep rendering looking how it does today |
|
Oops, my bad! I was a bit too trigger-happy with deleting those post-processing lines. 😅 Huge thanks to @cameron1024 for the commits to fix this (and honestly, for bringing merman into Zed in the first place!). I can confirm it works well now.
Theming is definitely still a weak point in merman, so keeping Zed's own color compatibility layer makes sense. Feel free to adjust the logic or push directly to this branch if you want! Longer term, I’ll take these pain points into account and work on proper theme support for merman v0.7, alongside the Mermaid v11.15.0 update. Thanks again! |
|
Nice! I've been really happy with it, so excited for any improvements 😁 I think the visual output is good now, I'll do a more regular code review later today, but from a quick look already it seems fine. |
|
FYI, based on #58325, I think we should hold off on merging this PR until that panic is fixed upstream |
- switch mermaid_render to published merman 0.6.2\n- refresh Cargo.lock to use crates.io release artifacts
|
Thanks, I have fixed in v0.6.2. I also found the same issue in a few other diagram types (State, Block, Mindmap, Treemap, C4, and Class diagram) and fixed them in the same release. |
|
Update on the code: we hit a stack overflow with cyclic diagrams, e.g.: flowchart TD
subgraph A
B
end
subgraph B
A
end
This requires a change to merman, which we've pushed to our fork, tagged Going ahead and merging this. If you feel like my changes are incorrect, happy to discuss in another PR after the release. Thanks again for the contribution! |
|
/cherry-pick preview |
|
That works for me. Given the release timing, I think this is the right approach. I was likely over-focusing on 1:1 Mermaid SVG parity and didn't pay enough attention to edge-case robustness. I'll do a quick audit of upstream merman for similar scenarios and follow up in a separate thread if I find anything. |
|
🍒💥 Cherry-pick did not succeed |
I was a silly goose didn't notice my `git push` failed, so merged zed-industries#57967 without a critical commit, and some follow-ups. This PR just cherry-picks those commits. Release Notes: - N/A or Added/Fixed/Improved ...
Cherry-picks 2 PRs - originally meant to be 1 PR, but my local git state was messed up, causing a `git push` to fail and I didn't notice: - #57967 - #58419 Self-Review Checklist: - [ ] I've reviewed my own diff for quality, security, and reliability - [ ] Unsafe blocks (if any) have justifying comments - [ ] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [ ] Tests cover the new/changed behavior - [ ] Performance impact has been considered and is acceptable Closes #ISSUE Release Notes: - N/A or Added/Fixed/Improved ... --------- Co-authored-by: Latias94 <superfrankie621@gmail.com>
Following up on zed-industries#57644 by @cameron1024, this PR updates `merman` to v0.6. With merman 0.6's new raster-safe SVG pipeline, Zed can move generic `usvg`/`resvg` cleanup passes out of this crate and rely on merman for them instead. **What's moved to merman:** - `foreignObject` fallback text generation - Unsupported CSS cleanup - Invalid SVG attribute cleanup **What's kept in Zed:** - Theme CSS injection and accent color assignment - Zed-specific fallback overlay handling **Integration note:** In merman v0.6, fallback overlay groups are marked with `data-merman-foreignobject="fallback"` and preserve source classes like `node` or `section-*`, so host CSS can still style fallback text. This PR updates Zed's accent tracker to check for this marker, ensuring fallback overlays are not treated as real layout nodes. I also added a render-stage test for the new contract: the SVG output from `render_mermaid` is already raster-safe before Zed-specific post-processing runs. --- ### Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ### Release Notes: - Improved rendering of Mermaid diagrams in Markdown previews. ### Tests: - `cargo +1.95 fmt --check -p mermaid_render` - `cargo +1.95 test -p mermaid_render` - `cargo +1.95 clippy -p mermaid_render --all-targets -- -D warnings` - `git diff --check HEAD~1..HEAD` --------- Co-authored-by: cameron <cameron.studdstreet@gmail.com>
I was a silly goose didn't notice my `git push` failed, so merged zed-industries#57967 without a critical commit, and some follow-ups. This PR just cherry-picks those commits. Release Notes: - N/A or Added/Fixed/Improved ...



Following up on #57644 by @cameron1024, this PR updates
mermanto v0.6.With merman 0.6's new raster-safe SVG pipeline, Zed can move generic
usvg/resvgcleanup passes out of this crate and rely on merman for them instead.What's moved to merman:
foreignObjectfallback text generationWhat's kept in Zed:
Integration note:
In merman v0.6, fallback overlay groups are marked with
data-merman-foreignobject="fallback"and preserve source classes likenodeorsection-*, so host CSS can still style fallback text. This PR updates Zed's accent tracker to check for this marker, ensuring fallback overlays are not treated as real layout nodes.I also added a render-stage test for the new contract: the SVG output from
render_mermaidis already raster-safe before Zed-specific post-processing runs.Self-Review Checklist:
Release Notes:
Tests:
cargo +1.95 fmt --check -p mermaid_rendercargo +1.95 test -p mermaid_rendercargo +1.95 clippy -p mermaid_render --all-targets -- -D warningsgit diff --check HEAD~1..HEAD