markdown

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package markdown renders Markdown for the terminal. It wraps glamour for the styling and adds OSC 8 hyperlinks so URLs stay clickable.

Index

Constants

View Source
const DefaultWidth = 80

DefaultWidth is the word wrap used when the caller has no width of its own.

Variables

This section is empty.

Functions

func Hyperlink(text, url string) string

Hyperlink wraps text in an OSC 8 terminal hyperlink sequence, returning it unchanged when there is no URL to link to.

func LinkifyURLs

func LinkifyURLs(text string) string

LinkifyURLs wraps bare URLs in OSC 8 hyperlink sequences, leaving URLs that already sit inside one alone.

func Render

func Render(md htmlutil.Markdown, width int) string

Render renders Markdown as styled terminal output wrapped to width. It falls back to the Markdown source when glamour cannot be set up, so a rendering problem costs formatting rather than the message itself.

Only htmlutil.ToMarkdown can produce the Markdown this accepts: the type is the provenance, so a string from anywhere else cannot reach glamour. The Markdown is still treated as untrusted on the way in and the output is checked on the way out: see prepareSource and contain. One consequence worth knowing is that `&` is always literal here — an entity reference in the source is shown as the characters it was written with, because the HTML it came from already decoded the entities that were meant to be decoded.

Types

This section is empty.

Jump to

Keyboard shortcuts

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