Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display Mermaid diagram from C# variable in Polyglot notebook

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
like image 960
Piotr Jakóbczyk Avatar asked Sep 12 '25 03:09

Piotr Jakóbczyk


1 Answers

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

like image 151
ATK Avatar answered Sep 13 '25 19:09

ATK