diff options
author | John MacFarlane <jgm@berkeley.edu> | 2010-12-10 10:47:46 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2010-12-10 10:47:46 -0800 |
commit | ee0a0953de9b864a1a0cf6d3ddd3cff60a67915a (patch) | |
tree | 08ecce7374b4034da8b048965903f0efefd545b5 /src/Text/Pandoc/Readers | |
parent | bb609a85e3db8a25fbfac30858c8637eb6664fd6 (diff) | |
download | pandoc-ee0a0953de9b864a1a0cf6d3ddd3cff60a67915a.tar.gz |
Markdown reader: Rewrote para parser for better efficiency.
This change avoids repeated parsing of inline lists for 'plain'
blocks.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 59f825808..55c7f1d57 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -650,16 +650,14 @@ isHtmlOrBlank _ = False para :: GenParser Char ParserState Block para = try $ do - result <- many1 inline - if all isHtmlOrBlank result - then fail "treat as raw HTML" - else return () - newline - blanklines <|> do st <- getState - if stateStrict st - then lookAhead (blockQuote <|> header) >> return "" - else pzero - return $ Para $ normalizeSpaces result + result <- liftM normalizeSpaces $ many1 inline + guard $ not . all isHtmlOrBlank $ result + option (Plain result) $ try $ do + newline + blanklines <|> + (getState >>= guard . stateStrict >> + lookAhead (blockQuote <|> header) >> return "") + return $ Para result plain :: GenParser Char ParserState Block plain = many1 inline >>~ spaces >>= return . Plain . normalizeSpaces |