Documentation
¶
Index ¶
- Constants
- Variables
- func CollectFontFamilies(content string) ([]string, error)
- func CountWordsHtml(html string) int32
- func DefaultAllowedFontSizes() []string
- func FixHTML(htmlSnippet string) (string, error)
- func SanitizeHtml(html string) string
- type ExpandTag
- type ExpandTagFunc
- type MarkupEngine
- type MarkupEngineOptions
- type ProcessedContentData
- type WidgetRegistry
Constants ¶
View Source
const WidgetElement = "ol-widget"
Variables ¶
View Source
var FXModule = fx.Module("content_util", fx.Provide(NewDefaultEngine))
Functions ¶
func CollectFontFamilies ¶
CollectFontFamilies returns the distinct font families used in HTML content.
func CountWordsHtml ¶
func DefaultAllowedFontSizes ¶
func DefaultAllowedFontSizes() []string
DefaultAllowedFontSizes is shared by chapter sanitization and the editor UI.
func SanitizeHtml ¶
SanitizeHtml takes a string of HTML content and returns a sanitized version of it, free of potentially malicious tags and attributes.
Types ¶
type ExpandTag ¶
type ExpandTag interface {
Expand(node *html.Node)
ConfigureSanitizer(policy *bluemonday.Policy)
}
type ExpandTagFunc ¶
ExpandTagFunc adapts a function to an ExpandTag. It is useful for small tag expanders and tests that do not need to change the sanitizer policy.
func (ExpandTagFunc) ConfigureSanitizer ¶
func (ExpandTagFunc) ConfigureSanitizer(*bluemonday.Policy)
func (ExpandTagFunc) Expand ¶
func (f ExpandTagFunc) Expand(node *html.Node)
type MarkupEngine ¶
type MarkupEngine struct {
// contains filtered or unexported fields
}
func NewDefaultEngine ¶
func NewDefaultEngine() *MarkupEngine
func NewEngine ¶
func NewEngine(options MarkupEngineOptions) *MarkupEngine
func (*MarkupEngine) Clean ¶
func (e *MarkupEngine) Clean(value string) (processed ProcessedContentData, err error)
type MarkupEngineOptions ¶
type MarkupEngineOptions struct {
TagExapanders map[string]ExpandTag
// URLFilter decides whether a URL used by markup such as links and images is
// permitted. A nil filter leaves URL validation to the sanitizer policy.
URLFilter func(url string) bool
// TextColorFilter decides whether a CSS text color value is permitted. A nil
// filter leaves text color validation to the sanitizer policy.
TextColorFilter func(color string) bool
// AllowedFontFamilies is the fixed set of permitted font-family CSS values.
AllowedFontFamilies []string
// FontFamilyFilter permits dynamic font-family values.
FontFamilyFilter func(fontFamily string) bool
// AllowedFontSizes is the fixed set of permitted font-size CSS values.
AllowedFontSizes []string
}
type ProcessedContentData ¶
type WidgetRegistry ¶
type WidgetRegistry struct {
}
func NewWidgetRegistry ¶
func NewWidgetRegistry() *WidgetRegistry
func (*WidgetRegistry) ConfigureSanitizer ¶
func (w *WidgetRegistry) ConfigureSanitizer(policy *bluemonday.Policy)
func (*WidgetRegistry) Expand ¶
func (w *WidgetRegistry) Expand(node *html.Node)
Click to show internal directories.
Click to hide internal directories.