Skip to content

feat: say why a mermaid diagram was not rendered - #313

Open
simono wants to merge 1 commit into
RivoLink:mainfrom
simono:feat/mermaid-too-wide-hint
Open

simono wants to merge 1 commit into
RivoLink:mainfrom
simono:feat/mermaid-too-wide-hint

Conversation

@simono

@simono simono commented Sep 29, 2026

Copy link
Copy Markdown

What changed

When no layout of a Mermaid diagram fits, leaf falls back to its source (#288). The block header now says why and how wide the terminal needs to be:

┌─ mermaid · not rendered, needs 256 columns, has 120 ─┐
  • mermaid::render returns Result<String, Fallback>; Fallback::TooWide carries the width of the narrowest layout it tried.
  • The header reports that in terminal columns, including the frame and any list or blockquote prefix, so resizing to that width renders the diagram.
  • On narrow terminals the label drops detail until it fits instead of wrapping.
  • Unsupported or invalid diagrams keep the plain mermaid header.

Why

The fallback is silent, so a diagram that is only too wide looks like unsupported Mermaid. I hit this with a flowchart and a state diagram that need 256 and 212 columns.

How it was tested

  • New tests in markdown_embedded.rs: the reported width is exact (one column less falls back, the reported width renders), the header fits at widths 20 to 60, and unsupported diagrams get no note.
  • cargo test, cargo clippy --all-targets --all-features -- -D warnings, cargo build --release.
  • Manually with wide flowchart and state diagrams, resizing the terminal across the threshold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant