Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Emojify ¶ added in v0.6.0
Emojify replaces shortcodes in `inputText` with the emoji in `emojis`.
Callers should ensure that inputText and resulting text are escaped appropriately depending on what they're used for.
func SanitizeHTML ¶
SanitizeHTML sanitizes risky html elements from the given string, allowing only safe ones through.
func SanitizePlaintext ¶ added in v0.3.4
SanitizePlaintext runs text through basic sanitization. This removes any html elements that were in the string, and returns clean plaintext.
Types ¶
type FormatFunc ¶ added in v0.7.0
type FormatFunc func(ctx context.Context, pmf gtsmodel.ParseMentionFunc, authorID string, statusID string, text string) *FormatResult
type FormatResult ¶ added in v0.7.0
type Formatter ¶
type Formatter interface { // FromPlain parses an HTML text from a plaintext. FromPlain(ctx context.Context, pmf gtsmodel.ParseMentionFunc, authorID string, statusID string, plain string) *FormatResult // FromMarkdown parses an HTML text from a markdown-formatted text. FromMarkdown(ctx context.Context, pmf gtsmodel.ParseMentionFunc, authorID string, statusID string, md string) *FormatResult // FromPlainEmojiOnly parses an HTML text from a plaintext, only parsing emojis and not mentions etc. FromPlainEmojiOnly(ctx context.Context, pmf gtsmodel.ParseMentionFunc, authorID string, statusID string, plain string) *FormatResult }
Formatter wraps some logic and functions for parsing statuses and other text input into nice html. Each of the member functions returns a struct containing the formatted HTML and any tags, mentions, and emoji that were found in the text.
func NewFormatter ¶
NewFormatter returns a new Formatter interface for parsing statuses and other text input into nice html.