Decouple render elements from blackfriday parser

This commit is contained in:
Christian Muehlhaeuser
2019-12-07 18:48:08 +01:00
parent 665477d690
commit 897b2dbd1e
13 changed files with 179 additions and 132 deletions
+2 -3
View File
@@ -11,7 +11,6 @@ import (
"github.com/logrusorgru/aurora"
"github.com/lucasb-eyer/go-colorful"
bf "gopkg.in/russross/blackfriday.v2"
)
type BaseElement struct {
@@ -137,8 +136,8 @@ func renderText(w io.Writer, rules ElementStyle, s string) {
_, _ = w.Write([]byte(out.String()))
}
func (e *BaseElement) Render(w io.Writer, node *bf.Node, tr *TermRenderer) error {
bs := tr.context.blockStack
func (e *BaseElement) Render(w io.Writer, ctx RenderContext) error {
bs := ctx.blockStack
renderText(w, bs.Current().Style, e.Prefix)
defer func() {