mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-06 17:07:15 -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) {
|
func (w *IndentWriter) Write(b []byte) (int, error) {
|
||||||
for _, c := range string(b) {
|
for _, c := range string(b) {
|
||||||
if !w.skipIndent {
|
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.skipIndent = true
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Forward.Write([]byte{byte(c)})
|
_, err := w.Forward.Write([]byte{byte(c)})
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
if c == '\n' {
|
if c == '\n' {
|
||||||
// end of current line
|
// end of current line
|
||||||
w.skipIndent = false
|
w.skipIndent = false
|
||||||
|
|||||||
Reference in New Issue
Block a user