Avoids single words breaking onto the last line of text.
Use buddysystem.js and simply pass in an array of objects into buddySystem()
objs = document.getElementsByClassName('corrected')
buddySystem(objs)
Use buddysystem.jquery.js after jQuery and $.buddySystem() on any element or elements.
$('.corrected').buddySystem()
Because you don't need yet another library in your app to do something so simple, this code snippet has been golfed to be as small as possible.
BuddySystem looks for the last space in a phrase like this one
The rain in Spain falls mainly on the plains
And replaces it with
, causing the last two words to be parsed as one...holding hands together, the buddy system.
The rain in Spain falls mainly on the plains
Of course, because
is unicode markup for a non-breaking space, the text will appear as:
"The rain in Spain falls mainly on
the plains"
If the line breaks after the last "the".