File: emoji.go

package info (click to toggle)
golang-github-yuin-goldmark-emoji 1.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 232 kB
  • sloc: makefile: 2
file content (42 lines) | stat: -rw-r--r-- 898 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Package ast defines AST nodes that represetns emoji extension's elements.
package ast

import (
	"fmt"

	"github.com/yuin/goldmark-emoji/definition"
	gast "github.com/yuin/goldmark/ast"
)

// Emoji represents an inline emoji.
type Emoji struct {
	gast.BaseInline

	ShortName []byte
	Value     *definition.Emoji
}

// Dump implements Node.Dump.
func (n *Emoji) Dump(source []byte, level int) {
	m := map[string]string{
		"ShortName": string(n.ShortName),
		"Value":     fmt.Sprintf("%#v", n.Value),
	}
	gast.DumpHelper(n, source, level, m, nil)
}

// KindEmoji is a NodeKind of the emoji node.
var KindEmoji = gast.NewNodeKind("Emoji")

// Kind implements Node.Kind.
func (n *Emoji) Kind() gast.NodeKind {
	return KindEmoji
}

// NewEmoji returns a new Emoji node.
func NewEmoji(shortName []byte, value *definition.Emoji) *Emoji {
	return &Emoji{
		ShortName: shortName,
		Value:     value,
	}
}