From 092a25ba776fa3f999ad081d6d937b336c65833c Mon Sep 17 00:00:00 2001 From: John Titor Date: Wed, 4 Aug 2021 20:00:51 +0200 Subject: [PATCH] Preserve empty lines in wordWrap --- wrap.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wrap.go b/wrap.go index 3dfe6e1..9ece984 100644 --- a/wrap.go +++ b/wrap.go @@ -28,6 +28,10 @@ func splitOnSpace(x string) []string { func wordWrap(m measureStringer, s string, width float64) []string { var result []string for _, line := range strings.Split(s, "\n") { + if strings.TrimSpace(line) == "" { + result = append(result, line) + continue + } fields := splitOnSpace(line) if len(fields)%2 == 1 { fields = append(fields, "")