Markdown for MT fix

Freshness Warning
This article is over 10 years old. It's possible that the information you read below isn't current.

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 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:

--- 2004-12-14 22:57:42.000000000 -0800
+++   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

John Gruber
February 20, 2006 8:43 AM

Perhaps it should return the empty string not just if the input is empty, but if the input consists of nothing but whitespace? Like say if you leave a stray newline all by itself in the Extended Entry field -- it seems to me Markdown ought to treat this as "empty". Regardless, thanks for the patch. I'll work this into the next update.

Your comments:

Text only, no HTML. URLs will automatically be converted to links. Your email address is required, but it will not be displayed on the site.


Not your company or your SEO link. Comments without a real name will be deleted as spam.

Email: (not displayed)

If you don't feel comfortable giving me your real email address, don't expect me to feel comfortable publishing your comment.

Website (optional):

Follow me on Twitter

Best Of

  • Rounded corners in CSS There lots of ways to create rounded corners with CSS, but they always require lots of complex HTML and CSS. This is simpler.
  • Embrace the medium The Web is different than print, television, or any other medium. To be successful, designers must embrace those differences.
  • Writing Realistic Job Descriptions Publish a job listing like this one and you are virtually guaranteeing that you won't get qualified applicants for the position.
  • Lock-in is bad T-Mobile thinks they'll get new Hotspot customers with exclusive content and locked-in devices.
  • Movie marketing on a budget Mark Cuban's looking for more cost effective ways to market movies.
  • More of the best »

Recently Read

Get More

Subscribe | Archives



Turkey Legs (May 30)
Product naming gone awry.
Speaking for Geeks: Your Slides (Dec 17)
Tips and tricks for creating great slides.
Speaking for Geeks: Writing Your Talk (Dec 14)
Don’t wait until the night before the talk to write it. Crazy, I know.
Speaking for Geeks: Tell a Story (Dec 13)
Telling a story keeps your presentation focused, keeps your audience interested, and makes it easier for you to remember your talk.
Speaking for Geeks: Where to speak (Dec 11)
You've got a great idea for a talk. How do you find conferences to submit it to?
Speaking for Geeks: Getting your session accepted (Dec 10)
Your conference speaking submissions are not getting accepted because they're bad. Here's how to make them better.
Speaking for Geeks: What Should I Talk About? (Dec 9)
Don't wait for that conference to come calling before you start planning for it.
You should speak at conferences. Yes, you. (Dec 8)
Developers, you should give talks at conferences and your local meetups. It's easier than you think, and you’ll improve your career.

Subscribe to this site's feed.


Voice and communications platforms, including Tropo and Phono. Work.
The Sacramento technology startup community.
Pinewood Freak
Pinewood Derby tips and tricks


Adam Kalsey

Mobile: 916.600.2497

Email: adam AT

AIM or Skype: akalsey



©1999-2016 Adam Kalsey.
Content management by Movable Type.