Content last modified Monday 6 March 2017
hop to #bottom
Categories:
Author:
Current version:
1.0
About It:
Get it:
Rate it:
  • Helpful?
  • 1 Yes
  • 0 No
Flag it:

If you'd like to provide updated information and do not have access to directly edit, please contact the site admin; thanks!

cnn_title_case

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.

Adam Nolley, ported it to PHP for use as a Wordpress plugin, and I thought it might be useful to wrap Adam’s function up into a Textpattern plugin.

Download:

cnn_title_case-1.0.txt

Usage:

You can use in an article form to title case the article’s title like this:

<txp:cnn_title_case><txp:title /></txp:cnn_title_case>
Article Request Count:
Keywords/tags:
Initially released:
8/8/08
Posted here:
20 Aug 2008
Article modified:
12 Dec 2009

You may want to leave your comments/questions at the Forum thread for quicker feedback. Otherwise, comment away:

Your comment will NOT be submitted until you click the 'Submit' button on the next pageload.

Commented (4)

Was waiting for someone to port this. Thank you.

Nice plugin indeed, but it seems like this is not for non-English websites.

Indeed, this plugin is fundamentally English only.

I imagine that other languages could benefit from a plugin like this, but someone else will have to write it; I barely know the grammar rules of my own language.

There’s some difficulties if this plugin is used with words that have umlauts in them. If the word has an umlaut, like ä or ö, the next letter after it is put in uppercase. For example here’s an s that should be in lowercase:

JyväSkylä

Subscribe to this article's comments RSS feed. [ ? ]   View Recent Comments across the site.

You know you want to visit the Archives.

Browse

Categories


Articles

There are also tag clouds, 'cause those are fun.
Published with Textpattern