Documentation
¶
Overview ¶
Package termmd renders Markdown for a terminal as it streams in.
A Renderer buffers text until a block is complete (a paragraph ends at a blank line, a fence at its closing line, a list item at the next item) and then writes that block once, wrapped to the width, so streamed text never re-renders. Flush writes whatever is still buffered, so a stream that ends mid-block loses nothing. With Color off the output has no escape codes but keeps the structure: indentation, bullets, code-block borders and table columns.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RuneWidth ¶
RuneWidth is the number of terminal columns r takes: 0 for controls and combining marks, 2 for East Asian wide and fullwidth characters and most emoji, 1 otherwise. It is a small table, not a full UAX #11 implementation, but covers CJK, Hangul, kana, fullwidth forms and emoji.
func StringWidth ¶
StringWidth is the number of terminal columns s takes. s must not hold escape sequences.
func SupportsHyperlinks ¶
SupportsHyperlinks reports whether the terminal described by getenv clearly renders OSC 8 hyperlinks. Unknown terminals, tmux and screen get false: there the escape can show up as garbage.
Types ¶
type Options ¶
type Options struct {
Width int // columns to wrap to; under 20 means 80
Color bool // ANSI styles and Unicode borders and bullets
Hyperlinks bool // OSC 8 links (only with Color)
}
Options configure a Renderer.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer turns streamed Markdown into terminal text. It is not safe for concurrent use.