Support margin style flag

This commit is contained in:
Christian Muehlhaeuser
2019-12-04 06:58:28 +01:00
parent 8bcc61ace1
commit 419fda75c9
2 changed files with 25 additions and 3 deletions
+11 -3
View File
@@ -26,21 +26,29 @@ func (e *DocumentElement) Finish(w io.Writer, node *bf.Node, tr *TermRenderer) e
indent = rules.Indent
suffix = rules.Suffix
}
pw := &PaddingWriter{
Padding: uint(tr.WordWrap + int(indent*2)),
PadFunc: func(wr io.Writer) {
renderText(w, rules, " ")
},
Forward: &AnsiWriter{
Forward: w,
},
}
iw := &IndentWriter{
Indent: indent,
Forward: &AnsiWriter{
Forward: w,
Forward: pw,
},
}
_, err := iw.Write(tr.document.Bytes())
if err != nil {
return err
}
renderText(iw, rules, suffix)
tr.document.Reset()
tr.blockStyle.Pop()
renderText(w, rules, suffix)
return nil
}