Skip to content
docsv0.3.0

MarkdownRenderer

Renders a pragmatic markdown subset to plain text lines, leaving ANSI styling to the final `TuiAnsiPainter` pass. The TUI analog of pi-tui's `Markdown`. Supports the constructs that matter in a terminal dashboard or agent transcript: ATX headings (`#`, `##`, `###`), paragraphs with word wrapping, unordered lists (`-`/`*`/`+`), ordered lists (`1.`), blockquotes (`>`), thematic breaks (`---`), fenced code blocks (` ``` `), and inline emphasis (`**bold**`, `*italic*`, `_italic_`, `` `code` ``). HTML tags are stripped to their text content. Inline emphasis is rendered as ANSI SGR codes directly in the line so the diff buffer carries the styling through without a second pass — `TuiAnsiPainter` is glyph-only by design and would not know how to paint a bold word. The renderer emits `\033[1m`/`\033[3m`/`\033[0m` and trusts the theme's final reset to clean up. Node props (all optional): - `content` string The markdown source. Alias: `text`. - `padding` int Horizontal padding. Default: 0. - `paddingX` int Override horizontal padding. Default: 0. - `paddingY` int Vertical padding (top + bottom). Default: 0. - `wrap` bool Word-wrap paragraphs/list items. Default: true. - `scrollToBottom` bool Anchor overflowing content to the latest lines. Default: false. - `scrollFromBottom` int Lines to move back from the latest viewport. Default: 0.

MarkdownRenderer::supports()

public function supports(Milpa\Live\ValueObjects\Tui\TuiNode $node): bool

True only for `markdown` nodes — dispatch is by declared node type, never by where the node came from.

Parameters

Parameters of supports()
NameTypeDescription
$nodeMilpa\Live\ValueObjects\Tui\TuiNode

MarkdownRenderer::render()

public function render(Milpa\Live\ValueObjects\Tui\TuiNode $node, Milpa\Live\ValueObjects\Tui\TuiRenderContext $context): Milpa\Live\ValueObjects\Tui\TuiFrame

Parses the `text` prop and returns the rendered block lines.

Parameters

Parameters of render()
NameTypeDescription
$nodeMilpa\Live\ValueObjects\Tui\TuiNode
$contextMilpa\Live\ValueObjects\Tui\TuiRenderContext