Documentation
¶
Overview ¶
Package mdtext converts light Markdown into the two forms OpenPanda's surfaces need beyond a rendered web page:
- Plain: readable prose for TTS (the voice pipeline) and for pipes / logs — emphasis markers, link syntax and fence markers are dropped, table rows become comma-separated values.
- ANSI: a terminal-friendly render for TTYs — headings become bold cyan, bold/italic/code keep their emphasis via SGR, tables stay column-aligned.
It is a small line-oriented state machine, not a full Markdown parser: model answers are light Markdown (headings, lists, tables, fenced code, emphasis), and the goal is that nothing reads worse than it would as raw text. A gofmt-style fenced block passes through untouched (plain) or dim (ANSI); anything unrecognized is kept verbatim.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ANSI ¶
ANSI renders Markdown with SGR emphasis for color TTYs: headings bold cyan, fenced code dim, bold→bold, code→dim, italic→italic, tables column-aligned, lists and quotes kept. When the caller already knows the sink is not a TTY it should use Plain instead.
func IsFenceStart ¶
IsFenceStart reports whether a line opens or closes a fenced code block (``` markers); streaming line renderers track fence state with this and pass lines through untouched inside a fence.
func LineANSI ¶
LineANSI renders one Markdown line with SGR emphasis (see ANSI). fence selects code-block pass-through. It is stateless so a stream can render line by line as deltas arrive.
func LinePlain ¶
LinePlain renders one Markdown line as plain text (see Plain). fence selects code-block pass-through.
func Plain ¶
Plain strips Markdown syntax for speech and plain-text sinks: headings keep their text, emphasis and link markers drop out, fenced code stays verbatim, tables flatten to comma-separated cells, list bullets become "• " and horizontal rules become "—".
func Render ¶ added in v0.0.8
Render formats s into rich terminal Markdown using Glamour with automatic dark/light styling and word wrap to width columns. If width <= 0, word wrap is disabled. If Glamour fails or cannot format, it gracefully falls back to ANSI(s).
func RenderTerminal ¶ added in v0.0.8
RenderTerminal formats s for terminal display. If NO_COLOR is set, it falls back to Plain(s). Otherwise it renders via Glamour with word wrapping fitted to the terminal width (default 80, capped at 120 cols for reading comfort).
Types ¶
This section is empty.