Render Mermaid diagrams referenced from a .mmd or .mermaid file
#201064
Replies: 2 comments 3 replies
-
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
-
|
This would be a massive quality-of-life upgrade for docs : ( But, currently and Sadly, you're forced to choose between pre-rendering SVGs via CI (which gets stale fast) or using those messy base64 blobs with Mermaid Live. Neither is a real "source of truth." Definitely push this through the official GitHub feedback form; discussions are great for visibility, but that's how this actually gets on the engineering roadmap. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
🏷️ Discussion Type
Product Feedback
💬 Feature/Topic Area
Code Search and Navigation
Body
Feature request
Render Mermaid diagrams referenced from a
.mmdor.mermaidfile — both same-repo relative paths andcross-repo raw URLs — the way SVG images work today:
What GitHub already supports
GitHub currently renders Mermaid in two places:
Inline fenced blocks in Markdown files, issues, PRs, discussions, and wikis
(docs):
Standalone
.mermaid/.mmdfiles viewed directly in blob view(docs).
The missing piece
There is no way to reference a
.mmdfile from a Markdown file, the way imagepaths work today.
renders inline;does not —and neither does a raw URL to a
.mmdfile in another repository, even though theequivalent raw SVG URL renders fine.
This means a diagram has no single source of truth:
must be copy-pasted as fenced blocks, which inevitably drift apart.
service's repository — the exact use case in Is it possible to reference another diagram within a diagram / magic cross linking? mermaid-js/mermaid#1944, open since 2021.
The upstream Mermaid project cannot fix this, because rendering is the host's job.
with mermaid-cli and commit the images (e.g. feat: add --keep-source to retain mermaid source in Markdown output mermaid-js/mermaid-cli#1114,
https://github.com/nielsvaneck/render-md-mermaid). This works — and the SVG can then
be referenced cross-repo via its raw URL — but it duplicates every diagram as a build
artifact and goes stale the moment someone edits the source without re-rendering.
mermaid.ink/ Mermaid Live URL avoids the build step butmoves the diagram out of the repo into an unreadable base64 blob in the URL.
Proposed behavior
When the target of Markdown image syntax is a
.mmd/.mermaidfile, render it as aMermaid diagram (in the same sandboxed viewer used for fenced blocks and blob view),
with exactly the same resolution and access semantics as images:
Relative path, same repo — resolved at the same ref as the Markdown file being
rendered, subject to the same access control:
Absolute raw URL, any repo — fetched the way raw image URLs are fetched today
(anonymously, via GitHub's proxy). This works for public repositories and fails for
private ones — identical to the behavior of a cross-repo raw SVG URL now, so it
introduces no new permission surface:
Pinning to a tag or commit SHA instead of a branch gives stable embeds, again exactly
as with images.
Because both forms reuse the existing image-resolution rules and the existing sandboxed
Mermaid renderer, this avoids the cross-origin, permission, and cache-invalidation
questions that general Markdown transclusion would raise: nothing becomes fetchable that
isn't fetchable today, and staleness behaves no differently than a referenced image.
Who benefits
service repo (Is it possible to reference another diagram within a diagram / magic cross linking? mermaid-js/mermaid#1944).
.mmdfile is the diagram,editable in blob view, rendered everywhere it's referenced — across repositories.
Beta Was this translation helpful? Give feedback.
All reactions