cdornan / fmt

New formatting library
BSD 3-Clause "New" or "Revised" License
56 stars 6 forks source link

Add 'wordWrap' formatter #14

Closed chshersh closed 3 years ago

chshersh commented 6 years ago

Something like that:

wordsWrapF :: Int -> Text -> Builder

Behavior should be the following:

  1. Splits given text into lines with length no more than given Int.
  2. No breaks in the middle of the words (every line should contain whole words).

TODO: should we compress consequent spaces? Like, should

wordWrapF 100 "foo            bar"

result in

"foo bar"

?

I think it should.

@neongreen Please, comment.

Also, relevant to https://github.com/serokell/importify/issues/90

cdornan commented 3 years ago

If anybody still thinks this is important then reopen, or better submit a patch.