diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2009-04-29 19:28:39 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2009-04-29 19:28:39 +0000 |
commit | e203c562d6f41e1d090e3470469d6b84069bc6da (patch) | |
tree | 33d5b617d246b6b8013a83d3367a6a03d3790af0 /src/Text/Pandoc/Readers/Markdown.hs | |
parent | 5182381084f3d03499a3dec70dadf6c8e9930366 (diff) | |
download | pandoc-e203c562d6f41e1d090e3470469d6b84069bc6da.tar.gz |
Improved efficiency of whitespace parser.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1565 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc/Readers/Markdown.hs')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 38a600abe..be9c4cfd5 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -55,9 +55,6 @@ readMarkdown state s = (readWith parseMarkdown) state (s ++ "\n\n") -- Constants and data structure definitions -- -spaceChars :: [Char] -spaceChars = " \t" - bulletListMarkers :: [Char] bulletListMarkers = "*+-" @@ -325,7 +322,7 @@ hrule = try $ do skipSpaces start <- oneOf hruleChars count 2 (skipSpaces >> char start) - skipMany (oneOf spaceChars <|> char start) + skipMany (spaceChar <|> char start) newline optional blanklines return HorizontalRule @@ -634,7 +631,7 @@ htmlBlock :: GenParser Char ParserState Block htmlBlock = try $ do failUnlessBeginningOfLine first <- htmlElement - finalSpace <- many (oneOf spaceChars) + finalSpace <- many spaceChar finalNewlines <- many newline return $ RawHtml $ first ++ finalSpace ++ finalNewlines @@ -939,12 +936,12 @@ strikeout = failIfStrict >> enclosed (string "~~") (try $ string "~~") inline >> superscript :: GenParser Char ParserState Inline superscript = failIfStrict >> enclosed (char '^') (char '^') - (notFollowedBy' whitespace >> inline) >>= -- may not contain Space + (notFollowedBy spaceChar >> inline) >>= -- may not contain Space return . Superscript subscript :: GenParser Char ParserState Inline subscript = failIfStrict >> enclosed (char '~') (char '~') - (notFollowedBy' whitespace >> inline) >>= -- may not contain Space + (notFollowedBy spaceChar >> inline) >>= -- may not contain Space return . Subscript abbrev :: GenParser Char ParserState Inline @@ -1053,17 +1050,15 @@ emDash :: GenParser Char st Inline emDash = oneOfStrings ["---", "--"] >> return EmDash whitespace :: GenParser Char ParserState Inline -whitespace = do - sps <- many1 (oneOf spaceChars) - if length sps >= 2 - then option Space (endline >> return LineBreak) - else return Space <?> "whitespace" +whitespace = spaceChar >> + ( (spaceChar >> skipMany spaceChar >> option Space (endline >> return LineBreak)) + <|> (skipMany spaceChar >> return Space) ) <?> "whitespace" nonEndline :: GenParser Char st Char nonEndline = satisfy (/='\n') strChar :: GenParser Char st Char -strChar = noneOf (specialChars ++ spaceChars ++ "\n") +strChar = noneOf (specialChars ++ " \t\n") str :: GenParser Char st Inline str = many1 strChar >>= return . Str |