Markdown for MT fix

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

  • Google on the desktop Google picks up Picasa, giving them an important foothold on people's PCs.
  • 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.
  • Pitching Bloggers Forget what you learned in your PR classes. Start acting like a human instead of a marketer, and the humans behind the blogs will respond.
  • 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.
  • 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.
  • More of the best »

Recently Read

Get More

Subscribe | Archives

12

Recently

Stretching your team (Jun 11)
Stretching your team is one of the best ways to improve your output, your team's happiness, and your velocity. But they'll need coaching.
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?

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