WPT details: The following tests cover the CSS parser: https://wpt.fyi/results/css/css-text/parsing?label=master&label=experimental&aligned&q=text-wrap The precise line breaking algorithm is UA defined, so it is not testable by wpt, instead, tests are in wpt_internal.
Adjusts line breaking to avoid a short single word on the last line (also known as typographic orphans.) When `text-wrap: pretty` is specified, paragraphs that will end up with a short single word on the last line are adjusted so that the last line has two or more words. It also adjusts hyphenation if consecutive hyphenated lines appear at the end of a paragraph. The algorithm is based on the Knuth-Plass algorithm, as used by TeX. It computes scores for all candidates, and chooses the best one. To balance between the typographic benefits and the performance impacts, it adjsuts the last 4 lines of paragraphs that meet certain conditions.
Docs: https://docs.google.com/document/d/1jJFD8nAUuiUX6ArFZQqQo8yTsvg8IuAq7oFrNQxPeqI/edit?usp=sharing
Samples: https://output.jsbin.com/hopejeb