-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodes.go
More file actions
47 lines (37 loc) · 1.01 KB
/
nodes.go
File metadata and controls
47 lines (37 loc) · 1.01 KB
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
package markdown
import "github.com/yuin/goldmark/ast"
var (
kindLiteralBlock = ast.NewNodeKind("MarkdownLiteralBlock")
kindCodeBlock = ast.NewNodeKind("MarkdownCodeBlock")
)
type literalBlock struct {
ast.BaseBlock
value string
}
func newLiteralBlock(value string) *literalBlock {
return &literalBlock{value: value}
}
func (n *literalBlock) Kind() ast.NodeKind {
return kindLiteralBlock
}
func (n *literalBlock) Dump(source []byte, level int) {
ast.DumpHelper(n, source, level, map[string]string{"Value": n.value}, nil)
}
type codeBlockNode struct {
ast.BaseBlock
language SyntaxHighlight
value string
}
func newCodeBlockNode(language SyntaxHighlight, value string) *codeBlockNode {
return &codeBlockNode{language: language, value: value}
}
func (n *codeBlockNode) Kind() ast.NodeKind {
return kindCodeBlock
}
func (n *codeBlockNode) Dump(source []byte, level int) {
meta := map[string]string{}
if n.language != "" {
meta["Language"] = string(n.language)
}
ast.DumpHelper(n, source, level, meta, nil)
}