Converts agent assistant messages to styled text runs for the GUI.
Uses a hybrid approach:
- Regex-based Markdown parser for structure (headers, bold, italic,
inline code, lists, blockquotes, rules). This strips syntax markers
so the GUI shows clean rendered text, not raw
**or##. - Tree-sitter highlights overlaid on fenced code block content. This gives per-language syntax highlighting (Elixir, Python, etc.) inside code blocks, which the regex parser can't do.
The regex path always runs. Tree-sitter is layered on top for code blocks only when highlight spans are available.
Summary
Types
A line of styled runs.
All styled lines for a message.
A single styled text run: {text, fg_rgb, bg_rgb, flags}.
Functions
Converts assistant message text to styled runs for the GUI.
Types
@type styled_line() :: [styled_run()]
A line of styled runs.
@type styled_lines() :: [styled_line()]
All styled lines for a message.
@type styled_run() :: {String.t(), non_neg_integer(), non_neg_integer(), non_neg_integer()}
A single styled text run: {text, fg_rgb, bg_rgb, flags}.
Functions
@spec stylize( String.t(), MingaEditor.UI.Highlight.t() | nil, map(), non_neg_integer() ) :: styled_lines()
Converts assistant message text to styled runs for the GUI.
Always uses the regex-based Markdown parser for structure (strips syntax markers). When tree-sitter highlights are available, overlays per-language syntax highlighting onto fenced code block content lines.
buffer_byte_offset is the starting byte offset of this message's
text within the full *Agent* buffer. Required for aligning
tree-sitter spans (which reference the full buffer) with per-message
line content.