Documentation
¶
Overview ¶
A hypertext filter. Rewrite HTML into a safer whitelisted subset.
Index ¶
- func EscapeText(text string) string
- func GetAttr(node *html.Node, name string) string
- func HasClass(node *html.Node, class string) bool
- func ImgToLink(node *html.Node) string
- func ImgToText(node *html.Node) string
- func SetAttr(node *html.Node, name string, value string)
- func WriteText(w io.Writer, text string)
- type Filter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Filter ¶
type Filter struct {
Imager func(node *html.Node) string
SpanClasses map[string]bool
BaseURL *url.URL
WithLinks bool
FilterText func(io.Writer, string)
RetargetLink func(string) string
}
A filter. Imager is a function that is used to process <img> tags. It should return the HTML replacement. SpanClasses is a map of classes allowed for span tags. The zero filter is useful by itself. By default, images are replaced with text.
Click to show internal directories.
Click to hide internal directories.