matrixfmt

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const RoomPattern = `@room`
View Source
const SlackApprovedTLDs = "ac|ad|ae|af|ag|ai|al|am|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|" +
	"bs|bt|bw|bz|ca|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cv|cw|cx|cy|cz|de|dj|dk|dm|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|" +
	"fo|fr|ga|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gw|gy|hk|hm|hn|hr|ht|hu|ie|il|im|in|io|iq|it|je|jm|jo|jp|ke|" +
	"kh|ki|km|kn|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|mg|mh|mk|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|" +
	"mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pm|pn|pr|ps|pt|pw|qa|re|ro|rs|ru|rw|sa|sb|sc|se|sg|" +
	"si|sk|sl|sm|sn|sr|ss|st|su|sv|sx|sz|tc|td|tg|th|tj|tk|tl|tm|tn|to|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|vg|vi|" +
	"vn|vu|wf|ws|ye|yt|za|zm|zw|com|net|org|edu|gov|info|biz|int|dev"
View Source
const URLWithProtocolPattern = `https?://[^\s/_*]+(?:/\S*)?`
View Source
const URLWithoutProtocolPattern = `[^\s/_*:]+\.(?:` + SlackApprovedTLDs + `)(?:/\S*)?`

Variables

Functions

This section is empty.

Types

type Context

type Context struct {
	Ctx      context.Context
	Portal   *bridgev2.Portal
	Mentions *event.Mentions
	TagStack format.TagStack
	Style    slack.RichTextSectionTextStyle
	Link     string

	PreserveWhitespace bool
}

func (Context) StyleBold

func (ctx Context) StyleBold() Context

func (Context) StyleCode

func (ctx Context) StyleCode() Context

func (Context) StyleItalic

func (ctx Context) StyleItalic() Context

func (Context) StylePtr

func (ctx Context) StylePtr() *slack.RichTextSectionTextStyle

func (Context) StyleStrike

func (ctx Context) StyleStrike() Context
func (ctx Context) WithLink(link string) Context

func (Context) WithTag

func (ctx Context) WithTag(tag string) Context

func (Context) WithWhitespace

func (ctx Context) WithWhitespace() Context

type HTMLParser

type HTMLParser struct {
	// contains filtered or unexported fields
}

HTMLParser is a somewhat customizable Matrix HTML parser.

func New2

func New2(br *bridgev2.Bridge, db *slackdb.SlackDB) *HTMLParser

func (*HTMLParser) GetMentionedChannelID

func (parser *HTMLParser) GetMentionedChannelID(mxid id.RoomID, ctx Context) string
func (parser *HTMLParser) GetMentionedEventLink(roomID id.RoomID, eventID id.EventID, ctx Context) string

func (*HTMLParser) GetMentionedUserID

func (parser *HTMLParser) GetMentionedUserID(mxid id.UserID, ctx Context) string

func (*HTMLParser) Parse

func (parser *HTMLParser) Parse(ctx context.Context, htmlData string, mentions *event.Mentions, portal *bridgev2.Portal) *slack.RichTextBlock

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

func (*HTMLParser) ParseText

func (parser *HTMLParser) ParseText(ctx context.Context, text string, mentions *event.Mentions, portal *bridgev2.Portal) *slack.RichTextBlock

Jump to

Keyboard shortcuts

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