-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathast.go
38 lines (29 loc) · 806 Bytes
/
ast.go
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
package anchor
import (
"strconv"
"github.com/yuin/goldmark/ast"
)
// Kind is the NodeKind used by anchor nodes.
var Kind = ast.NewNodeKind("Anchor")
// Node is an anchor node in the Markdown AST.
type Node struct {
ast.BaseInline
// ID of the header this anchor is for.
ID []byte
// Level of the header that this anchor is for.
Level int
// Value is the text inside the anchor.
// Typically this is a fixed string
// like '¶' or '#'.
Value []byte
}
// Kind reports that this is a Anchor node.
func (*Node) Kind() ast.NodeKind { return Kind }
// Dump dumps this node to stdout for debugging.
func (n *Node) Dump(src []byte, level int) {
ast.DumpHelper(n, src, level, map[string]string{
"ID": string(n.ID),
"Value": string(n.Value),
"Level": strconv.Itoa(n.Level),
}, nil)
}