Search documentation of Localize

# Localize.Message.Formatter (Localize v0.39.0)

Copy Markdown View Source

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. See `Localize.Message.Formatter.HTML`.

- `:ansi` — ANSI-coloured terminal output. See `Localize.Message.Formatter.ANSI`.

## Summary

### Types

format()

### Functions

render(tokens, format, options \\ [])

Renders a token list in the chosen format.

## Types

# format()

    @type format() :: :plain | :html | :ansi

## Functions

# render(tokens, format, options \\ [])

    @spec render([Localize.Message.Highlighter.token()], format(), Keyword.t()) ::
      String.t()

Renders a token list in the chosen format.

### Arguments

- `tokens` is a list of `t:Highlighter.token/0` tuples.

- `format` is one of `:plain`, `:html`, or `:ansi`.

- `options` is a keyword list of format-specific options.

### Returns

- A rendered string.