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]
END

Translate to Raku:

use MermaidJS::Grammar;
$spec ==> mermaid-js-interpret

Translate 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 --help

References

[AAp1] Anton Antonov, Graphviz::DOT::Grammar. Raku package, (2024), GitHub/antononcube.

MermaidJS::Grammar v0.0.2

Grammar for parsing Mermaid-JS language specs and converting them to specs of Graphviz DOT, JSON, PlantUML, Raku, or Wolfram Language.

Authors

  • Anton Antonov

License

Artistic-2.0

Dependencies

JSON::Fast

Test Dependencies

Provides

  • MermaidJS::Actions::GraphvizDOT
  • MermaidJS::Actions::JSON
  • MermaidJS::Actions::PlantUML
  • MermaidJS::Actions::Raku
  • MermaidJS::Actions::WL::Association
  • MermaidJS::Actions::WL::Graph
  • MermaidJS::Grammar
  • MermaidJS::Grammarish

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.