mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-02 06:57:30 -04:00
Decouple render elements from blackfriday parser
This commit is contained in:
+4
-7
@@ -3,15 +3,13 @@ package gold
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
|
||||
bf "gopkg.in/russross/blackfriday.v2"
|
||||
)
|
||||
|
||||
type DocumentElement struct {
|
||||
Width uint
|
||||
}
|
||||
|
||||
func (e *DocumentElement) Render(w io.Writer, node *bf.Node, tr *TermRenderer) error {
|
||||
ctx := tr.context
|
||||
func (e *DocumentElement) Render(w io.Writer, ctx RenderContext) error {
|
||||
rules := ctx.style[Document]
|
||||
|
||||
be := BlockElement{
|
||||
@@ -24,8 +22,7 @@ func (e *DocumentElement) Render(w io.Writer, node *bf.Node, tr *TermRenderer) e
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *DocumentElement) Finish(w io.Writer, node *bf.Node, tr *TermRenderer) error {
|
||||
ctx := tr.context
|
||||
func (e *DocumentElement) Finish(w io.Writer, ctx RenderContext) error {
|
||||
bs := ctx.blockStack
|
||||
rules := ctx.style[Document]
|
||||
|
||||
@@ -40,7 +37,7 @@ func (e *DocumentElement) Finish(w io.Writer, node *bf.Node, tr *TermRenderer) e
|
||||
suffix := rules.Suffix
|
||||
|
||||
pw := &PaddingWriter{
|
||||
Padding: uint(tr.WordWrap) - margin,
|
||||
Padding: e.Width - margin,
|
||||
PadFunc: func(wr io.Writer) {
|
||||
renderText(w, rules, " ")
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user