@@ -185,7 +185,18 @@ parseMarkdown = do
185185 -- now parse it for real...
186186 (title, author, date) <- option ([],[],[]) titleBlock
187187 blocks <- parseBlocks
188− return $ Pandoc (Meta title author date) $ filter (/= Null) blocks
188+ let doc = Pandoc (Meta title author date) $ filter (/= Null) blocks
189+ -- if there are labeled examples, change references into numbers
190+ examples <- liftM stateExamples getState
191+ let handleExampleRef :: Inline -> Inline
192+ handleExampleRef z@(Str ('@':xs)) =
193+ case M.lookup xs examples of
194+ Just n -> Str (show n)
195+ Nothing -> z
196+ handleExampleRef z = z
197+ if M.null examples
198+ then return doc
199+ else return $ processWith handleExampleRef doc
189200
190201--
191202-- initial pass for references and notes
@@ -928,10 +939,9 @@ exampleRef :: GenParser Char ParserState Inline
928939exampleRef = try $ do
929940 char '@'
930941 lab <- many1 (alphaNum <|> oneOf "-_")
931− examples <- liftM stateExamples getState
932− case M.lookup lab examples of
933− Just num -> return (Str $ show num)
934− Nothing -> pzero
942+ -- We just return a Str. These are replaced with numbers
943+ -- later. See the end of parseMarkdown.
944+ return $ Str $ '@' : lab
935945
936946symbol :: GenParser Char ParserState Inline
937947symbol = do