Skip to content

Commit

Permalink
Formatted code.
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 18, 2021
1 parent c304b97 commit 94f7884
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,32 +275,32 @@ func replaceBytesInBetween(value []byte, startIndex int, endIndex int, new []byt

func wordWrap(s string, limit int) string {

if strings.TrimSpace(s) == "" {
return s
}
if strings.TrimSpace(s) == "" {
return s
}

// convert string to slice
strSlice := strings.Fields(s)
// convert string to slice
strSlice := strings.Fields(s)

var result string = ""
var result string = ""

for len(strSlice) >= 1 {
// convert slice/array back to string
// but insert <br> at specified limit
for len(strSlice) >= 1 {
// convert slice/array back to string
// but insert <br> at specified limit

result = result + strings.Join(strSlice[:limit], " ") + "<br>"
result = result + strings.Join(strSlice[:limit], " ") + "<br>"

// discard the elements that were copied over to result
strSlice = strSlice[limit:]
// discard the elements that were copied over to result
strSlice = strSlice[limit:]

// change the limit
// to cater for the last few words in
//
if len(strSlice) < limit {
limit = len(strSlice)
}
// change the limit
// to cater for the last few words in
//
if len(strSlice) < limit {
limit = len(strSlice)
}

}
}

return result
}
return result
}

0 comments on commit 94f7884

Please sign in to comment.