markdown

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package markdown supplies a glamour-backed tuikit.RenderFunc for tuikit.StreamingMarkdown, styled from a tuikit.Theme.

It is a separate package on purpose. A markdown engine is a large dependency — goldmark, chroma, an HTML sanitizer and a CSS parser — and the rest of tuikit needs none of it. Keeping it here means importing tuikit does not pull a markdown stack into a program that only wanted panels and tabs; only a program that imports this package links it.

Index

Constants

View Source
const DefaultSyntaxTheme = "tokyonight-night"

DefaultSyntaxTheme is the chroma stylesheet fenced code is highlighted with when no other is given. Chroma ships named stylesheets rather than taking colors, so a tuikit.Theme cannot drive highlighting the way it drives the rest of the styling — pick one that suits your palette with WithSyntaxTheme. The names come from chroma's styles package.

Variables

This section is empty.

Functions

func New

func New(theme tuikit.Theme, opts ...Option) tuikit.RenderFunc

New returns a render function that formats markdown with glamour, colored from theme, with fenced code highlighted by chroma. The returned function is safe to reuse across widths: it keeps one renderer per width, since building one parses a stylesheet and starts a goldmark pipeline — far too much to redo every frame.

Rendering failures fall back to the input text: an answer that cannot be styled must still be readable.

theme is captured here. A program whose theme changes at runtime needs a new render function, since the cached renderers are keyed on width alone.

func SyntaxThemes added in v0.6.1

func SyntaxThemes() []string

SyntaxThemes lists the chroma stylesheet names WithSyntaxTheme accepts, sorted. It is here so a host can offer a picker without taking a chroma dependency of its own.

Types

type Option

type Option func(*config)

Option configures the renderer.

func WithGlamour

func WithGlamour(opts ...glamour.TermRendererOption) Option

WithGlamour passes options straight through to glamour, for anything this package does not surface.

func WithStyleFunc added in v0.6.1

func WithStyleFunc(f func(*ansi.StyleConfig)) Option

WithStyleFunc adjusts the stylesheet after the theme has been mapped onto it, for the elements a tuikit.Theme has no opinion about — a base text color, an inline-code background, a colored blockquote rule.

func WithSyntaxTheme

func WithSyntaxTheme(name string) Option

WithSyntaxTheme sets the chroma stylesheet used for fenced code, overriding DefaultSyntaxTheme. An unknown name falls back to DefaultSyntaxTheme: chroma's own fallback is "swapoff", which colors six token types and leaves identifiers, operators and function names unstyled — a typo would render as almost-but-not-quite gray code rather than as an error. Light palettes want a light stylesheet — "tokyonight-day", "catppuccin-latte" and "github" are reasonable starts.

Jump to

Keyboard shortcuts

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