Breaking a Paragraph up, and Aligning It
A paragraph broken into lines, then laid out four ways: left, right, centred, justified.
A sign on a narrow post, the spine of a folder, a label running up the side of a box: sometimes a word has to be read from top to bottom, one letter under the next. Here three signs are set that way on narrow boards. The first fills its columns from right to left and may break a word anywhere, closing each column a cut ends on a hyphen; the second fills them from left to right starting at the bottom, and the third centres its words in blue with more room between the columns.
Under each sign, the program writes what it measured while setting it: how many of its columns fit on the board, how tall the tallest one is, how many end a paragraph, what the first one holds, and how tall the whole text would stand in a single column. The first sign runs out of room, and the page says so: four of its seven columns fit.
Nothing is left out and nothing is simplified: this is the program exactly as it runs, for the developer who uses this library.
Read the Rust source Read the Python source
Open the document in English Open the document in French Open the document in German Open the document in Spanish Open the document in Italian Open the document in Portuguese
A paragraph broken into lines, then laid out four ways: left, right, centred, justified.
A word longer than the column that holds it: the library leaves it whole, cuts it at the column's edge, or cuts it and closes the line on a hyphen.
A justified column set twice: the long words breaking at their soft hyphens with a hyphen shown, or left whole, and a figure a no-break space keeps together.
A justified column set four times: file paths and compounds running past the edge with no break points, wrapping where a break after a slash or a hyphen is allowed, then wherever their punctuation allows one, and last with no-break hyphens that keep each compound whole.
A title, a rule, two paragraphs, a heading, a table of twenty-six rows and a footnote, handed over in reading order and broken across two pages by the engine.
A delivery slip poured into two boxes, the second taking up where the first stopped, and a poster whose picture no box can hold, each box saying what became of the stack in it.