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

Add markdown support for diagrams using js-sequence style blocks #228

Open
jcollins-g opened this issue Jul 9, 2018 · 5 comments
Open
Labels
type-enhancement A request for a change that isn't a bug

Comments

@jcollins-g
Copy link
Contributor

Allowing inline diagram support from comment text to markdown (and indirectly, dartdoc), would be a nice thing to have for doc writers, so they don't have to have opaque image links in the source code when a simple diagram would suffice.

https://support.typora.io/Draw-Diagrams-With-Markdown
https://github.com/bramp/js-sequence-diagrams

@srawlins
Copy link
Member

srawlins commented Jul 9, 2018

Isn't this something that could be done (or would have to be done) as a post processing? Like the js-sequence library would, in the browser, find HTML like <pre class="language-sequence">...</pre>, and turn it into an image/svg/mathml/whatever?

@jcollins-g
Copy link
Contributor Author

@srawlins I don't know enough javascript to know without some research, but that doesn't sound unreasonable. In that case all markdown would need to do is generate that when it sees the appropriate markdown and leave it to the js-sequence library?

@srawlins
Copy link
Member

srawlins commented Jul 9, 2018

Yeah, I think Markdown provides good enough support for this out-of-the-box:

$ cat a.md 
Text

```sequence
Alice->Bob: More text.
```
$ dart bin/markdown.dart a.md 
<p>Text</p>
<pre><code class="language-sequence">Alice-&gt;Bob: More text.
</code></pre>

So the js-sequence library could work on that output.

@srawlins
Copy link
Member

Mermaid might be the new way to do this. https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/ Supported on GitHub out of the box.

@timmaffett
Copy link
Contributor

I created a interop wrapper package for mermaid.js and have submitted a PR to illustrate the changes needed to the markdown example code to support mermaid diagrams.

Here is an example illustrating a number of Mermaid diagram types

See PR #429 for more details.

Mermaid was generally impressive, and in conjunction with Markdown seems to make a fast combo. You can see how fast real time editing in the example above is, even with an example of every diagram type re-rendering with every key stroke.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
3 participants