discordmd

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: ISC Imports: 13 Imported by: 3

Documentation

Index

Constants

View Source
const (
	InlineEmojiSize = 22
	LargeEmojiSize  = 48
)

Variables

View Source
var DefaultRenderer renderer.Renderer = &BasicRenderer{}
View Source
var EmptyTag = Tag{}
View Source
var KindEmoji = ast.NewNodeKind("Emoji")
View Source
var KindInline = ast.NewNodeKind("Inline")
View Source
var KindMention = ast.NewNodeKind("Mention")

Functions

func BlockParsers

func BlockParsers() []util.PrioritizedValue

func EmojiURL

func EmojiURL(emojiID string, animated bool) string
func InlineParserWithLink() []util.PrioritizedValue

func InlineParsers

func InlineParsers() []util.PrioritizedValue

func Parse

func Parse(content []byte, opts ...parser.ParseOption) ast.Node

Parse parses the given byte slice with extra options. It does not parse links.

func ParseWithMessage

func ParseWithMessage(b []byte, s store.Cabinet, m *discord.Message, msg bool) ast.Node

ParseWithMessage parses the given byte slice with the Discord state and the Message as source for the ast nodes. If msg is false, then links will also be parsed (accordingly to embeds and webhooks, normal messages don't have links).

func Unescape

func Unescape(src []byte) []byte

Unescape handles escape characters. This is a helper function for renderers.

func UnescapeWriter

func UnescapeWriter(w io.Writer) io.Writer

Types

type Attribute

type Attribute uint16
const (
	AttrBold Attribute = 1 << iota
	AttrItalics
	AttrUnderline
	AttrStrikethrough
	AttrSpoiler
	AttrMonospace
	AttrQuoted
)

func TagAttribute

func TagAttribute(tag []byte) Attribute

func (*Attribute) Add

func (a *Attribute) Add(attr Attribute)

func (Attribute) Has

func (a Attribute) Has(attr Attribute) bool

func (Attribute) Markup

func (a Attribute) Markup() string

func (*Attribute) Remove

func (a *Attribute) Remove(attr Attribute)

func (Attribute) String

func (a Attribute) String() string

func (Attribute) StringInt

func (a Attribute) StringInt() string

type BasicRenderer

type BasicRenderer struct{}

BasicRenderer renders the package's ast.Nodes into simple unformatted plain text. It serves as an implementation reference. However, this implementation does not have a state, which is required for Inline and Blockquote.

func (*BasicRenderer) AddOptions

func (r *BasicRenderer) AddOptions(...renderer.Option)

func (*BasicRenderer) Render

func (r *BasicRenderer) Render(w io.Writer, source []byte, n ast.Node) error

type Emoji

type Emoji struct {
	ast.BaseInline

	ID   string
	Name string
	GIF  bool

	Large bool // TODO
}

func (*Emoji) Dump

func (e *Emoji) Dump(source []byte, level int)

Dump implements Node.Dump

func (Emoji) EmojiURL

func (e Emoji) EmojiURL() string

func (*Emoji) Kind

func (e *Emoji) Kind() ast.NodeKind

Kind implements Node.Kind.

type Inline

type Inline struct {
	ast.BaseInline
	Attr Attribute
}

func (*Inline) Dump

func (e *Inline) Dump(source []byte, level int)

Dump implements Node.Dump

func (*Inline) Kind

func (e *Inline) Kind() ast.NodeKind

Kind implements Node.Kind.

type Mention

type Mention struct {
	ast.BaseInline
	Message   *discord.Message
	Mentioned bool

	// both could be nil
	Channel   *discord.Channel
	GuildUser *discord.GuildUser
	GuildRole *discord.Role // might not have anything else but ID
}

func (*Mention) Dump

func (m *Mention) Dump(source []byte, level int)

Dump implements Node.Dump

func (*Mention) Kind

func (m *Mention) Kind() ast.NodeKind

Kind implements Node.Kind.

type Tag

type Tag struct {
	Attr  Attribute
	Color string
}

func (Tag) Combine

func (t Tag) Combine(tag Tag) Tag

Jump to

Keyboard shortcuts

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