Modifying MT-Textile

Most of my entries to this and other blogs are written using Brad Choate’s MT-Textile plugin. As much as I enjoy the plugin, there are two things that have annoyed me slightly with MT-Textile, and I’ve modified the MT-Textile code to change them.

The first change is that words written in uppercase are enclosed in <span class=”caps”>. For my personal use, this is undesireable, as I don’t use it for anything. If you want to remove this, locate line number 187 in textile.pm. It reads # ABC -> 'capped' span. Comment out the line below.

The second change is a change that enables me to distinguish between abbreviations and acronyms when writing. For an explanation of why I want this, read Craig Saila’s HTML is not an acronym.

So I’ve made a modification so I can write CSS[Cascading Style Sheets] and get <abbr title="Cascading Style Sheets">CSS</abbr> as result output.

To do the change, insert this above the <span /> we just removed:

# CSS[Cascading Style Sheets] -> abbr
$text =~ s|([A-Z][A-Z0-9]+)\[(.+?)\]|_repl($repl,qq{
<abbr title="$2">$1</abbr>})|ge;

Please note that what starts with $text =~ and ends with |ge; is supposed to be on one line. I’ve just inserted a linebreak to improve readability.

Comments are closed.