# 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

```md
<http://clubmate.fi>
```

Normal link

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

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

```md
Lorem ipsum [my Blog][1] dolor [another link][2].

[1]: http://clubmate.fi
[2]: http://example.com
```

Lists

```md
- 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):

```md
`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

```md
**Bold text**
```

Emphasised

```md
_Emphasised text_
```

Headers

```md
# H1

## h2

### h3
```

Images:

```md
![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

- [Markdown On Save Improved](http://wordpress.org/plugins/markdown-on-save-improved/)
  is pretty sweet, but deprecated
- [Jetpack](https://wordpress.org/plugins/jetpack/) has a new Markdown module
  that also supports GFM (to an extent)\*
  [Markdown On Save](http://wordpress.org/plugins/markdown-on-save/) should be a
  solid plugin also
- [GitHub-Flavored Markdown Comments](http://daringfireball.net/projects/markdown/)

## External resources

- Complete spec at
  [Daring Fireball](http://daringfireball.net/projects/markdown/)
- [GFM, GitHub Flavoured Markdown](https://help.github.com/articles/github-flavored-markdown),
  differs a bit from the normal
