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 -2
View File
@@ -10,10 +10,12 @@ type ImageElement struct {
}
func (e *ImageElement) Render(w io.Writer, node *bf.Node, tr *TermRenderer) error {
ctx := tr.context
if len(node.LastChild.Literal) > 0 {
el := &BaseElement{
Token: string(node.LastChild.Literal),
Style: tr.style[ImageText],
Style: ctx.style[ImageText],
}
err := el.Render(w, node.LastChild, tr)
if err != nil {
@@ -24,7 +26,7 @@ func (e *ImageElement) Render(w io.Writer, node *bf.Node, tr *TermRenderer) erro
el := &BaseElement{
Token: resolveRelativeURL(tr.BaseURL, string(node.LinkData.Destination)),
Prefix: " ",
Style: tr.style[Image],
Style: ctx.style[Image],
}
err := el.Render(w, node, tr)
if err != nil {