mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-05 16:37:19 -04:00
Support styled indents for block elements
This commit is contained in:
@@ -3,6 +3,7 @@ package gold
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/muesli/reflow"
|
||||
bf "gopkg.in/russross/blackfriday.v2"
|
||||
)
|
||||
|
||||
@@ -22,3 +23,19 @@ func (e *ParagraphElement) Render(w io.Writer, node *bf.Node, tr *TermRenderer)
|
||||
}
|
||||
return el.Render(w, node, tr)
|
||||
}
|
||||
|
||||
func (e *ParagraphElement) Finish(w io.Writer, node *bf.Node, tr *TermRenderer) error {
|
||||
var indent uint
|
||||
rules := tr.style[Paragraph]
|
||||
if rules != nil {
|
||||
indent = rules.Indent
|
||||
}
|
||||
iw := &IndentWriter{
|
||||
Indent: indent,
|
||||
Forward: w,
|
||||
}
|
||||
|
||||
_, err := iw.Write(reflow.ReflowBytes(tr.paragraph.Bytes(), tr.WordWrap-int(indent)))
|
||||
tr.paragraph.Reset()
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user