matrixfmt

package
v0.0.0-...-c8590ca Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: AGPL-3.0 Imports: 13 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

Types

type Context

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

func NewContext

func NewContext(ctx context.Context) Context

func (Context) WithIncrementedListDepth

func (ctx Context) WithIncrementedListDepth() 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   telegramfmt.UTF16String
	Entities telegramfmt.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 {
	GetGhostDetails func(context.Context, id.UserID) (networkid.UserID, string, int64, bool)
}

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