Markdown Supported in Theocacao Comments

After Jacob Rus mentioned in a recent comment thread that he couldn't use HTML entities in Theocacao comments, my reaction was "yes, that would be nice, but it's not a priority." Of course, what I meant is that it would take more time than I was willing to spend on it at this point.

I think some of this stems from my Cocoa-headedness, where I don't want to spend time writing code to re-solve problems which already have existing solutions. The challenge is that PHP code comes in all forms, so trying to identify a good comment-parsing library then integrate it my particular configuration could mean a lot of time.

If only there was a reasonable markup syntax which had a lot of visibility. Ah, yes. There is. Markdown, it turns out, has solved this problem. At first, it seemed that the only catch was the fact that it's written in Perl. I could wedge this into PHP, but it's not quite the approach I want. Fortunately, Michel Fortin ported Markdown to PHP.

Markdown Dropdown

So there you go. You can now comment in Markdown if you want, just make sure you select the appropriate markup language from the dropdown. For now, the default is still UBB, but I'm pretty sure that will change eventually. Markdown seems to do what I need.

This is technically "beta" quality, whatever that means. There are some rules in the site stylesheets which have nonstandard interpretations of HTML elements for the benefit of UBB, and that can cause some strange things to happen in Markdown (the code tag is the obvious example).

But yes, now you can use HTML entities if you select Markdown. Mdashes for everyone. You can even use ⌘ to display ⌘. Take a look at the Markdown Syntax page for more details.
Design Element
Markdown Supported in Theocacao Comments
Posted Mar 31, 2007 — 7 comments below


Andy Lee — Mar 31, 07 3848

Thanks! I like Markdown a lot, and use it to post to my blog. My one gripe is that I find it a pain to have to hit "Preview" and then scroll through the preview to see how it looks, and then scroll back through the Markdown input to resume editing where I left off.

I keep telling myself that someday I'll write a Cocoa control that switches, in place, between Markdown and rich text mode. Then I could ask the authors of MarsEdit and VoodooPad to use it. :)

Speaking of previews, IMO the choice of input syntax is less important than the ability to preview posts.

John Gruber — Mar 31, 07 3849

Nice. Can I ask what your strategy is for sanitizing HTML that comes in through comments?

Andy Lee — Mar 31, 07 3850

Oh, I just rely on whatever's built in at, which is where I host my blog. I hardly ever post and no one ever comments, so I've never really worried about it. In fact I had to check just now whether it has a Preview option (it doesn't).

I'm thinking of starting a new blog that would have higher visibility, as in a couple dozen readers instead of a couple (a whole order of magnitude increase!). I've been debating whether to host my own Wordpress installation or use a canned service. On the one hand there's control and the ability to fine-tune the site. On the other hand there's limited time and my own laziness.

Andy Lee — Mar 31, 07 3851

D'oh -- John, I don't know why I thought you were talking to me, but you weren't, were you?

Jacob Rus — Apr 01, 07 3858

What an excellent development! Couldn't have asked for more. And now hopefully the pretty Unicode glyphs should go through, so I can write ?E, right? Fantastic!

Jacob Rus — Apr 01, 07 3860

Ack. I'm really terrible at this. I forgot to pick markdown from the dropdown on that one. This is the last comment. I promise.


(by the way, ⌘E is really cool. It copies the current selection to the global find clipboard. Everyone should know and use it.)

Scott Stevenson — Apr 01, 07 3861 Scotty the Leopard

Nice. Can I ask what your strategy is for sanitizing HTML that comes in through comments?
I'm not sure how to give a short answer to this. There's a lot of custom code in the engine dedicated to filtering, most of which is influenced by Cocoa designs. The grunt work is handled by a combination of built-in PHP mechanisms and custom sets of regular expressions. I give the custom filters first crack, and whatever's left is handed over to Markdown.

I thought about releasing all of this stuff to the public, and I still could. It just seems like there are a number of good web frameworks in Rails and Django, and I don't want to muddy the waters unless there's a really good reason.


Comments Temporarily Disabled

I had to temporarily disable comments due to spam. I'll re-enable them soon.

Copyright © Scott Stevenson 2004-2015