Number Munging, v2.11

Download (Zip File)
Download (Plain Text)

Installation

Just drop the .PL file in your plugins folder and chmod 755. If you don't have a plugins folder, create one in the same folder as the mt.cgi file.

What It Does

The MT plugin contains three global tag attributes. You can insert them into any tag. For example: <$MTEntryDate strip_whitespace="leading" convert_to_roman="1"$>

strip_whitespace="1"Trim blank spaces from the start and end.
MT now does this with trim="1"
Example: " rutabega " => "rutabega"
strip_whitespace="leading"Trim blank spaces from only the start.
MT now does this with ltrim="1"
Example: " rutabega " => "rutabega "
strip_whitespace="trailing"Trim blank spaces from only the end.
MT now does this with rtrim="1"
Example: " rutabega " => " rutabega"
convert_to_roman="1"Convert all digits into roman numerals.
Example: "13 October 1998" => "XIII October MCMXCVIII"
convert_to_roman="lowercase"Convert all digits into lowercase roman numerals.
Example: "13 October 1998" => "xiii October mcmxcviii"
convert_to_base="2-16"Convert all digits (presumed to be base-10) into base-X numerals, where X is in the range 2-16.
Example: "Thirty in base-sixteen format is 30." => "Thirty in base-sixteen format is 1E."

Why?

I created the strip_whitespace command because the only default options for dates of a month are either "01" or " 1", and I wanted to have things like [1 March 2003] on my blog.

As for the Roman numerals? It's something I thought I could use in the future. The convert-to-base option might be useful in some cases, too.

Version History

v1.0 - Original version. [28 March 2003]

v1.1 - Name changed from "Lazy Plugins" to "Number Munging". [6 July 2003]

v2.0 - Added convert_to_base global attribute. [5 August 2005]

v2.1 - Internal changes; plugin now appears on front page of MT installations. [16 August 2005]

v2.11 - Cleaned up some code. [19 August 2005]

This plugin is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.
To contact the author, send mail to the "webmaster" of this domain.