Applying Filters to Titles - Hiranyaloka/Documentation GitHub Wiki
Actually, this can be used to apply text filters to anything. In my Entry Summary and Entry Detail templates, I originally had this:
<h1><a href="<$MTEntryPermalink$>"><mt:entrytitle></a></h1>
Which works fine, but what I really wanted was to apply Smartypants to get proper punctuation. So I came up with this:
<mt:setvarblock name="markdown_title"># <a href="<$MTEntryPermalink$>"><mt:entrytitle></a></mt:setvarblock> <mt:getvar name="markdown_title" filters="markdown_with_smartypants">
Which does exactly what I want. It also means I could do things like add asterisks around words in a title to make them bold or italic.
Note, however, that if the data you're setting in <mt:SetVarBlock> is multiple lines, you'll need convert_breaks="0" on the tag where the original data comes from. Otherwise, it will have <p> tags added, and Markdown will skip their contents. For example:
<mt:SetVarBlock name="comment"><$mt:CommentBody$></mt:SetVarBlock> <$mt:Var name="comment" filters="markdown_with_smartypants"$>
...will ignore the Markdown, showing the Markdown formatting characters instead of HTML markup. While:
<mt:SetVarBlock name="comment"><$mt:CommentBody convert_breaks="0"$></mt:SetVarBlock> <$mt:Var name="comment" filters="markdown_with_smartypants"$>
...will work as expected, with Markdown adding paragraph breaks in addition to formatting markup.
Likewise, removing paragraph tags from what's intended to be a single line of text can be done with this:
<mt:SetVarBlock name="comment"><$mt:EntryTitle convert_breaks="0"$></mt:SetVarBlock> <h1><$mt:Var name="comment" filters="markdown_with_smartypants" regex_replace="/</?p>/g",""$></h1>
That will produce a Markdown-formatted single line, without surrounding <p> tags.