Add BlockStack.Len() for convenience

This commit is contained in:
Christian Muehlhaeuser
2019-12-08 13:52:22 +01:00
parent ad5343d395
commit b4c77e8101
2 changed files with 6 additions and 2 deletions
+4
View File
@@ -11,6 +11,10 @@ type BlockElement struct {
type BlockStack []BlockElement
func (s *BlockStack) Len() int {
return len(*s)
}
func (s *BlockStack) Push(e BlockElement) {
*s = append(*s, e)
}
+2 -2
View File
@@ -100,7 +100,7 @@ func (tr *TermRenderer) RenderNode(w io.Writer, node *bf.Node, entering bool) bf
e := tr.NewElement(node)
if entering {
if len(*bs) > 0 {
if bs.Len() > 0 {
writeTo = io.Writer(bs.Current().Block)
}
_, _ = writeTo.Write([]byte(e.Entering))
@@ -113,7 +113,7 @@ func (tr *TermRenderer) RenderNode(w io.Writer, node *bf.Node, entering bool) bf
}
}
} else {
if len(*bs) > 0 {
if bs.Len() > 0 {
writeTo = io.Writer(bs.Parent().Block)
}