matrixfmt

package
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BlockTags = []string{"p", "h1", "h2", "h3", "h4", "h5", "h6", "ol", "ul", "pre", "blockquote", "div", "hr", "table"}
View Source
var DebugLog = func(format string, args ...any) {}

Functions

func Digits

func Digits(num int) int

Digits counts the number of digits (and the sign, if negative) in an integer.

func Parse

func Parse(ctx context.Context, parser *HTMLParser, content *event.MessageEventContent) (string, []*signalpb.BodyRange)

Types

type Context

type Context struct {
	Ctx                context.Context
	AllowedMentions    *event.Mentions
	TagStack           TagStack
	PreserveWhitespace bool
}

func NewContext

func NewContext(ctx context.Context) Context

func (Context) WithTag

func (ctx Context) WithTag(tag string) Context

func (Context) WithWhitespace

func (ctx Context) WithWhitespace() Context

type EntityString

type EntityString struct {
	String   signalfmt.UTF16String
	Entities signalfmt.BodyRangeList
}

func JoinEntityString

func JoinEntityString(with string, strings ...*EntityString) *EntityString

func NewEntityString

func NewEntityString(val string) *EntityString

func (*EntityString) Append

func (es *EntityString) Append(other *EntityString) *EntityString

func (*EntityString) AppendString

func (es *EntityString) AppendString(other string) *EntityString

func (*EntityString) Format

func (*EntityString) Split

func (es *EntityString) Split(at uint16) []*EntityString

func (*EntityString) TrimSpace

func (es *EntityString) TrimSpace() *EntityString

type HTMLParser

type HTMLParser struct {
	GetUUIDFromMXID func(context.Context, id.UserID) uuid.UUID
}

HTMLParser is a somewhat customizable Matrix HTML parser.

func (*HTMLParser) Parse

func (parser *HTMLParser) Parse(htmlData string, ctx Context) *EntityString

Parse converts Matrix HTML into text using the settings in this parser.

type TagStack

type TagStack []string

func (TagStack) Has

func (ts TagStack) Has(tag string) bool

func (TagStack) Index

func (ts TagStack) Index(tag string) int

type TaggedString

type TaggedString struct {
	*EntityString
	// contains filtered or unexported fields
}

TaggedString is a string that also contains a HTML tag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL