Dispatch module for rendering MF2 highlight tokens.
Delegates to one of the format-specific formatter modules based on
the :format option:
:plain— plain text, discards classes. Used internally to produce the canonical MF2 string from a token stream.:html— HTML with per-token<span>wrappers. SeeLocalize.Message.Formatter.HTML.:ansi— ANSI-coloured terminal output. SeeLocalize.Message.Formatter.ANSI.
Summary
Functions
Renders a token list in the chosen format.
Types
Functions
@spec render([Localize.Message.Highlighter.token()], format(), Keyword.t()) :: String.t() | {:error, Exception.t()}
Renders a token list in the chosen format.
Arguments
tokensis a list oft:Highlighter.token/0tuples.formatis one of:plain,:html, or:ansi.optionsis a keyword list of format-specific options.
Returns
- A rendered string.
Examples
iex> {:ok, ast} = Localize.Message.Parser.parse("Hello {$name}!")
iex> tokens = Localize.Message.Highlighter.to_tokens(ast)
iex> Localize.Message.Formatter.render(tokens, :plain)
"Hello {$name}!"