By John Gruber
Become smarter in just 5 minutes. Subscribe to Morning Brew.
[Update 9 August 2015: The current version of my personal title casing script is available here on Gist.]
Back in May, I published a Perl script I wrote for properly title-casing text. Its main trick was in being smart about “small words” that should not be capitalized even in title case.
The source code itself is, uh, rather convoluted, to say the least. It’s one of those pieces of code that started small and simple, and grew ugly over time as edge cases were worked around one at a time. I’ve been using this script for years, but have put off publishing it on the grounds that it looks like the sort of punctuation-riddled code that gives Perl phobics the heebie-jeebies.
Aristotle Pagaltzis was kind enough to take my Perl script and refactored it in a straightforward and logical way, fixing some of the edge conditions along the way. He took Gouch’s test cases and turned them into a proper testing suite. The result is better than my original script in every way, and his test suite can be used to improve any implementation.
My thanks to everyone who pitched in on these scripts, and to David Gouch and Aristotle Pagaltzis especially.