Pagedown and Angle Brackets not Cooperating
<p>I'm trying to use <a href="https://code.google.com/p/pagedown/wiki/PageDown" rel="nofollow">Pagedown</a> to parse markdown (containing code sections) into html.</p>

<p>It mostly works, but I've noticed one strange behavior. If I have this in my markdown:</p>

<pre><code>`ArrayList&lt;String&gt; names = new ArrayList&lt;&gt;();`
</code></pre>

<p>The text that displays ends up being this:</p>

<pre><code>ArrayList&lt;string&gt; names = new ArrayList&amp;lt;&amp;gt;();
</code></pre>

<p>Notice that the first <code>String</code> is lower-cased, and the second <code>&lt;&gt;</code> is converted into html entities, which are not correctly displayed since they end up inside a code block.</p>

<p>If I look at the markdown that Pagedown "thinks" it's supposed to process, it gets stranger:</p>

<pre><code>`ArrayList&lt;string&gt; names = new ArrayList&amp;lt;&amp;gt;();`&lt;/string&gt;
</code></pre>

<p>Obviously, it's treating the <code>&lt;String&gt;</code> section of the code text as an html tag, and adding a closing <code>&lt;/string&gt;</code> tag. Parsing that markdown produces this html:</p>

<pre><code>&lt;code&gt;ArrayList&amp;lt;string&amp;gt; names = new ArrayList&amp;amp;lt;&amp;amp;gt;();&lt;/code&gt;
</code></pre>

<p>If I encode the angle brackets ahead of time:</p>

<pre><code>`ArrayList&amp;lt;String&amp;gt; names = new ArrayList&amp;lt;&amp;gt;();`
</code></pre>

<p>Then Pagedown simply encodes the html entities as part of the code, which is exactly what I want it to do with the angle brackets:</p>

<pre><code> &lt;code&gt;ArrayList&amp;amp;lt;String&amp;amp;gt; names = new ArrayList&amp;amp;lt;&amp;amp;gt;();&lt;/code&gt;
</code></pre>

<p>I just want to be able to throw markdown (containing code sections) into the Pagedown parser and have it output sanitized html. Here is what I'm currently doing:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript" src="Markdown.Converter.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="Markdown.Sanitizer.js"&gt;&lt;/script&gt;
&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"&gt;&lt;/script&gt;
&lt;script&gt;
    function parseMarkdown(){

        var markdown = $("#markdown").html();        

        console.log("markdown: " + markdown);

        var converter =  new Markdown.getSanitizingConverter();
            var html = converter.makeHtml(markdown);

            console.log("html: " + html);

            $("#markdown").html(html);
    }
    $(parseMarkdown);
&lt;/script&gt;
&lt;/head&gt;
&lt;body onload="parseMarkdown"&gt;
&lt;div id="markdown"&gt;
`ArrayList&lt;String&gt; names = new ArrayList&lt;&gt;();`
&lt;/div&gt;

&lt;/body&gt;

&lt;/html&gt;
</code></pre>

<p>In real life the markdown is either coming from a database (which was written using the Pagedown editor) or from markdown files (which were written in a basic text editor). Is there an extra step I'm missing? Is the above approach a risk of bad JavaScript being run before Markdown parses it?</p>