**Driving on MT**: Ain’t “Typography” *Grand*?
Sunday, November 4, 2007To write this blog, I use the Markdown with SmartyPants text filter. In fact, I use Markdown pretty much anywhere I can. It’s simple to use, and looks good even when displayed as plain text.
And there’s never a reason not to use SmartyPants. It makes such a difference in how punctuation looks, even a design-blind developer like myself can see the improvement.
So when I noticed that text filters are not applied to titles, I was quite disappointed. I set out to correct it, and here’s what I came up with.
What I needed was a way to run my titles through Markdown & SmartyPants before displaying them. In my Entry Summary and Entry Detail templates, I originally had this:
<h1><a href="<$MTEntryPermalink$>"><mt:entrytitle></a></h1>
I knew there was a global tag attribute called filters
that could be used to run any tag content through a text filter, so I first tried this:
<h1><a href="<$MTEntryPermalink$>"><mt:entrytitle filters="markdown_with_smartypants"></a></h1>
Which produced the following (formatted for readability):
<h1><p><a href="http://newsgoat.com/2007/11/01/now-news-about-what-im-not-doing/">
Now, News About What I’m Not Doing</a></p></h1>
Notice the extra <p>
tag? It makes sense: I gave Markdown a single line of text—treating it as a paragraph is exactly what it was supposed to do. I started wondering how I could tell Markdown that my title’s are not paragraphs, without including extra characters in each title. It finally dawned on me that a global tag attribute should be truly global. So I tried this:
<mt:setvarblock name="markdown_title">
# <a href="<$MTEntryPermalink$>"><mt:entrytitle></a>
</mt:setvarblock>
<mt:getvar name="markdown_title" filters="markdown_with_smartypants">
And that does exactly what I want. It also means I can do things like add asterisks around words in a title to make them bold or italic—like I did, rather superfluously, on this title. I also think this opens up interesting formatting options for other areas of a Movable Type template. I’m not sure what yet, but I’ll be playing with the idea. If you have any suggestions, leave ‘em in the comments.