Documentation ¶
Index ¶
- Constants
- Variables
- type Context
- func (ctx Context) StyleBold() Context
- func (ctx Context) StyleCode() Context
- func (ctx Context) StyleItalic() Context
- func (ctx Context) StylePtr() *slack.RichTextSectionTextStyle
- func (ctx Context) StyleStrike() Context
- func (ctx Context) WithLink(link string) Context
- func (ctx Context) WithTag(tag string) Context
- func (ctx Context) WithWhitespace() Context
- type HTMLParser
- func (parser *HTMLParser) GetMentionedChannelID(mxid id.RoomID, ctx Context) string
- func (parser *HTMLParser) GetMentionedEventLink(roomID id.RoomID, eventID id.EventID, ctx Context) string
- func (parser *HTMLParser) GetMentionedUserID(mxid id.UserID, ctx Context) string
- func (parser *HTMLParser) Parse(ctx context.Context, htmlData string, mentions *event.Mentions, ...) *slack.RichTextBlock
- func (parser *HTMLParser) ParseText(ctx context.Context, text string, mentions *event.Mentions, ...) *slack.RichTextBlock
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 ¶
View Source
var URLOrRoomRegex = regexp.MustCompile(fmt.Sprintf("%s|%s|%s", URLWithProtocolPattern, URLWithoutProtocolPattern, RoomPattern))
View Source
var URLRegex = regexp.MustCompile(fmt.Sprintf("%s|%s", URLWithProtocolPattern, URLWithoutProtocolPattern))
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) StyleItalic ¶
func (Context) StylePtr ¶
func (ctx Context) StylePtr() *slack.RichTextSectionTextStyle
func (Context) StyleStrike ¶
func (Context) WithWhitespace ¶
type HTMLParser ¶
type HTMLParser struct {
// contains filtered or unexported fields
}
HTMLParser is a somewhat customizable Matrix HTML parser.
func (*HTMLParser) GetMentionedChannelID ¶
func (parser *HTMLParser) GetMentionedChannelID(mxid id.RoomID, ctx Context) string
func (*HTMLParser) GetMentionedEventLink ¶
func (*HTMLParser) GetMentionedUserID ¶
func (parser *HTMLParser) GetMentionedUserID(mxid id.UserID, ctx Context) string
Click to show internal directories.
Click to hide internal directories.