Documentation
¶
Index ¶
- func Plain(src string) string
- func RenderGFM(src string) (string, error)
- func RenderGFMWithMedia(src string, resolve MediaResolver) (string, error)
- func Speech(src string) string
- func SplitFrontMatter(data []byte) (meta, body []byte)
- func WriteFrontMatter(frontMatter any, body string) ([]byte, error)
- type Media
- type MediaResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Plain ¶
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 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  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
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 ¶
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 ¶
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.