Documentation ¶
Overview ¶
Package format contains utilities for working with Matrix HTML, specifically methods to parse Markdown into HTML and to parse Matrix HTML into text or markdown.
https://spec.matrix.org/v1.2/client-server-api/#mroommessage-msgtypes
Index ¶
- Variables
- func DefaultPillConverter(displayname, mxid, eventID string, _ Context) string
- func Digits(num int) int
- func HTMLToText(html string) string
- func RenderMarkdown(text string, allowMarkdown, allowHTML bool) event.MessageEventContent
- type CodeBlockConverter
- type Context
- type HTMLParser
- type PillConverter
- type TaggedString
- type TextConverter
Constants ¶
This section is empty.
Variables ¶
View Source
var AntiParagraphRegex = regexp.MustCompile("^<p>(.+?)</p>$")
View Source
var BlockTags = []string{"p", "h1", "h2", "h3", "h4", "h5", "h6", "ol", "ul", "pre", "blockquote", "div", "hr", "table"}
View Source
var ExtensionEscapeHTML = &extEscapeHTML{}
View Source
var ExtensionSpoiler = &extSpoiler{}
ExtensionSpoiler is an extension that allow you to use spoiler expression like '~~text~~' .
View Source
var Extensions = goldmark.WithExtensions(extension.Strikethrough, extension.Table, ExtensionSpoiler)
View Source
var HTMLOptions = goldmark.WithRendererOptions(html.WithHardWraps(), html.WithUnsafe())
Functions ¶
func DefaultPillConverter ¶ added in v0.9.14
func HTMLToText ¶
HTMLToText converts Matrix HTML into text with the default settings.
func RenderMarkdown ¶
func RenderMarkdown(text string, allowMarkdown, allowHTML bool) event.MessageEventContent
Types ¶
type CodeBlockConverter ¶
type HTMLParser ¶
type HTMLParser struct { PillConverter PillConverter TabsToSpaces int Newline string HorizontalLine string BoldConverter TextConverter ItalicConverter TextConverter StrikethroughConverter TextConverter UnderlineConverter TextConverter MonospaceBlockConverter CodeBlockConverter MonospaceConverter TextConverter }
HTMLParser is a somewhat customizable Matrix HTML parser.
type PillConverter ¶ added in v0.9.14
type TaggedString ¶
type TaggedString struct {
// contains filtered or unexported fields
}
TaggedString is a string that also contains a HTML tag.
type TextConverter ¶
Click to show internal directories.
Click to hide internal directories.