diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-08-28 02:33:53 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-08-28 02:33:53 +0000 |
commit | 1d8fe2653a7e67da06c15588a5940b20b0d8587e (patch) | |
tree | 32ce92f65f3371e0ae5862ca24f95d7ebd1c844f /src | |
parent | 08fbfa37cc5bb506fabc532657d603c138b5c474 (diff) | |
download | pandoc-1d8fe2653a7e67da06c15588a5940b20b0d8587e.tar.gz |
Performance improvements:
+ Rearranged parsers in definition of 'inline' so that the most
frequently used would (by and large) be tried first.
+ Removed some unneeded 'try's.
+ Removed tabchar parser, as whitespace handles tabs anyway.
+ All in all, these changes, together with the last two commits,
cut almost in half the time it takes pandoc to parse a large test file.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@924 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index ed447e9c6..eedf0311d 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -617,6 +617,11 @@ table = failIfStrict >> (simpleTable <|> multilineTable) <?> "table" inline = choice [ rawLaTeXInline' , escapedChar + , smartPunctuation + , linebreak + , endline + , whitespace + , str , charRef , note , inlineNote @@ -631,15 +636,9 @@ inline = choice [ rawLaTeXInline' , strikeout , superscript , subscript - , smartPunctuation , code - , ltSign , symbol - , str - , linebreak - , tabchar - , whitespace - , endline ] <?> "inline" + , ltSign ] <?> "inline" escapedChar = try $ do char '\\' @@ -649,10 +648,11 @@ escapedChar = try $ do else satisfy (not . isAlphaNum) return $ Str [result] -ltSign = try $ do - notFollowedBy (noneOf "<") -- continue only if it's a < - notFollowedBy' rawHtmlBlocks -- don't return < if it starts html - char '<' +ltSign = do + st <- getState + if stateStrict st + then char '<' + else notFollowedBy' rawHtmlBlocks >> char '<' -- unless it starts html return $ Str ['<'] specialCharsMinusLt = filter (/= '<') specialChars @@ -760,8 +760,6 @@ emDash = try $ skipSpaces >> oneOfStrings ["---", "--"] >> whitespace = (many1 (oneOf spaceChars) >> return Space) <?> "whitespace" -tabchar = tab >> return (Str "\t") - -- hard line break linebreak = try $ oneOf spaceChars >> many1 (oneOf spaceChars) >> endline >> return LineBreak |