-
-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Description
I think general non-word wrapping would be a great addition to this library. This algorithm should just break as soon as the limit is reached. This would also be a great addition to wordwrap
, as wordwrap
does currently not enforce the given limit if the length of single words already exceeds the limit.
A typical usecase would be to stay confined to the terminal width: In this case word-wrapping is nice but the limit has to be strictly enforced so word-wrapping could be applied first and then the general wrapping.
package main
import (
"fmt"
"github.com/muesli/reflow/wordwrap"
"github.com/muesli/reflow/wrap"
)
func main() {
test := "AAAAA BBBBBBBBBBB"
fmt.Println(wordwrap.String(test, 8))
// output:
// AAAAA
// BBBBBBBBBBB
fmt.Println(wrap.String(wordwrap.String(test, 8), 8))
// output:
// AAAAA
// BBBBBBBB
// BBB
}
Metadata
Metadata
Assignees
Labels
No labels