mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-05 16:37:19 -04:00
Handle write buffers & cascading styles in BlockStack
This commit is contained in:
+10
-5
@@ -1,6 +1,7 @@
|
||||
package gold
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
|
||||
bf "gopkg.in/russross/blackfriday.v2"
|
||||
@@ -12,8 +13,12 @@ type DocumentElement struct {
|
||||
func (e *DocumentElement) Render(w io.Writer, node *bf.Node, tr *TermRenderer) error {
|
||||
rules := tr.style[Document]
|
||||
if rules != nil {
|
||||
tr.blockStyle.Push(rules)
|
||||
renderText(w, rules, rules.Prefix)
|
||||
be := BlockElement{
|
||||
Block: &bytes.Buffer{},
|
||||
Style: rules,
|
||||
}
|
||||
tr.blockStack.Push(be)
|
||||
renderText(tr.blockStack.Current().Block, rules, rules.Prefix)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -43,14 +48,14 @@ func (e *DocumentElement) Finish(w io.Writer, node *bf.Node, tr *TermRenderer) e
|
||||
Forward: pw,
|
||||
},
|
||||
}
|
||||
_, err := iw.Write(tr.document.Bytes())
|
||||
_, err := iw.Write(tr.blockStack.Current().Block.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
renderText(iw, rules, suffix)
|
||||
|
||||
tr.document.Reset()
|
||||
tr.blockStyle.Pop()
|
||||
tr.blockStack.Current().Block.Reset()
|
||||
tr.blockStack.Pop()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user