From f74dda27b6d6a6425cc62d7c9c7c943b69f2d9db Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sat, 29 Dec 2007 06:30:12 +0000 Subject: Markdown reader: Make 'block' conditional on strictness state, instead of using failIfStrict in block parsers. Use a different ordering of parsers in strict mode: raw HTML block before paragraph. This recovers performance that was lost in strict mode with r1154. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1157 788f1e2b-df1e-0410-8736-df70ead52e1b --- Text/Pandoc/Readers/Markdown.hs | 48 +++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 21 deletions(-) (limited to 'Text') diff --git a/Text/Pandoc/Readers/Markdown.hs b/Text/Pandoc/Readers/Markdown.hs index e9befec12..6ff5ce17c 100644 --- a/Text/Pandoc/Readers/Markdown.hs +++ b/Text/Pandoc/Readers/Markdown.hs @@ -226,17 +226,32 @@ noteBlock = try $ do parseBlocks = manyTill block eof -block = choice [ header - , table - , codeBlock - , hrule - , list - , blockQuote - , rawLaTeXEnvironment' - , para - , htmlBlock - , plain - , nullBlock ] "block" +block = do + st <- getState + choice (if stateStrict st + then [ header + , codeBlock + , hrule + , bulletList + , orderedList + , blockQuote + , htmlBlock + , para + , plain + , nullBlock ] + else [ header + , table + , codeBlock + , hrule + , bulletList + , orderedList + , definitionList + , blockQuote + , rawLaTeXEnvironment + , para + , htmlBlock + , plain + , nullBlock ]) "block" -- -- header blocks @@ -314,8 +329,6 @@ blockQuote = do -- list blocks -- -list = choice [ bulletList, orderedList, definitionList ] "list" - bulletListStart = try $ do optional newline -- if preceded by a Plain block in a list context nonindentSpaces @@ -434,7 +447,6 @@ defRawBlock = try $ do return $ firstline ++ "\n" ++ unlines rawlines ++ trailing definitionList = do - failIfStrict items <- many1 definitionListItem let (terms, defs) = unzip items let defs' = compactify defs @@ -502,12 +514,6 @@ rawHtmlBlocks = do else combined return $ RawHtml combined' --- --- LaTeX --- - -rawLaTeXEnvironment' = failIfStrict >> rawLaTeXEnvironment - -- -- Tables -- @@ -629,7 +635,7 @@ alignType strLst len = (True, True) -> AlignCenter (False, False) -> AlignDefault -table = failIfStrict >> (simpleTable <|> multilineTable) "table" +table = simpleTable <|> multilineTable "table" -- -- inline -- cgit v1.2.3