linebreak

linebreak is a very simple library for Haskell to appropriately break a sentence into fixed-width lines, using Knuth-Liang hyphenation to obtain a better result. An example is worth a thousand words; say I wanted to cram this paragraph in 60 columns-width lines, the result would be:

|linebreak| is a very simple library for Haskell to appro-
priately break a sentence into fixed-width lines, using
Knuth-Liang hyphenation to obtain a better result. An exam-
ple is worth a thousand words; say I wanted to cram this
paragraph in 60 columns-width lines, the result would be:

Without hypens (same 60 columns max width):

|linebreak| is a very simple library for Haskell to
appropriately break a sentence into fixed-width lines, using
Knuth-Liang hyphenation to obtain a better result. An
example is worth a thousand words; say I wanted to cram this
paragraph in 60 columns-width lines, the result would be:

As you can see the right margin in the hyphenated text is less ragged (and probably the best result we can obtain, since with fixed-width fonts with double-margin justification look ugly); linebreak attains the result with efficiency and minimal dependencies.

The library

You can find linebreak on Hackage.

I distribute source (signed hashes). To report a bug, request a feature or contribute with a patch, write to me.

If you prefer, there is a git repository too.