-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.go
53 lines (45 loc) · 1.12 KB
/
node.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
package runic
import (
"slices"
)
type Node struct {
Typ string `json:"type"`
Val string `json:"value,omitempty"`
Children []*Node `json:"children,omitempty"`
parent *Node
}
const INDENT_WIDTH = 2
const (
nodeRoot = "Root"
nodeError = "ERROR"
nodeHeadingOne = "HeadingOne"
nodeHeadingTwo = "HeadingTwo"
nodeHeadingThree = "HeadingThree"
nodeHeadingFour = "HeadingFour"
nodeHeadingFive = "HeadingFive"
nodeHeadingSix = "HeadingSix"
nodeParagraph = "Paragraph"
nodeText = "Text"
nodeBoldTag = "BoldTag"
nodeItalicTag = "ItalicTag"
nodeList = "List"
nodeListItem = "ListItem"
)
const (
nodeHeadingOneValue = "."
nodeHeadingTwoValue = ":"
nodeHeadingThreeValue = ":."
nodeHeadingFourValue = "::"
nodeHeadingFiveValue = "::."
nodeHeadingSixValue = ":::"
)
var (
errInvalidTag = "Invalid tag name"
errInvalidHeading = "Invalid heading value"
)
func isOneOf(nodeType string, nodeTypes ...string) bool {
return slices.Contains(nodeTypes, nodeType)
}
func getListItemDepth(listItem token) int {
return listItem.indent / INDENT_WIDTH
}