Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get an image corresponding to a Mermaid-JS specification via the web Mermaid-Ink interface of Mermaid-JS
ResourceFunction["MermaidInk"][s] retrieves an image defined by the spec s from Mermaid's Ink Web interface. |
"TB" | top-to-bottom |
"TD" | top-down |
"BT" | bottom-to-top |
"RL" | right-to-left |
"LR" | left-to-right |
Generate a flowchart from a Mermaid specification:
In[1]:= |
Out[1]= |
Create a Graphics expression from a class diagram:
In[2]:= |
Out[2]= |
The first argument can be a Graph object -- the corresponding Mermaid-JS graph is produced. Here is a random graph that has both directed and undirected edges (some edges have tags):
In[3]:= |
Out[6]= |
Here is the corresponding Mermaid-JS image:
In[7]:= |
Out[7]= |
Here is a left-to-right version:
In[8]:= |
Out[8]= |
Very often Large Language Models (LLMs) produce Mermaid-JS code as a Markdown fenced code block. By default the fences are removed. Here we define a Mermaid-JS specification:
In[9]:= |
Out[9]= |
Here we generate the corresponding diagram:
In[10]:= |
Out[10]= |
Create a Sequence Diagram:
In[11]:= |
Out[11]= |
State diagram:
In[12]:= |
Out[12]= |
Entity Relationship Diagram:
In[13]:= |
Out[13]= |
User Journey -- PNG image is obtained and cropped:
In[14]:= |
Out[14]= |
Gantt chart:
In[15]:= |
Out[15]= |
Pie chart:
In[16]:= |
Out[16]= |
Requirement Diagram:
In[17]:= |
Out[17]= |
Very often Large Language Models (LLMs) produce Mermaid-JS code as a Markdown fenced code block. By default the fences are removed:
In[18]:= |
Out[18]= |
Without dropping the Markdown code block fences we get an error:
In[19]:= |
Out[19]= |
The option "MermaidDirectives" is used when the first argument is a Graph object:
In[20]:= |
Out[21]= |
Create a Markdown-related conversions flowchart:
In[22]:= |
Out[22]= |
Create a Sequence Diagram for a blogging app service communication:
In[23]:= |
There is a fairly straightforward correspondence between the edge specifications for Graph and Mermaid graph (or flowchart) specifications:
In[24]:= |
Out[24]= |
In[25]:= |
Out[25]= |
In[26]:= |
Out[26]= |
A diagram that clarifies the execution of MermaidInk:
In[27]:= |
Out[27]= |
For some textual content MermaidInk specifications should use quotes. Also, a new line character in text can be included using "<br/>":
In[28]:= |
Out[28]= |
Without the quotes for block "A" the specifications above does not work:
In[29]:= |
Out[29]= |
Larger flowchart with some styling:
In[30]:= |
Out[30]= |
Some interesting interaction:
In[31]:= |
Out[31]= |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License