Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mermaid diagram rendering in Markdown preview #10696

Open
1 task done
Tracked by #5346
szabba opened this issue Apr 17, 2024 · 5 comments
Open
1 task done
Tracked by #5346

Mermaid diagram rendering in Markdown preview #10696

szabba opened this issue Apr 17, 2024 · 5 comments
Labels
enhancement [core label] language An umbrella label for all programming languages syntax behaviors markdown Markdown markup support potential extension Functionality that could be implemented as an extension (consider moving to community extensions)

Comments

@szabba
Copy link

szabba commented Apr 17, 2024

Check for existing issues

  • Completed

Describe the feature

Markdown is great for writing technical documentation maintained alongside the code, using the same workflows - but technical documentation often needs to contain diagrams.

Mermaid is a code-driven tool for preparing technical diagrams.
It supports different types of diagrams, with different syntaxes.

GitLab and GitHub support rendering mermaid diagrams from fenced code blocks annotated as Mermaid code.
VS Code code has plugins 1 that enable viewing them in the Markdown preview.
Notion.so supports something similar, though it's only Markdown-adjacent.

If applicable, add mockups / screenshots to help present your vision of the feature

Here I've overlayed how GitHub renders these ono Zed:

image

Here's a screenshot showing how Notion lets the user switch betwen the code vs diagram view.

image

This might be nice to have for Zed.
It is more important in Notion's use case.
They don't have a strict separation between viewing and editing.
In Zed that separation is the Markdown text buffer vs preview pane distinction.

Footnotes

  1. I'm linking to the one with most installs as of submission.

@szabba szabba added admin read Pending admin review enhancement [core label] triage Maintainer needs to classify the issue labels Apr 17, 2024
@Moshyfawn Moshyfawn added markdown Markdown markup support language An umbrella label for all programming languages syntax behaviors and removed triage Maintainer needs to classify the issue labels Apr 17, 2024
@JosephTLyons JosephTLyons added potential extension Functionality that could be implemented as an extension (consider moving to community extensions) and removed admin read Pending admin review labels Apr 19, 2024
@Spoutnik97
Copy link

@JosephTLyons is it still possible to develop this extension ? Does it depend on architectural stuff ?
I could try to develop it

@ckmjreynolds
Copy link

1

The only thing that keeps me using VSCode vs. Zed is the inability to properly edit README.md files for GitHub. In my case, the most glaring omission is the inability to include Mermaid diagrams.

@ckmjreynolds
Copy link

FWIW, I discovered it is possible to use Marked 2 (on MacOS) and use a simple preprocessor script to get Mermaid working in a preview with Zed. Not ideal, but maybe enough to allow me to stop using VSCode.

@Spoutnik97
Copy link

@ckmjreynolds how do you use the preprocessor ?

@ckmjreynolds
Copy link

ckmjreynolds commented Jul 12, 2024

@Spoutnik97

cat marked_preprocessor.sh
#!/bin/bash
cat ~/bin/head.html -

cat head.html
<script src="https://unpkg.com/mermaid@10/dist/mermaid.min.js"></script>
<script>
	mermaid.initialize({ startOnLoad: true });
	mermaid.initialize({ startOnLoad: true });
	Marked.hooks.register('update', function() { mermaid.run(); });
</script>

For some reason calling initialize twice is needed at least in my testing, you can instead do Cmd R to refresh.

I pieced this together based on support information for both using Mermaid and using a preprocessor on Marked 2's support website.

@notpeter notpeter mentioned this issue Jul 31, 2024
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement [core label] language An umbrella label for all programming languages syntax behaviors markdown Markdown markup support potential extension Functionality that could be implemented as an extension (consider moving to community extensions)
Projects
None yet
Development

No branches or pull requests

5 participants