Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchImage ¶
FetchImage loads the image src names, for Options.LoadImage: an http or https URL, a data: URI (base64), or a local file (a path or a file: URL). It reads PNG, JPEG, GIF (the first frame) and WebP. Downloads time out after 20 seconds and stop at 20 MB.
Loading the images of Markdown the app doesn't control - a model's reply, a message from someone else - tells their servers that the document was opened, and from where: wrap FetchImage to allow only trusted hosts in such a case.
Types ¶
type Options ¶
type Options struct {
// Styles is the body text: Color (default theme.text), FontSize
// (default 14), LineHeight, FontFamily.
Styles styles.Styles
// CodeFont is the typeface of code spans and blocks, default
// "Go Mono" (register it, or your own monospace face, with
// RegisterFonts).
CodeFont properties.FontFamily
// CodeBackground fills code spans and blocks, default a faint tint
// of the text color.
CodeBackground properties.Color
// LinkColor colors links, default theme.primary.
LinkColor properties.Color
// OnLink handles taps on links; by default they open in the
// browser.
OnLink func(url string)
// Selectable, when set, makes the document selectable as a whole -
// drag across paragraphs, headings, lists, tables and code, then
// copy - by putting it in a SelectionArea; its value identifies the
// document, as a message ID would. A document already inside a
// SelectionArea is part of that area's selection, with or without
// it.
Selectable any
// Gap is the space between blocks in dp, default 10.
Gap int
// LoadImage, when set, loads the pictures of , in
// paragraphs, headings and table cells, given src: FetchImage
// reads URLs, data: URIs and files, or wrap it to resolve relative
// paths or allow only some hosts. It's called once per src, off the
// UI goroutine, and the image is kept for the next documents that
// show it. An image shows at its pixel size in dp, narrowed to the
// width there is, on a line of its own (side by side with images
// next to it); its alt text shows while it loads and if it fails.
// Without LoadImage, images show as their alt text.
LoadImage func(src string) (image.Image, error)
// Math sets formulas, with package formula imported (which adds its
// math font): $$...$$ and \[...\] starting a line as display
// formulas, centered; $...$ and \(...\) in a paragraph inline, on
// the text's baseline and wrapping with the words. A $ opens a
// formula when no space follows it and closes one when no space
// comes before it and no digit after it, as on GitHub, so "$5 and
// $10" stays text; \$ is a dollar sign. A selection copies a
// formula as its source. One that doesn't read (formula.Check), or
// without package formula, shows its source as code.
Math bool
}
Options configures how Markdown renders. The zero value works.