render

package
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Warmup

func Warmup()

Warmup pre-builds the renderer cache so the first page render inside the TUI doesn't pay chroma's syntax-highlighter init cost (~100ms).

Types

type Link struct {
	Target  string
	Display string
	Start   int // byte offset in Styled (start of the styled link span)
	End     int // byte offset in Styled (exclusive, end of the styled link span)
}

Link is one wiki-link occurrence inside the styled output.

Display is the user-visible link text (target or alias). It's exposed so the view layer can re-render the link with combined cursor + link styling in one pass — slicing Styled[Start:End] yields bytes that already contain SGR codes, and wrapping those produces nested resets that clobber the cursor highlight and any surrounding Glamour styling.

type Result

type Result struct {
	Styled string
	Links  []Link
	// Tasks holds the byte offset in Styled of each open task marker
	// (TODO/LATER/DOING/WAITING with non-empty text), in document order.
	// The index matches graph.TodoBullet.Ordinal so the view layer can
	// deep-link a dashboard todo to its rendered row.
	Tasks []int
	// Finds holds the byte offset in Styled of each highlighted emphasis-term
	// occurrence, in document order. Empty unless rendered with an emphasis term.
	Finds []int
}

Result is the rendered page.

func Render

func Render(body string, width int) (Result, error)

Render returns Glamour-rendered markdown with wiki-link positions annotated. width is the target terminal column count.

func RenderWithEmphasis

func RenderWithEmphasis(body string, width int, emphasis string) (Result, error)

RenderWithEmphasis is Render plus highlighting whole-word occurrences of emphasis (recorded in Result.Finds). emphasis == "" is identical to Render.

Jump to

Keyboard shortcuts

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