Title Case for Movable Type

John Gruber shared a code snippet that converts strings to Title Case. It’s actually more clever than it sounds, taking into account the need to keep a collection of small words uncapitalised, and correctly handling punctuation issues.

Here’s a version for Movable Type that can be used to automatically convert entry titles to title case. It is essentially a wrapper for John’s script that adds some functionality to deal with html entities (so it should play nice with Smarty Pants and Widon’t).

Download

Title Case for Movable Type v1.1 (2008-05-23)

Installation

Unzip the file and place TitleCase.pl in the plugins directory of your Movable Type installation.

(mthome)/plugins/TitleCase.pl

Usage

For titles, add the global filter titlecase="1" to your entry title tags:

<mt:EntryTitle titlecase="1"/>

Comments

1.

Brook Elgie - 23rd May 2008, 10.07 PM

I’ve updated this to v1.1, with a small change to make the plugin behave better with future versions of MT4. There has been no change to the functionality.

However, this change does mean the plugin is no longer compatible with previous versions of Movable Type, so if you’re using MT3, feel free to download Title Case v1.0 which should work for you.

2.

Jesper Hills - 13th Feb 2009, 5.40 PM

For instances where text-transform: capitalize; just doesn’t cut it anymore?

3.

Brook Elgie - 13th Feb 2009, 6.29 PM

It depends which style you want to achieve. Using text-transform:capitalize will capitalise all words. Title Case will try to be smart about it and exclude a list of small words in keeping with typographic conventions used by some people.

Post a new comment



Comment preview: