May 11, 2015

Poetry & Markdown for What?

I’m a novice when it comes to poetry, but striving to learn more, read more and more thoughtfully consume text. Of course, the first thing I do is turn to code.

I use Github pages wth Jekyll to run this site. It’s great because it gives me the lightweight CMS that I need that’s mostly just writing text but occasionally writing code, with switching between the two seamless and easy.

Unfortuantely, Github pages uses markdown and I’m not expert on Markdown. It seems like it screws up poetry. Newlines in Markdown aren’t respected and it just makes the whole thing go to crap.

So the following passage:

And we all say: OH!
Well I never!
Was there ever
A Cat so clever
As Magical Mr. Mistoffelees!

When copied and pasted into Markdown becomes:

And we all say: OH!Well I never!Was there everA Cat so cleverAs Magical Mr. Mistoffelees!

My solution is to use a little lightweight jQuery to reformat the text as follows:

  var text =$(this).html();
  var text = text.split("\n").join("<br />") 


This allows me to replace newline blocks with the explicit break tag forcing newlines in the HTML. This solves my solution for now. We’ll see what the future brings.

Follow along by reading my favourite poetry over on this page: /poetry.

More blog posts:

A Lil' Website Refresh

March 20, 2024

This post was written by Tom Critchlow - blogger and independent consultant. Subscribe to join my occassional newsletter: