-
Notifications
You must be signed in to change notification settings - Fork 7
/
ast.go
59 lines (50 loc) · 1.37 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package wikilink
import (
"github.com/yuin/goldmark/ast"
)
// Kind is the kind of the wikilink AST node.
var Kind = ast.NewNodeKind("WikiLink")
// Node is a Wikilink AST node.
// Wikilinks have two components: the target and the label.
//
// The target is the page to which this link points,
// and the label is the text that displays for this link.
//
// For links in the following form, the label and the target are the same.
//
// [[Foo bar]]
//
// For links in the following form, the target is the portion of the link to
// the left of the "|", and the label is the portion to the right.
//
// [[Foo bar|baz qux]]
type Node struct {
ast.BaseInline
// Page to which this wikilink points.
//
// This may be blank for links to headers within the same document
// like [[#Foo]].
Target []byte
// Fragment portion of the link, if any.
//
// For links in the form, [[Foo bar#Baz qux]], this is the portion
// after the "#".
Fragment []byte
// Whether this link starts with a bang (!).
//
// ![[foo.png]]
//
// This indicates that the resource should be embedded (e.g. images).
Embed bool
}
var _ ast.Node = (*Node)(nil)
// Kind reports the kind of this node.
func (n *Node) Kind() ast.NodeKind {
return Kind
}
// Dump dumps the Node to stdout.
func (n *Node) Dump(src []byte, level int) {
ast.DumpHelper(n, src, level, map[string]string{
"Target": string(n.Target),
}, nil)
}