README-work
MermaidJS::Grammar
Raku package with a grammar for Mermaid-JS diagram specs.
Languages and formats Mermaid-JS is translated to:
DONE Raku
Translation to Raku hashmap structure with keys "nodes", "edges", and "styles".
DONE JSON
Simple JSON serialization from Raku-actions results.
DONE Graphviz DOT
TODO PlantUML
PlantUML uses DOT language, so, for flowcharts this should be a very short and easy format implementation based on DOT actions.
The current unfinished implementation tries to reuse the Raku actions. (Without good results.)
TODO Mathematica / Wolfram Language
DONE Basic vertexes and edges
TODO Vertex styles
TODO Edge styles
Currently, Only Mermaid-JS flowcharts are parsed and translated. Here is list of the parser implementation priorities (most important first):
Flowcharts
Class diagrams
Mind-maps
Sequence diagrams
ERD diagrams
A very similar Raku package is "Graphviz::DOT::Grammar", [AAp1].
Usage examples
Here is a Mermaid-JS spec:
my $spec = q:to/END/;
flowchart TD
A[Start] --> B{Decide}
B -->|Yes| C[Do thing]
B -->|No| D[Stop]
ENDTranslate to Raku:
use MermaidJS::Grammar;
$spec ==> mermaid-js-interpretTranslate to Graphviz DOT:
$spec ==> mermaid-js-interpret(a=>'DOT')Translate to Mathematica / Wolfram Language Graph:
$spec ==> mermaid-js-interpret(a=>'Mathematica')CLI
The package provides the Command Line Interface (CLI) script from-mermaid-js. Here is its usage message:
from-mermaid-js --helpReferences
[AAp1] Anton Antonov, Graphviz::DOT::Grammar. Raku package, (2024), GitHub/antononcube.