My Digital Junk Drawer

So immediately after setting up my environment to allow me to write and publish directly through TextMate, I had to follow-up and do a couple more things.

  1. I setup a basic template in TextMate so the YAML header information (post title, type of post, tags, etc.) would be pre-populated.
  2. Experimented with footnotes
  3. I ran into another problem and learned something interesting
  4. In writing this post, I had yet another problem and worked through it.

The Template

The template I setup basically just includes the YAML at the top of the file needed to specify the title, tags, type of post and format. It uses a TextMate variable to use the filename as the default post title and looks like this (this code needs to be surrounded by three hyphens above and below, but I had to remove them in order to deal with a strange issue I was having in my published post):

title: ${TM_NEW_FILE_BASENAME}
type: regular
state: queue
format: markdown
tags: 

Footnotes

As it turns out, Tumblr actually uses PHP Markdown Extra which provides some additional functionality on top of the standard Markdown syntax. One of the features of most interest to me is the ability to add footnote links. The links are added to the end of the footnoted item and the footnote automatically includes a link back up the point in the document that the footnote was referenced from. Here’s a sample footnote1.

Interesting Problem

The interesting problem I discovered came when I tried to publish a sample post to try out the footnotes for the first time. I used my template, added a bunch of lorem ipsum filler text, put a footnote reference at the top of the file and added the corresponding note at the end after the filler. I hit my shortcut to post it to my drafts folder so I could go preview it and see the footnote in action. I was greeted with the message:

Oh no! Something went wrong. Tumblr says, "Post cannot be empty."

As it turns out, if your file doesn’t have any empty lines at the bottom, this is what you get. I’m not really sure why that is, but after making several attempts to change different parts of the file, I grabbed the text from my last post that did work and pasted it in. Due to some minor form of OCD I felt the need to delete the two empty lines at the end of the file and got the same message. I sat staring at the screen frustrated for a minute and had one of those moments all too common when trying something new… I resorted to doing things that in my mind shouldn’t make any difference, and the first of those things was to put the empty lines back in the file. That did the trick. Just to make sure, I removed the spaces and tried again and got the error again. So, the lesson is that at least in my situation, Markdown files need to end with some empty lines. Maybe this is something other people already knew, but it was a lesson for me.

The Code Problem

I thought this problem was related to headings and I was wrong. As it turns out it had something to do with the YAML section I added as a code block… even though I had it indented as you’re supposed to in Markdown, it was having an issue with the three hyphens at the top and bottom of the template code I pasted… I’ll repeat it here, if you copy this and try to use it, be sure to add the three hyphens above and below the code.


  1. This is a sample footnote. This could be anything and you can place it anywhere in your markdown… the end of the document makes the most sense, so that’s what I did. Keep in mind that the rendered footnote will always be placed at the end of your document. 

  1. avanslaars posted this
Blog comments powered by Disqus