A while ago, John Gruber posted a nifty little Perl script that attempts to correctly convert text into Title Case. I’ll let Gruber explain more:
It’s pretty easy to write a non-clever title-casing function. The simplest way is to just capitalize the first letter of every word. That’s not right, though, because it’ll leave you with capitalized small words like if, in, of, on, etc. What you want is something that not only knows not to capitalize such words, but will un-capitalize them if they’re erroneously capitalized in the input.
But since it’s a Perl script, and since times are what they are (Perl??? who uses that anymore???), there was a flurry of people porting Gruber’s function into every imaginable programming language. I found one, written by Adam Nolley, that was ported into PHP for use as a Wordpress plugin.
So I thought it might be useful to wrap Adam’s function up into a Textpattern plugin.
Download:
Usage:
Use in an article form to title case the article’s title:
<txp:cnn_title_case><txp:title /></txp:cnn_title_case>