Richer Text, Poor Me
I missed a specific situation back when I hacked at Markdown.
Because Markdown syntax allows HTML in code blocks, encoding every < as < would also affect those in code blocks. This resulted in double encoding, i.e. &lt;, which is rendered by the browser as <—not pretty.
After discovering this during a related discussion with Sander on #foxymonkies, someone there—I believe it was sdwilsh—pointed me to Safe Markdown. Unfortunately, when I finally got that working, it didn’t seem to solve my problem at all.
Determined to find a solution, I dug into Markdown a bit deeper and found that all the encoding of code happens in Markdown_Parser’s encodeCode() function, rather unsurprisingly. Consequently, if I changed that function to return its input unchanged and did all the escaping in advance—which I was already doing—, I’d be home free.
Obviously, I could easily achieve this by extending the Markdown_Parser class. I ended up throwing everything related to comment formatting in there, including emoticons. The result is in Pwnt_Blog_CommentFormatter.
Once again, feel free to hunt for any shortcomings I may have overlooked.
Update: Actually, it’s better to put the emoticon stuff in a separate class, so Markdown and SmartyPants don’t get loaded for no reason.