Diagrams

edit

Diagram languages, such as Mermaid, describe flowcharts, sequences or classes as text, which fits in a Markdown document. Diagrams renders their code blocks as the elements that the scripts of these languages look for: a code block of mermaid is rendered as <pre class="mermaid">, and one of nomnoml as <div class="nomnoml">. Add the script of the language to the page to draw the diagrams.

var options = new MarkdownParseOptions { Extensions = MarkdownExtensions.Diagrams };
var tree = MarkdownSyntaxTree.ParseText("```mermaid\ngraph LR\n  A --> B\n```\n\n```nomnoml\n[A]->[B]\n```\n", options);

Assert.Equal("<pre class=\"mermaid\">graph LR\n  A --> B\n</pre>\n<div class=\"nomnoml\">[A]->[B]\n</div>\n", MarkdownHtmlRenderer.ToHtml(tree));

The syntax tree does not change: the diagrams are MarkdownCodeBlockSyntax nodes, whose Language is mermaid or nomnoml.