Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindLinks ¶
FindLinks parses the given string looking for recognizable URLs (including scheme). It returns a list of those URLs, without changing the string, or an error if something goes wrong. If no URLs are found within the given string, an empty slice and nil will be returned.
func MinifyHTML ¶
MinifyHTML runs html through a minifier, reducing it in size.
func RemoveHTML ¶
RemoveHTML removes all HTML from the given string.
func SanitizeHTML ¶
SanitizeHTML cleans up HTML in the given string, allowing through only safe HTML elements.
Types ¶
type Formatter ¶
type Formatter interface { // FromMarkdown parses an HTML text from a markdown-formatted text. FromMarkdown(ctx context.Context, md string, mentions []*gtsmodel.Mention, tags []*gtsmodel.Tag) string // FromPlain parses an HTML text from a plaintext. FromPlain(ctx context.Context, plain string, mentions []*gtsmodel.Mention, tags []*gtsmodel.Tag) string // ReplaceTags takes a piece of text and a slice of tags, and returns the same text with the tags nicely formatted as hrefs. ReplaceTags(ctx context.Context, in string, tags []*gtsmodel.Tag) string // ReplaceMentions takes a piece of text and a slice of mentions, and returns the same text with the mentions nicely formatted as hrefs. ReplaceMentions(ctx context.Context, in string, mentions []*gtsmodel.Mention) string // ReplaceLinks takes a piece of text, finds all recognizable links in that text, and replaces them with hrefs. ReplaceLinks(ctx context.Context, in string) string }
Formatter wraps some logic and functions for parsing statuses and other text input into nice html.
Click to show internal directories.
Click to hide internal directories.