# `Ascii.Mermaid`
[🔗](https://github.com/houllette/ascii_art/blob/main/lib/ascii/mermaid.ex#L1)

Parses a documented subset of Mermaid into native `Ascii.Diagram`s.

Supports flowcharts, sequences and C4 context/container/component views.
Unsupported statements are errors, with source line and column; they are
never silently ignored. This is a character renderer with its own layout,
rather than pixel or layout parity with Mermaid's SVG output. See the
[support matrix](guides/diagrams.md#mermaid-support).

    iex> {:ok, frame} = Ascii.Mermaid.render("flowchart LR\nA[Hello] --> B[World]")
    iex> frame.text =~ "World"
    true

# `error`

```elixir
@type error() ::
  Ascii.Diagram.error()
  | {:error, {:invalid_source, :type | :size | :encoding | :statements}}
  | {:error, {:syntax, pos_integer(), pos_integer(), String.t()}}
```

# `compile`

```elixir
@spec compile(source :: String.t(), opts :: keyword()) ::
  {:ok, Ascii.Diagram.Layout.t()} | error()
```

Parses and lays out once; retain the layout for repeated drawing or hit testing.

# `parse`

```elixir
@spec parse(source :: String.t()) :: {:ok, Ascii.Diagram.t()} | error()
```

Parses at most 64 KiB of source, without the piece options' string truncation.

# `render`

```elixir
@spec render(source :: String.t(), opts :: keyword()) ::
  {:ok, Ascii.Frame.t()} | error()
```

Parses and renders source as a standard frame.

---

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