# `AshWorkflow.Charts.Mermaid`
[🔗](https://github.com/team-alembic/ash_workflow/blob/v0.12.0/lib/ash_workflow/charts/mermaid.ex#L1)

Draws an `AshWorkflow.Charts.Graph` as a Mermaid `stateDiagram-v2`.

GitHub, Livebook and ExDoc (with the script this library's own docs use)
show the result without other tools.

* Each step is declared as `state "review" as step_review`. The `step_`
  prefix keeps a step name such as `:note` or `:end` from being read as a
  Mermaid keyword. A character outside `A-Z`, `a-z`, `0-9` and `_` becomes
  `_` and its code point in hex. `render/2` raises `ArgumentError` if two
  step names still map to one ID, such as `:"re-open"` and `:re_2Dopen`.
* Each step that is not terminal has a description line with its kind:
  `⚙️ automatic`, `✋ manual` or `⏳ wait state`. The gear carries
  U+FE0F, so it draws as a colour emoji, the same as the other two.
* The initial step has an edge from `[*]`, and every terminal step has an
  edge to `[*]`.
* An edge label starts with a symbol for its kind: `⚙` for `on_success`,
  `✖` for `on_error`, `📨` for an `on_signal`, `⏱` for a timeout and `↶`
  for undo. A transition has no symbol. A timeout edge gives the timeout's
  name and then its deadline, as in `⏱ escalation after 7 days`. A
  conditional route adds `when` and its condition, and the fallback route
  of a conditional `on_success` adds `otherwise`.
* A step's notes go in a `note right of` block: `policy:`, `retry:`, `⏱` for
  a timeout that runs an action, `↻` for an `every`, and `📨` for an
  `on_signal` that runs an action.

A state diagram cannot draw a dashed or dotted edge, which is why the edge
kind is in the label. The characters `#`, `;`, `<`, `>`, `"` and `\` are written
as Mermaid entity codes, such as `#60;` for `<`, so a condition such as
`score < 3` cannot break the diagram. A `:` is written as `#58;` when another
`:` follows it or when it ends the text, because Mermaid's label lexer stops
at `::` and at a final `:`. A single `:` inside text, as in `:reviewer`,
needs no code.

This backend takes no options.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
