pf » Widon't and Widows
September 05, 2006
Widon't and Widows

Shaun Innman posted about a technique he call's Widon't, for dealing with the widow problem on the web.
The widow problem is when you have a single word on a line by itself, at the end of a headline or paragraph. In typesetting this word is called a widow.
For example:
Man Walks On Moon
Moon is the widow in the above example. Shaun fixes this by replacing the last space with an He provides a function in PHP, but here's a simple regular expression for ColdFusion to do the same:
ReReplace(headline, " ([^ ]+)$", " \1")
It can get a bit trickier to fix this at the end of paragraphs, here's another regular expression that might work for that (need to test more):
ReReplace(text, " ([^ ]+\r?\n)", " \1", "ALL")
Permalink | Add Comment |
add to del.icio.us
| Tags: text, type, typesetting, regex, rereplace, widows, widont
add to del.icio.us
| Tags: text, type, typesetting, regex, rereplace, widows, widont
Related Entries
- Auto-Linking Comments - June 24, 2005
- Regex to Replace Multiple Blank Lines with One - May 19, 2005
Trackback Address: 580/A677953F3B81727C60332A384A9F3299
Comments
On 10/30/2006 at 9:27:05 PM MST Ryan Smith wrote:
1
Nice solution for IE but I haven't had any luck with in Firefox
On 12/26/2006 at 9:19:25 AM MST hogan wrote:
2
Marvelous. Thanks, will spread this among my friends!
On 12/26/2006 at 5:08:25 PM MST intial wrote:
3
Marvelous. Thanks, will spread this among my friends!
On 12/26/2006 at 7:07:32 PM MST jewerly wrote:
4
Marvelous. Thanks, will spread this among my friends!
- CFSCRIPT Cheatsheet
- 3 New Image Effects for ColdFusion 8
- Googlebot to Submit Web Forms
- ColdFusion 8 Update 1 Fixes some Image Processing Quirks
- 10 Most Useful Image Functions in ColdFusion 8
- Speaking at NYC CFUG This Week
- Adobe AIR Tutorial for HTML / JavaScript Developers
- INFORMATION_SCHEMA Support in MySQL, PostgreSQL
Subscribe to my RSS Feed:
RSS
RSS
Pete Freitag is a software engineer, and web developer located in









