I've got a content-editable `<div>`.

When a correct markdown syntax is entered into the div, I need it to add the correct HTML around the outside, but preserve the markdown characters within. For instance:

```
# My H1

```

would be parsed to

```
<h1># My H1</h1>

```

This is similar to the way iA Writer behaves, and I think Byword does as well.

Anything out there that works like this?