Handle Lists as a block element, which supports margins & indents

This commit is contained in:
Christian Muehlhaeuser
2019-12-04 13:37:14 +01:00
parent 038f2dd684
commit 15d9fd129b
3 changed files with 59 additions and 21 deletions
+2 -13
View File
@@ -2,7 +2,6 @@ package gold
import (
"io"
"strings"
bf "gopkg.in/russross/blackfriday.v2"
)
@@ -11,19 +10,9 @@ type ItemElement struct {
}
func (e *ItemElement) Render(w io.Writer, node *bf.Node, tr *TermRenderer) error {
l := 0
n := node
for n.Parent != nil && (n.Parent.Type == bf.List || n.Parent.Type == bf.Item) {
if n.Parent.Type == bf.List {
l++
}
n = n.Parent
}
el := &BaseElement{
Prefix: strings.Repeat(" ", l-1),
Token: string(node.Literal),
Style: Item,
Token: string(node.Literal),
Style: Item,
}
return el.Render(w, node, tr)
}