Markdown for MT fix

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

  • How not to apply for a job Applying for a job isn't that hard, but it does take some minimal effort and common sense.
  • Simplified Form Errors One of the most frustrating experiences on the Web is filling out forms. When mistakes are made, the user is often left guessing what they need to correct. We've taken an approach that shows the user in no uncertain terms what needs to be fixed.
  • The best of 2006 I wrote a lot of drivel in 2006. Here's the things that are less crappy than the rest.
  • 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.
  • Debunking predictions Read/Write Web's authors have some goofy predictions.
  • More of the best »

Recently Read

Get More

Subscribe | Archives

11

Recently

Physical camera shutter for Cisco Spark Board (Jul 6)
A 3d printable design for a camera shutter for a Cisco Spark Board
My Travel Coffee Setup (Jan 20)
What my travel coffee brewing setup looks like, and how you can build your own for under $100.
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.

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-2017 Adam Kalsey.
Content management by Movable Type.