Markdown for MT fix

Freshness Warning
This article is over 9 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 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

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.

Name:

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

Recently Read

Get More

Subscribe | Archives

9

Recently

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.
Form or function in hotel design (Nov 17)
The hotel has one of the most beautifully designed rooms I've ever stayed in. It's also the worst designed hotel room I've ever stayed in.

Subscribe to this site's feed.

Elsewhere

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

Contact

Adam Kalsey

Mobile: 916.600.2497

Email: adam AT kalsey.com

AIM or Skype: akalsey

Resume

PGP Key

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