moonrockz/diagrams-mermaid/printer

Values

print

fn print(diagram : @moonrockz/diagrams-mermaid/ast.Diagram) -> String

Canonical Mermaid text of diagram, with these rules:

  • The front matter comes first, then each directive on its own line, then sequenceDiagram.
  • Each statement is on its own line and ends with \n. Statements have two spaces of indentation for each level: one under the header, and one more in each frame and box.
  • Keywords are in lower case, except sequenceDiagram, accTitle and accDescr. title: text becomes title text.
  • A message is the sender, () when it has one before the arrow, the arrow as written, + or -, () when it has one after the arrow, the receiver, :, and a space and the text when the text is not empty.
  • Notes and link statements have the same : text form. Two note participants are joined by , without spaces.
  • A participant configuration is @{ and its text and }.
  • A - after an arrow that ends with -, such as /|-, has a space before it, because /|-- is another arrow.
  • A description with a line break (\n or \r) uses the accDescr { ... } form, with its lines as written; others use accDescr: text.
  • Comments are not printed, because the AST does not keep them.

Source