It can be library-dependent or -agnostic. I just want to know if a script exists that will analyze the page (or maybe certain nodes that it has been given) and... "protect" against widows and orphans in the text.
What does "protect" mean? I don't know. I considered seeing if I could come up with one myself, but part of the problem is I'm not even sure how I would go about doing it.
Clarification: This would be for the screen version of the site, not print.
Control widow and orphan lines Select the paragraphs in which you want to control widow and orphan. On the Format menu, click Paragraph, and then click the Line and Page Breaks tab. Select the Widow/Orphan control check box.
Widow/Orphan control Widows and orphans are single lines of text in a paragraph that print at the top or bottom of a text box or column. To prevent widows and orphans by always having at least two lines of text at the top or bottom of a text box, select the Widow/Orphan control check box.
The orphans property sets or returns the minimum number of lines for an element that must be visible at the bottom of a page (for printing or print preview). The orphans property only affects block-level elements.
By default, widow and orphan control is already enabled when you first install and launch Contributor.
I recently ran into this problem in my angular app and used some regex I found on this post to add a non-breaking space before the last word:
String.replace(/\s([^\s<]+)\s*$/,\' \;$1');
But angular was printing the non-breaking space as a string so I used unicode and it worked great:String.replace(/\s([^\s<]+)\s*$/,'\u00A0$1');
Adobe has stepped up and decided this is a serious issue on the web. They have put forward a proposal to help fix widows/orphans and other text balancing typography issues.
The repository for their jQuery plugin is here: https://github.com/adobe-webplatform/balance-text
The proposal to the w3c was here: http://adobe-webplatform.github.io/balance-text/proposal/index.html
It has since been adopted into the CSS Text Module Level 4 Editor's Draft.
I believe you're describing typographic widows in an HTML document? Where a single word wraps around onto a new line in a header, for example?
The jQuery Widon't plugin goes through your HTML looking for this and puts a non-breaking space between the second-last and last words to ensure that at least two words wrap to a new line.
Hope this helps, Karl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With