Documentation
¶
Overview ¶
Package mdrender renders Markdown for a terminal card: one glamour-backed implementation, styled from the theme package, so a Markdown message looks identical in every tuigoff app with no glamour import of its own.
Render falls back to the raw text on any renderer error, and the renderer constructor is a variable so a test can inject faults without a real glamour dependency.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NewTermRenderer = func(options ...glamour.TermRendererOption) (TermRenderer, error) { return glamour.NewTermRenderer(options...) }
NewTermRenderer constructs the glamour renderer Render uses. It is a var, not a plain function call, so a test can fault-inject either the constructor itself (return an error) or wrap the returned TermRenderer to fault-inject Render.
var Style = ""
Style selects glamour's built-in style by name (see glamour.WithStandardStyle: "dark", "light", "notty", "ascii", ...). Empty (the default) tracks theme.Dark automatically — a card's background comes from theme, so rendered markdown text must too, or it goes near-invisible on a light card (a dark-styled renderer defaulting to pale text over theme's light surface, the bug this replaced). Set Style explicitly only to pin a specific glamour style regardless of theme.Dark (e.g. "notty"/"ascii" for a non-colour terminal).
Functions ¶
func Render ¶
Render renders text as markdown at width, falling back to the raw text, trimmed of surrounding whitespace, on any renderer error — markdown rendering is a presentation nicety, never a reason to drop a response. It satisfies transcript.MarkdownRenderer's signature directly (pass mdrender.Render to chatshell.WithMarkdownRenderer / transcript. WithMarkdownRenderer).
Types ¶
type TermRenderer ¶
TermRenderer is the narrow seam Render needs from *glamour.TermRenderer — just the one method it calls — so a test can fault-inject both the constructor (via NewTermRenderer) and the render call itself without a real glamour dependency.