Scott Boms

Markdown Comment Formatting for MT4

In starting (somewhat) fresh with this new version of the notebook, one critical thing on the list of must do items was to finally do away with the old popup window style comments. These were a throwback and perhaps unfortunate decision made when this site was first built on Movable Type 2.x and I chose to use monthly archives as the primary archive type instead of individual entries. Hindsight is 20/20 I’ve heard…

Upgrading to Movable Type 4 and cleaning out the attic presented an opportunity to rectify this problem. The primary archive type used throughout, now individual entries, allows inline commenting without requiring popup windows. Changing the commenting behaviour provided a second opportunity — to allow the use of John Gruber’s Markdown syntax instead of vanilla HTML in the comments, something I’ve wanted to do for some time now.

Essentially this means dropping in plain old links in the comments will be converted but will definitely receive the rel="nofollow" treatment.

Why Markdown for Comments?

Why Markdown? More importantly, why not Textile?

My reasoning is simple. One — I use it myself. Every post in the notebook has been written using Markdown. Two — it’s easy to learn, use, and has the right amount of syntax flexibility in terms of what I’m willing to allow.

Movable Type 4 blog comment settings
Movable Type 4 blog comment settings

While setting up commenting to allow Markdown formatted comments I discovered a problem: certain parts of Markdown’s formatting syntax were being ignored and converted into plain text. My first thought was that this was a bug in either Markdown or in Movable Type itself, but after a bit of digging using Google and in the documentation for Movable Type itself, I recognized the problem.

Out of the box, Movable Type’s comment feature will only allow certain HTML tags to be included. Anything else will be automatically stripped out — for example: code, blockquote, h4, h5, h6. To change this behaviour, it’s simply a matter of specifying your own subset of HTML elements which will be acceptable in comments and setting the appropriate text filter in the Movable Type blog comment settings. The specific details on how to do this are:

  1. In your blog’s comment settings, choose Markdown for text formatting.
  2. Click the “Allow HTML” checkbox to enable comments to accept plain old vanilla HTML.
  3. Under the “Limit HTML Tags” options, use your own settings to specify the tags you want to allow in comments.
  4. Uncheck the “Allow HTML” checkbox one you are finished entering tags in step 3. Save your settings and rebuild you entries.

Although I haven’t tested this, I suspect the same procedure will also work if you choose to use Textile formatting for comments.