2

I know that Polyglot notebooks support Mermaid diagrams. But it doesn't support veriable sharing. Suppose I have diagram code in C# string variable. Are there any possibility to display that string as diagram?

Example:

// below diagram code was generated via some method
var mermaidCode = """
flowchart TD
    A --> B
""";

// here I would like to display mermaidCode as diagram
mermaidCode

1 Answers1

3

Its litle late, but you can do this.

1 - generate a "mermaid" cell with

using Microsoft.DotNet.Interactive; 
using Microsoft.DotNet.Interactive.Commands;
    
await Kernel.Root.SendAsync(new SendEditableCode("mermaid", <yourMarkdown>));

2 - run the new generated cell

ATK
  • 46
  • 2
  • If you use ``Kernel.Root.SendAsync(new SubmitCode("mermaid", ""))`` instead, it will run the mermaid output instead of generating a new cell each time. – sidney.andrews Jun 01 '23 at 16:07