Markdown for MT fix
Freshness Warning
This blog post is over 18 years old. It's possible that the information you read below isn't current and the links no longer work.
17 Feb 2006
I’ve gotten in the habit of writing everything in Markdown. Documents I write are done in Markdown first, and if I need to send a "pretty" version to someone, it get’s turned into HTML and copied into OpenOffice.org. Most of the time the OO.o version isn’t even saved. There’s a long list of advantages to this, but that’s another post for another time.
I’d tried writing blog entries in Markdown using the Markdown plugin for Movable Type, but on entries without an Extended Entry, my "Read more" link appeared anyway, as if there was something in the extended entry anyway.
Today I got around to looking into it. When Markdown is done processing the text, it takes the resulting output and adds a newline (\n) to it. If the text is empty, it still gets a newline appended.
The fix was simple. If the text is empty, then just return it before doing any Markdown processing. Here’s a patch:
--- Markdown.pl 2004-12-14 22:57:42.000000000 -0800
+++ Markdown-fixed.pl 2006-02-17 11:33:02.000000000 -0800
@@ -231,6 +231,8 @@
# and <img> tags get encoded.
#
my $text = shift;
+ return $text
+ if $text eq '';
# Clear the global hashes. If we don’t clear these, you get conflicts
# from other articles when generating a page which contains more than