Tag: porting
-
Shaun Inman’s Widon’t Ported to Javascript
—
by
I was working on some pull-quote magic today (more on that later) and needed to de-widow a string in Javascript a la Shaun Inman’s Widon’t. So I ported it to Javascript. Here’s the magic: String.prototype.widont = function() { return this.replace(/([^\s])\s+([^\s]+)\s*$/, ‘$1 $2’); } // end widont() To use this simply call the widont() method on a…