Convert between Markdown elements
<p>What are the options to parse Markdown document and process its elements to  output an another Markdown document?</p>

<p>Let's say it</p>

<pre><code>```
# unaffected #
```

# H1 #

H1
==

## H2 ##

H2
--

### H3 ###
</code></pre>

<p>should be converted to</p>

<pre><code>```
# unaffected #
```

## H1 ##

H1
--

### H2 ###

### H2 ###

#### H3 ####
</code></pre>

<p>in Node environment. Target element may vary (e.g. #### may be converted to **).</p>

<p>The document may contain other markup elements that should remain unaffected.</p>

<p>How it can be obtained? Obviously, not with regexps (using regexp instead of full-blown lexer will affect <code># unaffected #</code>). I was hoped to use <code>marked</code> but it seems that it is capable only of HTML output, not Markdown.</p>