Ascii.Mermaid (Ascii v0.3.0)

Copy Markdown View Source

Parses a documented subset of Mermaid into native Ascii.Diagrams.

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.

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

Summary

Functions

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

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

Parses and renders source as a standard frame.

Types

error()

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

Functions

compile(source, opts \\ [])

@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(source)

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

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

render(source, opts \\ [])

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

Parses and renders source as a standard frame.