unorphan.js
Prevents text orphans.
orphan (n.) A word, part of a word, or very short line that appears by itself at the end of a paragraph. (via Wikipedia)
Usage
Call unorphan()
on some nodes.
Or pass on a node, or a list of nodes:
// Node // NodeList // jQuery
How does it work? — This changes last orphan space to a non-breaking space so the last 2 words stick together. Yes, it's smart and handles many edge cases.
<!-- before: --> Hello there world<!-- after: --> Hello there world
Line breaks — You may also unorphan before line breaks by passing { br: true }
.
4 Privet DriveLittle WhiggingSurrey
Download
npm install unorphan
bower install unorphan
Thanks
unorphan © 2015+, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors (list).
ricostacruz.com · GitHub @rstacruz · Twitter @rstacruz