mdrender

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 5 Imported by: 0

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

View Source
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.

View Source
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

func Render(text string, width int) string

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

type TermRenderer interface {
	Render(string) (string, error)
}

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.

Jump to

Keyboard shortcuts

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