-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparagraph.go
45 lines (39 loc) · 898 Bytes
/
paragraph.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
package ftml
type ParagraphType uint8
const (
TextParagraph ParagraphType = iota
Header1Paragraph
Header2Paragraph
Header3Paragraph
OrderedListParagraph
UnorderedListParagraph
QuoteParagraph
)
func (t ParagraphType) String() string {
switch t {
case TextParagraph:
return "Text"
case Header1Paragraph:
return "Header Lvl 1"
case Header2Paragraph:
return "Header Lvl 2"
case Header3Paragraph:
return "Header Lvl 3"
case OrderedListParagraph:
return "Ordered List"
case UnorderedListParagraph:
return "Unordered List"
case QuoteParagraph:
return "Quote"
}
panic("Unknown Paragraph Type")
}
type Paragraph struct {
Type ParagraphType
Children []*Paragraph
Content []Span
Entries [][]*Paragraph
}
func (p *Paragraph) Leaf() bool {
return p.Type == TextParagraph || p.Type == Header1Paragraph || p.Type == Header2Paragraph || p.Type == Header3Paragraph
}