From 1b8a9711b8ca84d2e557f59c137c7cb025fbd2d0 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 19 Jan 2011 15:14:23 -0800 Subject: Replaced more noneOf/oneOf parsers. --- src/Text/Pandoc/Readers/Markdown.hs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index e3258f1a9..30106e1ba 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -72,6 +72,12 @@ isHruleChar _ = False setextHChars :: [Char] setextHChars = "=-" +isBlank :: Char -> Bool +isBlank ' ' = True +isBlank '\t' = True +isBlank '\n' = True +isBlank _ = False + -- -- auxiliary functions -- @@ -212,7 +218,7 @@ referenceKey = try $ do optional nl skipMany spaceChar notFollowedBy' reference - many1 (noneOf " \t\n") + many1 (satisfy $ not . isBlank) let betweenAngles = try $ char '<' >> manyTill (noneOf ">\n" <|> nl) (char '>') src <- try betweenAngles <|> sourceURL @@ -236,7 +242,7 @@ referenceTitle = try $ do return $ decodeCharacterReferences tit noteMarker :: GenParser Char ParserState [Char] -noteMarker = string "[^" >> many1Till (noneOf " \t\n") (char ']') +noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']') rawLine :: GenParser Char ParserState [Char] rawLine = do @@ -405,7 +411,7 @@ keyValAttr = try $ do key <- identifier char '=' char '"' - val <- manyTill (noneOf "\n") (char '"') + val <- manyTill (satisfy (/='\n')) (char '"') return ("",[],[(key,val)]) codeBlockDelimited :: GenParser Char st Block @@ -975,7 +981,7 @@ mathChunk :: GenParser Char st [Char] mathChunk = do char '\\' c <- anyChar return ['\\',c] - <|> many1 (noneOf " \t\n\\$") + <|> many1 (satisfy $ \c -> not (isBlank c || c == '\\' || c == '$')) math :: GenParser Char ParserState Inline math = (mathDisplay >>= applyMacros' >>= return . Math DisplayMath) @@ -1108,7 +1114,7 @@ source' = do skipMany spaceChar optional nl skipMany spaceChar - many1 (noneOf " \t\n") + many1 (satisfy $ not . isBlank) let betweenAngles = try $ char '<' >> manyTill (noneOf ">\n" <|> nl) (char '>') src <- try betweenAngles <|> sourceURL -- cgit v1.2.3