git.iko.soy/typeable/pandoc
on master help sign in
HTML reader: don't parse raw HTML inside <code> tag.

Previously '<code><a>x</a></code>' would be parsed as Code "<a>x</a>", which is not what you want.

commitca51bbbf166b8fd5d835426e1f499d251f2c110c authorJohn MacFarlane <jgm@berkeley.edu> dateThu 11 Nov 2010, 20:02 (16 years ago) parent21556e3
2 files changed+5−5
src/Text/Pandoc/Readers/HTML.hs+2−2 tests/html-reader.html+3−3
src/Text/Pandoc/Readers/HTML.hs+2−2
@@ -686,8 +686,8 @@ inline = choice [ charRef
686686
687687code :: GenParser Char ParserState Inline
688688code = try $ do
689− result <- (htmlOpenTag "code" >> manyTill anyChar (htmlEndTag "code"))
690− <|> (htmlOpenTag "tt" >> manyTill anyChar (htmlEndTag "tt"))
689+ result <- (htmlOpenTag "code" >> manyTill (noneOf "<>") (htmlEndTag "code"))
690+ <|> (htmlOpenTag "tt" >> manyTill (noneOf "<>") (htmlEndTag "tt"))
691691 -- remove internal line breaks, leading and trailing space,
692692 -- and decode character references
693693 return $ Code $ decodeCharacterReferences $ removeLeadingTrailingSpace $
tests/html-reader.html+3−3
@@ -340,7 +340,7 @@ foo<p>This should just be an HTML comment:</p>
340340<p>So is <strong><em>this</em></strong> word.</p>
341341<p><strong><em>This is strong and em.</em></strong></p>
342342<p>So is <strong><em>this</em></strong> word.</p>
343−<p>This is code: <code>></code>, <code>$</code>, <code>\</code>, <code>\$</code>, <code>&lt;html></code>.</p>
343+<p>This is code: <code>&gt;</code>, <code>$</code>, <code>\</code>, <code>\$</code>, <code>&lt;html&gt;</code>.</p>
344344<hr />
345345<h1>Smart quotes, ellipses, dashes</h1>
346346<p>"Hello," said the spider. "'Shelob' is my name."</p>
@@ -442,8 +442,8 @@ Email link (nobody [at] nowhere.net)<p><a href="">Empty</a>.</p>
442442An e-mail address: nobody [at] nowhere.net<blockquote>
443443<p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>
444444</blockquote>
445−<p>Auto-links should not occur here: <code>&lt;http://example.com/></code></p>
446−<pre><code>or here: &lt;http://example.com/>
445+<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
446+<pre><code>or here: &lt;http://example.com/&gt;
447447</code></pre>
448448<hr />
449449<h1>Images</h1>