From d4b71a6423721c79852b96c4ac398dff1c7ac428 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 1 Feb 2011 22:35:27 -0800 Subject: Markdown reader: Simplified and corrected footnote block parser. --- src/Text/Pandoc/Readers/Markdown.hs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 2bfb742bd..01cc5e2e8 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -245,15 +245,17 @@ noteMarker :: GenParser Char ParserState [Char] noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']') rawLine :: GenParser Char ParserState [Char] -rawLine = do +rawLine = try $ do notFollowedBy blankline notFollowedBy' $ try $ skipNonindentSpaces >> noteMarker - contents <- many1 nonEndline - end <- option "" (newline >> optional indentSpaces >> return "\n") - return $ contents ++ end + optional indentSpaces + anyLine rawLines :: GenParser Char ParserState [Char] -rawLines = many1 rawLine >>= return . concat +rawLines = do + first <- anyLine + rest <- many rawLine + return $ unlines (first:rest) noteBlock :: GenParser Char ParserState [Char] noteBlock = try $ do @@ -263,8 +265,9 @@ noteBlock = try $ do char ':' optional blankline optional indentSpaces - raw <- sepBy rawLines (try (blankline >> indentSpaces >> - notFollowedBy blankline)) + raw <- sepBy rawLines + (try (blankline >> indentSpaces >> + notFollowedBy blankline)) optional blanklines endPos <- getPosition let newnote = (ref, (intercalate "\n" raw) ++ "\n\n") -- cgit v1.2.3