markdown

package
v1.62.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Plain

func Plain(src string) string

Plain reduces Markdown to the words in it, for the places that show a piece of an answer where no markup can be rendered: a notification title, a toast, a push body. It walks what the parser understood instead of cutting markup out with patterns, so a heading, a link, a list and a fenced block all come out as what they say. Blocks and line breaks are kept as line breaks; the caller decides what a line means where it shows the text.

func RenderGFM

func RenderGFM(src string) (string, error)

RenderGFM converts Markdown to HTML.

func RenderGFMWithMedia

func RenderGFMWithMedia(src string, resolve MediaResolver) (string, error)

RenderGFMWithMedia renders Markdown like RenderGFM, except that a link or an image pointing at a file the resolver claims becomes a real player: an answer that writes ![](out.mp4) gets a video element instead of a broken image. Raw HTML stays disabled, so model output still cannot inject markup, and every URL in the result comes from the resolver, never from the model.

func Speech added in v1.55.0

func Speech(src string) string

Speech reduces Markdown to what a voice should read out, for the spoken answers. It is Plain with the parts no listener wants taken away: a code block falls out entirely, a program is not prose, and a bare link address says nothing a voice can say. Inline code stays, a spoken sentence may name a command; a link's words stay while its destination goes, which the walk gives for free because the destination is no child of the link.

func SplitFrontMatter

func SplitFrontMatter(data []byte) (meta, body []byte)

func WriteFrontMatter

func WriteFrontMatter(frontMatter any, body string) ([]byte, error)

Types

type Media

type Media struct {
	// URL is where the browser loads the file.
	URL string
	// Kind is image, video, audio or file.
	Kind string
}

Media describes how one file an answer points at should be shown.

type MediaResolver

type MediaResolver func(destination string) (Media, bool)

MediaResolver maps a destination as written in the Markdown onto a Media. Returning false leaves the node to the default rendering, which is what every external link and image gets.

Jump to

Keyboard shortcuts

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