-
Notifications
You must be signed in to change notification settings - Fork 4
/
ast.go
60 lines (46 loc) · 1.04 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
60
package katex
import (
"github.com/yuin/goldmark/ast"
"github.com/yuin/goldmark/util"
)
type Inline struct {
ast.BaseInline
Equation []byte
}
func (n *Inline) Inline() {}
func (n *Inline) IsBlank(source []byte) bool {
for c := n.FirstChild(); c != nil; c = c.NextSibling() {
text := c.(*ast.Text).Segment
if !util.IsBlank(text.Value(source)) {
return false
}
}
return true
}
func (n *Inline) Dump(source []byte, level int) {
ast.DumpHelper(n, source, level, nil, nil)
}
var KindInline = ast.NewNodeKind("Inline")
func (n *Inline) Kind() ast.NodeKind {
return KindInline
}
type Block struct {
ast.BaseInline
Equation []byte
}
func (n *Block) IsBlank(source []byte) bool {
for c := n.FirstChild(); c != nil; c = c.NextSibling() {
text := c.(*ast.Text).Segment
if !util.IsBlank(text.Value(source)) {
return false
}
}
return true
}
func (n *Block) Dump(source []byte, level int) {
ast.DumpHelper(n, source, level, nil, nil)
}
var KindBlock = ast.NewNodeKind("Block")
func (n *Block) Kind() ast.NodeKind {
return KindBlock
}