From d28ad2b0f13d39863f3aff101e348a380f79f5d1 Mon Sep 17 00:00:00 2001
From: John MacFarlane <fiddlosopher@gmail.com>
Date: Thu, 12 Apr 2012 09:52:28 -0700
Subject: [PATCH] Markdown:  don't recognize references inside delimited code
 blocks.

Previously pandoc would produce incorrect results on this:

    ~~~
    [not a link]: /url
    ~~~

    [not a link]

because it would recognize "not a link" as a reference link
definition on the first pass.  This fix causes the first pass
to skip delimited code blocks.
---
 src/Text/Pandoc/Readers/Markdown.hs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 666265935..749963cd0 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -183,6 +183,7 @@ parseMarkdown = do
   st <- getState
   let firstPassParser = referenceKey
                      <|> (if stateStrict st then pzero else noteBlock)
+                     <|> liftM snd (withRaw codeBlockDelimited)
                      <|> lineClump
   docMinusKeys <- liftM concat $ manyTill firstPassParser eof
   setInput docMinusKeys