mdrender

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package mdrender renders markdown to terminal-styled output using the shared entire CLI palette (orange H1, cyan H2, indigo H3, plus chroma syntax highlighting). Used by `entire dispatch`, `entire review`, and any other command that prints LLM-generated markdown to the terminal.

Two entry points:

  • Render: pure function — caller supplies width and background hint.
  • RenderForWriter: TTY-aware — renders to a terminal writer with auto-detected width; passes raw markdown through when w is not a terminal (so redirected output is grep-friendly, not full of ANSI).

Index

Constants

View Source
const DefaultTerminalWidth = 80

DefaultTerminalWidth caps glamour word-wrap when no real terminal width is available. Matches the cap used by status_style.getTerminalWidth.

Variables

This section is empty.

Functions

func Render

func Render(markdown string, width int, darkBackground bool) (rendered string, err error)

Render produces a glamour-styled string from markdown using the entire CLI palette. width is the word-wrap target; darkBackground selects the dark or light palette variant.

Errors only on glamour renderer construction or render failure — both of which indicate a malformed StyleConfig (programmer error) rather than a runtime condition. Renderer panics are recovered and returned as errors so callers can fall back to raw markdown instead of crashing.

func RenderForWriter

func RenderForWriter(w io.Writer, markdown string) (string, error)

RenderForWriter renders markdown when w is a terminal writer, and returns the input unchanged otherwise. NO_COLOR=1 also disables rendering so pipelines that grep through redirected output work without unwrapping ANSI escape sequences.

Width is auto-detected from w (capped at 80); background palette is detected via termenv.HasDarkBackground.

Types

This section is empty.

Jump to

Keyboard shortcuts

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