update regex for code blocks

Move away from consuming any number of blank lines before the code block
to forcing a single blank line or the start of the file.

i.e. code blocks have to be like

```code
x = 1
```

blah blah blah.

and not like
```code
x = 1
```
blah blah blah.

This is consistent with other markdown specs e.g. pandoc.

This required implementing a pre processor for text blocks (like we
already have for code blocks), which is currently only used to strip
excess blank lines from the start and end of the markdown text (which
are left there because of the new code regex).
wip: convert notebook to markdown

TODO:
- write code attributes into markdown
- strip outputs from notebook
- write outputs into json code cell

This allows us to roundtrip notebooks, i.e go from
markdown -> notebook json-> markdown with no change.

This is done using a slightly modified markdown template
`templates/markdown.tpl`. This is enabled via

    notedown example.ipynb --reverse

or equally

    ipython nbconvert example.ipynb --to markdown \
                                    --template templates/markdown.tpl
include cell outputs in markdown output

enable with `--with_outputs` switch

e.g.

    notedown r-examples/r-example.ipynb --reverse
    notedown r-examples/r-example.ipynb --reverse --with_outputs
implement pandoc attributes and reading inputs

Now we can read outputs that have been written to markdown, as long as
they use a special syntax. The input / output cells are represented by
two consecutive code blocks, the second of which must have pandoc
attributes containing the classes `.json` and `.output`. i.e. like this:

```{.python .input}
code
```

```{.json .output}
outputs
```

This is enabled by allowing pandoc attributes on code blocks.