markdown

package
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package markdown renders the final assistant answer as styled terminal output. It is the one markdown renderer in the program: Writer.Assistant is the only caller in non-test code.

Rendering never fails a turn. Render returns the styled answer, or the input unchanged when the input is empty, oversized, or the renderer errors. Whether to render at all is decided by the caller (see ui.Writer), so this package does no TTY or environment checks itself: Render always styles, which also keeps it deterministic under test.

Index

Constants

View Source
const MaxInputBytes = 256 * 1024

MaxInputBytes caps the answer Render will style. Above it the raw markdown goes through unchanged: a huge report still prints, it just does not get colors. 256 KiB is far above any report worth styling line by line, and glamour on a pathological input must not stall a turn.

Variables

This section is empty.

Functions

func Render

func Render(src string, width int) string

Render styles src as terminal markdown wrapped at width, using the program's dark-derived style (blue bold headings, gray-background inline code, full-width prose). It returns src unchanged on empty input, oversized input, or any renderer error.

Types

type Mode

type Mode string

Mode selects when the final answer is styled.

const (
	// ModeAuto styles only on a terminal: stdout is a TTY and neither
	// NO_COLOR nor TERM=dumb opts out. Piped output stays raw markdown.
	ModeAuto Mode = "auto"

	// ModeAlways styles even when piped. Explicit opt-out; scripts that
	// parse stdout should keep the default.
	ModeAlways Mode = "always"

	// ModeNever prints raw markdown, exactly as before rendering existed.
	ModeNever Mode = "never"
)

func ParseMode

func ParseMode(s string) Mode

ParseMode normalizes a config value. Empty and unknown values are auto, so an unset ui.markdown keeps today's default behavior.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL