table-layout-0.9.0.2: Format tabular data as grid or table.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.Layout.Table.Justify

Description

Produce justified text, which is spread over multiple rows. For a simple cut, chunksOf from the split package is best suited.

Synopsis

Text justification

justify :: Int -> [String] -> [String] Source #

Fits as many words on a line as possible depending on the given width. Every line, except the last one, gets equally filled with spaces between the words as far as possible.

justifyText :: Int -> String -> [String] Source #

Uses words to split the text into words and justifies it with justify.

>>> justifyText 10 "This text will not fit on one line."
["This  text","will   not","fit on one","line."]

fitWords Source #

Arguments

:: Int

The number of characters available per line.

-> [String]

The words to join with whitespaces.

-> [Line]

The list of line information.

Fit as much words on a line as possible. Produce a list of the length of the line with one space between the words, the word count and the words.

Cutting below word boundaries is not yet supported.

concatPadLine Source #

Arguments

:: Int

The maximum length for lines.

-> Line

The Line.

-> String 

Join the words on a line together by filling it with spaces in between.

Helpers

dimorphicSummands :: Int -> Int -> [Int] Source #

Splits a given number into summands of 2 different values, where the first one is exactly one bigger than the second one. Splitting 40 spaces into 9 almost equal parts would result in:

>>> dimorphicSummands 40 9
[5,5,5,5,4,4,4,4,4]

dimorphicSummandsBy :: (Int -> a) -> Int -> Int -> [a] Source #

mixedDimorphicSummandsBy :: (Int -> a) -> Int -> Int -> [a] Source #

Spread out summands evenly mixed as far as possible.