mermaid.sequence.parser.parse

mermaid.sequence.parser

parse(statements) -> script, err

Parse a sequence diagram's statements into a script

statements is what mermaid.source.statements returns after the sequenceDiagram header.

The script:

FieldHolds
participants{ id, label, kind } in order of first mention; kind is "participant" or "actor"
indexthe participants by id
eventsthe events in order
titlethe diagram's title as lines, or nil
autonumbertrue when messages are numbered

An event is one of:

kindFields
"message"from, to, line, head, tail, text, activate, deactivate
"activate", "deactivate"who
"note"side ("left", "right" or "over"), who (one id, or two for a note over a span), text
"open"tag (loop, opt, alt, par, critical, break or rect), text
"divider"tag (else, and or option), text
"close"none

A message's line is "solid" or "dotted", and its head is "arrow", "open", "cross" or nil. activate is set by a + after the arrow and starts an activation of the receiver; deactivate is set by a - and ends one of the sender. Every text is lines, and may be empty.

Returns nil and line N: reason for a statement outside the grammar, create and destroy, a message with no colon, a deactivate with no open activation, a divider outside its block, an end with no block, a block left open, a script with no participant, and one over 50 participants or 500 events.