mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-08-31 14:16:44 -04:00
Add error handling to IndentWriter
This commit is contained in:
@@ -16,11 +16,17 @@ type IndentWriter struct {
|
||||
func (w *IndentWriter) Write(b []byte) (int, error) {
|
||||
for _, c := range string(b) {
|
||||
if !w.skipIndent {
|
||||
w.Forward.Write([]byte(strings.Repeat(" ", int(w.Indent))))
|
||||
_, err := w.Forward.Write([]byte(strings.Repeat(" ", int(w.Indent))))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
w.skipIndent = true
|
||||
}
|
||||
|
||||
w.Forward.Write([]byte{byte(c)})
|
||||
_, err := w.Forward.Write([]byte{byte(c)})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if c == '\n' {
|
||||
// end of current line
|
||||
w.skipIndent = false
|
||||
|
||||
Reference in New Issue
Block a user