-
Notifications
You must be signed in to change notification settings - Fork 12
/
state.go
42 lines (32 loc) · 742 Bytes
/
state.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
package pdf
import "github.com/yuin/goldmark/ast"
type state struct {
containerType ast.NodeKind
textStyle Style
leftMargin float64
firstParagraph bool
// populated if node type is a list
listkind listType
itemNumber int // only if an ordered list
// populated if node type is a link
destination string
// populated if table cell
isHeader bool
}
type states struct {
stack []*state
}
func (s *states) push(c *state) {
s.stack = append(s.stack, c)
}
func (s *states) pop() *state {
var x *state
x, s.stack = s.stack[len(s.stack)-1], s.stack[:len(s.stack)-1]
return x
}
func (s *states) peek() *state {
return s.stack[len(s.stack)-1]
}
func (s *states) parent() *state {
return s.stack[len(s.stack)-2]
}