PhoenixStreamdown.Remend (PhoenixStreamdown v1.0.0-beta.4)

Copy Markdown View Source

Completes incomplete markdown syntax during streaming.

When LLMs stream markdown token-by-token, you get partial formatting: unclosed **bold, half-open code fences, partial [links](. This module auto-closes those constructs so the markdown parser produces valid output.

Operates on raw strings before they reach the parser — no AST, no dependencies.

Summary

Functions

Completes incomplete markdown syntax in the given text.

Functions

complete(text)

@spec complete(String.t()) :: String.t()

Completes incomplete markdown syntax in the given text.

iex> PhoenixStreamdown.Remend.complete("**bold text")
"**bold text**"

iex> PhoenixStreamdown.Remend.complete("```elixir\nIO.puts")
"```elixir\nIO.puts\n```"