A small Markdown syntax guide

A short Markdown cheat sheet, with notes on writing Markdown in WordPress and some external resources.

20.05.2014 added line break syntax 18.02.2015 added more Markdown Extra commands

This is a short post because there isn't that much to it, which is why Markdown is so useful.

In a nutshell, Markdown is an easy way to write HTML. It's not for writing entire websites, but content for websites, like this post.

Different flavors of markdown

There’s the standard syntax, and then there is GitHub-flavored Markdown (GFM). GFM is more advanced. There are also small differences between parsers. Here are some popular parsers:

  • Markdown extra (written in PHP)
  • CramDown (Ruby)
  • redcarpet (Ruby)

This post mostly covers the standard syntax and some of Markdown Extra.

Syntax

Line breaks

Use a blank line to start a new paragraph. If you want a simple line break (<br>), leave two or more spaces at the end of a line.

Autolink

<http://clubmate.fi>

Normal link

[http://clubmate.fi](clubmate.fi)

Or link references, the names can be anything, here I’m using numbers:

Lorem ipsum [my Blog][1] dolor [another link][2].
 
[1]: http://clubmate.fi
[2]: http://example.com

Lists

- Unordered list, list item 1
- Unordered list, list item 2
- Unordered list, list item 3
 
1. Ordered list, list item 1
2. Ordered list, list item 2
3. Ordered list, list item 3
4. Ordered list, list item 4
5. Ordered list, list item 5

Code (those are back-ticks, not single quotes):

`codehere`

Traditionally, you'd make code blocks by inserting four spaces in front of the line.

 
└─┬─┘
  └── Believe it or not, there are 4 space there

In Markdown Extra (a flavor of Markdown), fenced code blocks are possible with backticks:

```
<span class"something">Hello!</span>
```

Bold

**Bold text**

Emphasised

_Emphasised text_

Headers

# H1
 
## h2
 
### h3

Images:

![Alt text](/path/to/img.jpg)

Definition lists, this is specific to Markdown Extra:

Apple
  : Pomaceous fruit of plants of the genus Malus in
    the family Rosaceae.
  : An American computer company.
Orange
  : The fruit of an evergreen tree of the genus Citrus.

That’s the very basics of Markdown.

For WordPress

External resources