Move stateful objects to RenderContext struct

This commit is contained in:
Christian Muehlhaeuser
2019-12-07 15:40:42 +01:00
parent 53c220c9fc
commit 665477d690
12 changed files with 129 additions and 89 deletions
+4 -3
View File
@@ -11,8 +11,9 @@ type ItemElement struct {
}
func (e *ItemElement) Render(w io.Writer, node *bf.Node, tr *TermRenderer) error {
var el *BaseElement
ctx := tr.context
var el *BaseElement
if node.ListData.ListFlags&bf.ListTypeOrdered > 0 {
var l int64
n := node
@@ -23,13 +24,13 @@ func (e *ItemElement) Render(w io.Writer, node *bf.Node, tr *TermRenderer) error
el = &BaseElement{
Token: string(node.Literal),
Style: tr.style[Enumeration],
Style: ctx.style[Enumeration],
Prefix: strconv.FormatInt(l+1, 10),
}
} else {
el = &BaseElement{
Token: string(node.Literal),
Style: tr.style[Item],
Style: ctx.style[Item],
}
}