aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2011-01-19 15:14:23 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2011-01-19 15:14:23 -0800
commit1b8a9711b8ca84d2e557f59c137c7cb025fbd2d0 (patch)
treee2209e7cfbcaff3b5fdd98b38434604522a40c3f /src/Text/Pandoc
parenta400cfe10f0a1c29a6dd2b3a7d2a73f25d0fa981 (diff)
downloadpandoc-1b8a9711b8ca84d2e557f59c137c7cb025fbd2d0.tar.gz
Replaced more noneOf/oneOf parsers.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs16
1 files changed, 11 insertions, 5 deletions
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