TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Mermaid: Create diagrams and visualizations using text and code

349 点作者 tomduncalf大约 3 年前

29 条评论

kibwen大约 3 年前
It&#x27;s convenient that GitHub Markdown supports graphs natively, and I&#x27;ve used Mermaid there successfully. However, I was fairly disappointed with Mermaid itself; I found the syntax irregular and non-intuitive (the syntax for every different graph type feels like it was designed by different people working independently), the documentation was sparse (though it exists at all, so I&#x27;ll give it points for that), and worst of all the error messages were atrociously cryptic and entirely unhelpful.<p>That said, I also found the default styling and layout of the generated graphs to be far more attractive than Graphviz&#x2F;dot, though I&#x27;m not sure if that&#x27;s attributable to Mermaid or GitHub.<p>Which is to say, altogether probably a step forward, but still lots of room for improvement. Please, start with the error messages!
评论 #31277609 未加载
评论 #31277501 未加载
gepeto42大约 3 年前
Mermaid is great for keeping simple diagrams in Markdown documents, and GitHub very recently started supporting it. Beats taking screenshots and uploading PNGs to the repo for sure!<p>For those using VS Code, this GitHub Markdown extension also renders mermaid: <a href="https:&#x2F;&#x2F;marketplace.visualstudio.com&#x2F;items?itemName=bierner.markdown-preview-github-styles" rel="nofollow">https:&#x2F;&#x2F;marketplace.visualstudio.com&#x2F;items?itemName=bierner....</a>
评论 #31276027 未加载
评论 #31274334 未加载
评论 #31277320 未加载
评论 #31274357 未加载
评论 #31274509 未加载
heycaseywattsup大约 3 年前
I love that GitHub and Notion both support mermaid.js now!!<p>I wrote a tutorial for mermaid.js that you all might like :)<p>It includes: * the most common use cases * syntax gotchas and mnemonics for remembering them * how to style the diagrams (similar to css) * options for editors (including online ones! <a href="https:&#x2F;&#x2F;mermaid.live" rel="nofollow">https:&#x2F;&#x2F;mermaid.live</a> rocks)<p>Casey&#x27;s Mermaid.js tutorial: <a href="https:&#x2F;&#x2F;www.happyandeffective.com&#x2F;blog&#x2F;realtime-collaborative-diagramming-in-notion-with-mermaidjs" rel="nofollow">https:&#x2F;&#x2F;www.happyandeffective.com&#x2F;blog&#x2F;realtime-collaborativ...</a><p>---<p>I also wrote a tutorial for graphviz (which does not have GitHub or Notion support last I checked). I&#x27;m so proud of it -- it&#x27;s the most starred graphviz tutorial on GitHub<p>Casey&#x27;s Graphviz tutorial: <a href="https:&#x2F;&#x2F;github.com&#x2F;caseywatts&#x2F;graphviz-tutorial" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;caseywatts&#x2F;graphviz-tutorial</a>
评论 #31276330 未加载
amingilani大约 3 年前
I appreciate and used to use Mermaid for everything. I&#x27;ve since found PlantUML to be phenomenal. There were a few things I couldn&#x27;t flat out do with mermaid that I can&#x27;t recall since it&#x27;s been a year. But I&#x27;ve never run into a limitation with PlantUML
cjlm大约 3 年前
For something a bit more user-friendly check out flowchart.fun [0] – I just interviewed the sole developer [1]<p>[0]: <a href="https:&#x2F;&#x2F;flowchart.fun&#x2F;" rel="nofollow">https:&#x2F;&#x2F;flowchart.fun&#x2F;</a> [1]: <a href="https:&#x2F;&#x2F;sourcetarget.email&#x2F;editions&#x2F;43&#x2F;" rel="nofollow">https:&#x2F;&#x2F;sourcetarget.email&#x2F;editions&#x2F;43&#x2F;</a>
评论 #31280899 未加载
gertlex大约 3 年前
I come from past experiments with (py)graphviz, yed, probably a couple other forgotten things. (As well as manual diagrams in LucidChart and even Inkscape.) And am generally a non-web python guy.<p>I was looking at Mermaid last weekend, since a coworker has praised it a few times and I was wanting to play with it.<p>I think my expectation of how to use it was wrong? I typically expect to share my diagrams as .png files. The main documentation didn&#x27;t seem to give much guidance in this usecase.<p>I ended up going to <a href="https:&#x2F;&#x2F;github.com&#x2F;mermaid-js&#x2F;mermaid-cli" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mermaid-js&#x2F;mermaid-cli</a> ... there didn&#x27;t seem to be a simple install-and-use pathway similar to `apt` or `pip`, so I ended up trying the docker image for it. I got it working to create pngs, but I thought having to mess with docker volume mounts and defining my own aliases (`alias mermaid=&#x27;docker run -u $UID -it --rm -v ~&#x2F;mermaid:&#x2F;data minlag&#x2F;mermaid-cli -i&#x27;` so I can do `mermaid blah.mmd` in my ~&#x2F;mermaid folder) was a bit cumbersome...<p>Just sharing to see if there&#x27;s hot takes on where I went wrong, I guess. (for example, I certainly didn&#x27;t extensively read the docs to understand the usage paradigm it&#x27;s intended for)
评论 #31274412 未加载
评论 #31274776 未加载
评论 #31274924 未加载
prepend大约 3 年前
I’m such a huge fan of mermaid and use it in all my architecture markdown sites.<p>I was excited when GitHub enabled mermaid in their markdown preview. But weird that they still don’t support it in GitHub pages. I wish they would do this as being able to use mermaid in the default pages sites will be really nice. I’m currently not able to convince scientists I work with to set up their own static site generation instead of pages, just to get mermaid working.
arbitrage大约 3 年前
Mermaid is useful for small diagrams with a few elements.<p>When I try to create large diagrams with lots of linkages and text, my laptop fans kick in, and the battery starts draining. I use a reasonably beefy macbook pro as my daily driver.
评论 #31274270 未加载
评论 #31274472 未加载
shafoshaf大约 3 年前
One thing I didn&#x27;t see mentioned here is that mermaid makes creating charts programmatically very simple. We have a ton of workflows that are basically FSAs. We use Mermaid to create visuals of the workflows on the fly. Change it in code and the docs auto update.<p>Also, VisualStudio.com supports Mermaid as well.
happymellon大约 3 年前
A few times a team member has tried to get everyone on board with Mermaid.<p>In the end draw.io&#x2F;diagrams.net wins out as embeds the diagram in the header of a PNG, so it can be rendered by everything and edited in many ways, including the web, the desktop app or the VS Code plug in.
User23大约 3 年前
Interested Emacs users should check out ob-mermaid[1]. It’s an org babel extension that lets you inline mermaid diagrams in org documents.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;arnm&#x2F;ob-mermaid" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;arnm&#x2F;ob-mermaid</a>
acidburnNSA大约 3 年前
I made a fun chart tracing energy from the Big Bang to modern primary sources in Mermaid JS because it was so fun and easy. [1]<p>Then a guy on twitter and his son remixed it graphically into something truly artistic. [2]<p>I thank Mermaid for the overall experience b&#x2F;c it let somewhat complex concepts be shown so clearly that they could be immediately understood.<p>[1] <a href="https:&#x2F;&#x2F;whatisnuclear.com&#x2F;energy-flow.html" rel="nofollow">https:&#x2F;&#x2F;whatisnuclear.com&#x2F;energy-flow.html</a><p>[2] <a href="https:&#x2F;&#x2F;i.imgur.com&#x2F;SJjRaGH.jpg" rel="nofollow">https:&#x2F;&#x2F;i.imgur.com&#x2F;SJjRaGH.jpg</a>
a4isms大约 3 年前
Mermaid is particularly easy to embed in online web pages. Naturally, the most robust thing to do is generate a .png and embed that. But if you write in Markdown and have a rendering tool that directly supports Mermaid, you can add your Mermaid directly to the Markdown source that you check into git.<p>And even if you don&#x27;t have direct tooling support for Mermaid, you can render it in the browser using JavaScript. For example:<p><a href="https:&#x2F;&#x2F;raganwald.com&#x2F;2019&#x2F;09&#x2F;21&#x2F;regular-expressions.html#finite-state-recognizers-1" rel="nofollow">https:&#x2F;&#x2F;raganwald.com&#x2F;2019&#x2F;09&#x2F;21&#x2F;regular-expressions.html#fi...</a><p>The markdown is:<p><pre><code> # Finite-State Recognizers If we&#x27;re going to compile regular expressions to finite-state recognizers, we need a representation for finite-state recognizers. There are many ways to notate finite-state automata. For example, state diagrams are particularly easy to read for smallish examples: &lt;div class=&quot;mermaid&quot;&gt; stateDiagram [*] --&gt; start start --&gt; zero : 0 start --&gt; one : 1 one --&gt; one : 0, 1 zero --&gt; [*] one --&gt; [*] &lt;&#x2F;div&gt; Of course, diagrams are not particularly easy to work with in JavaScript. If we want to write JavaScript algorithms that operate on finite-state recognizers, we need a language for describing finite-state recognizers that JavaScript is comfortable manipulating. </code></pre> IMO, the best way to use it is within a format you&#x27;re already checking into git, and if you can, use a tool that compiles your diagrams into an embedded SVG at rendering time.<p>But even if your toolchain doesn&#x27;t make this easy, it&#x27;s still flexible enough to get the job done.
评论 #31275754 未加载
floverfelt大约 3 年前
Shameless plug, but I used mermaid.js to create a pom visualizer maven plugin [0] and it was honestly pretty great.<p>Like some of the other comments say (and after working with it quite a bit) it definitely has its warts. It&#x27;s not super well documented, it&#x27;s not as feature rich as I&#x27;d like, and the syntax can be a little wonky. All that said, it &quot;just works&quot; for creating simple visualizations and fit my use case near perfectly.<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;floverfelt&#x2F;pom-visualizer-maven-plugin" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;floverfelt&#x2F;pom-visualizer-maven-plugin</a>
tehwebguy大约 3 年前
I use Mermaid every week or so, it’s very cool.<p>It’s choices on where to position things are often infuriating but every visual flowchart builder has been a huge pain IMO so a text based one is super preferable even with the limitations.
arminiusreturns大约 3 年前
I&#x27;m pretty obsessed with diagrams as code and unfortunately while I liked the visuals produced by Mermaid I found some major limitations with it on my last comparison test a few months ago. I think it might just need to mature a little bit and then will probably be a solid choice. More of a greybeard sysadmin thing, but I usually refuse to install npm things locally so thats another issue for others who feel the same.<p>What I use myself and suggest to others these days is first and foremost blockdiag and its variants (nwdiag, seqdiag, rackdiag, etc), and the very descriptive python &quot;diagrams&quot;.
99_00大约 3 年前
Is there any way to embed diagrams in code comments and have it render in any IDE or source code hosting platform?<p>Am I wrong for wanting this?
评论 #31276589 未加载
pietroppeter大约 3 年前
as a related piece of new of today [0]:<p>&gt; The @github Markdown Preview extension for VS Code now includes Mermaid support!<p>and since Nim also made front page today I will share how I added mermaid.js support in my very own nimib project some time ago [1].<p>[0]: <a href="https:&#x2F;&#x2F;twitter.com&#x2F;mattbierner&#x2F;status&#x2F;1522003140777701376" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;mattbierner&#x2F;status&#x2F;1522003140777701376</a> [1]: <a href="https:&#x2F;&#x2F;pietroppeter.github.io&#x2F;nblog&#x2F;drafts&#x2F;mermaid_diagram.html" rel="nofollow">https:&#x2F;&#x2F;pietroppeter.github.io&#x2F;nblog&#x2F;drafts&#x2F;mermaid_diagram....</a>
jedimastert大约 3 年前
My first contact with Mermaid was in Typora, and it always worked well enough for me.
评论 #31279451 未加载
eternityforest大约 3 年前
Github has the best Markdown implementation I&#x27;ve ever seen.<p>Looking forward to this being available in more places, I&#x27;ll probably start using it in my documentation.
fallingmeat大约 3 年前
Anyone know if Activity diagrams can be made in this way? (Note activity diagrams are not exactly flow charts, they have some rules)
评论 #31278030 未加载
Veuxdo大约 3 年前
Mermaid (and plantUML) are great for simple diagrams. They aren&#x27;t model-based though, so sharing resources across many views isn&#x27;t possible. If you are looking for something more robust, consider something model-based like Ilograph: <a href="https:&#x2F;&#x2F;app.ilograph.com&#x2F;demo.ilograph.AWS%2520Distributed-Load-Testing&#x2F;__overview" rel="nofollow">https:&#x2F;&#x2F;app.ilograph.com&#x2F;demo.ilograph.AWS%2520Distributed-L...</a>
评论 #31278399 未加载
kimi大约 3 年前
Elixir&#x27;s ex-doc lets you embed Mermaid directly, <i>and</i> generate it on the fly through a function.
eptcyka大约 3 年前
How would this be different from plantuml?
评论 #31275575 未加载
nickmain大约 3 年前
Is anyone working on adding Mermaid support to Swift&#x27;s DocC ?
macgyverismo大约 3 年前
earnest question; why would I use this instead of graphviz?
评论 #31274324 未加载
评论 #31274177 未加载
评论 #31274304 未加载
评论 #31276162 未加载
评论 #31274084 未加载
tamiral大约 3 年前
I learned about this last week and I am so impressed.
aliswe大约 3 年前
still no topological charts though:(
评论 #31277910 未加载
oicU00大约 3 年前
There are Go and Python based packages for diagrams as well:<p><a href="https:&#x2F;&#x2F;diagrams.mingrammer.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;diagrams.mingrammer.com&#x2F;</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;blushft&#x2F;go-diagrams" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;blushft&#x2F;go-diagrams</a>