Converts token lists to ANSI-formatted terminal output.
Uses ChunkText as intermediate representation so colors and effects
are resolved through Pote's theme system — same pipeline that
Alaja.print_success, Alaja.Components.Table etc. already use.
Summary
Functions
Renders a token list into display-ready {color, text} tuples.
Renders tokens to ANSI escape sequences ready for terminal output.
Renders token list as a flat string (no ANSI escapes). Useful for testing or non-terminal output.
Functions
@spec render( [{atom(), String.t()}], Alaja.Syntax.Language.t(), Alaja.Syntax.Theme.t() | nil ) :: [ {String.t(), String.t()} ]
Renders a token list into display-ready {color, text} tuples.
Each tuple's color is an ANSI color string resolved through the theme chain:
- Language-level colors (
lang.colors) - Global syntax theme
- Hardcoded defaults
Examples
iex> lang = %Alaja.Syntax.Language{
...> name: "test",
...> colors: %{keyword: {:blue, [:bold]}}
...> }
iex> Renderer.render([{:keyword, "def"}, {:plain, " x"}], lang)
[{"blue", "def"}, {"white", " x"}]
@spec render_ansi( [{atom(), String.t()}], Alaja.Syntax.Language.t(), Alaja.Syntax.Theme.t() | nil ) :: iodata()
Renders tokens to ANSI escape sequences ready for terminal output.
Uses ChunkText.render/1 under the hood, which resolves colors
through Pote's resolver bridge (supports atoms, hex, "theme:key",
etc.) and applies effects (bold, italic, etc.).
Renders token list as a flat string (no ANSI escapes). Useful for testing or non-terminal output.