Jido.Chat.Markdown.StreamRenderer (Jido Chat v1.2.0)

Copy Markdown View Source

Builds safe Markdown snapshots from an incremental, provider-independent stream.

The renderer keeps the original text. push/2 can return a repaired snapshot for an in-progress edit. flush/1 returns stable final Markdown and keeps complete, supported Markdown exact. Possible table headers and partial table rows are held until their structure is known.

Summary

Functions

Adds one chunk without calculating a partial snapshot.

Returns stable final Markdown, or nil when there is no visible text.

Creates an empty streaming Markdown renderer.

Adds one text or structured stream chunk and returns a changed safe snapshot.

Renders a finite stream to its exact final Markdown fallback.

Returns the current safe replacement snapshot without changing state.

Types

t()

@type t() :: %Jido.Chat.Markdown.StreamRenderer{
  exact_snapshot?: boolean(),
  parts: [iodata()],
  snapshot: String.t() | nil
}

Functions

append(renderer, chunk)

@spec append(t(), term()) :: t()

Adds one chunk without calculating a partial snapshot.

flush(renderer)

@spec flush(t()) :: String.t() | nil

Returns stable final Markdown, or nil when there is no visible text.

new()

@spec new() :: t()

Creates an empty streaming Markdown renderer.

push(renderer, chunk)

@spec push(t(), term()) :: {t(), String.t() | nil}

Adds one text or structured stream chunk and returns a changed safe snapshot.

render(chunks)

@spec render(Enumerable.t()) :: String.t() | nil

Renders a finite stream to its exact final Markdown fallback.

snapshot(stream_renderer)

@spec snapshot(t()) :: String.t() | nil

Returns the current safe replacement snapshot without changing state.