RST reader: Combine para/plain.

This commit is contained in:
John MacFarlane 2012-09-28 22:14:03 -04:00
parent 4b65c2041c
commit 58909aaf21

View file

@ -228,15 +228,16 @@ lineBlock = try $ do
-- note: paragraph can end in a :: starting a code block
para :: Parser [Char] ParserState Blocks
para = try $ do
result <- trimInlines . mconcat <$> many inline
newline
blanklines
case viewr (B.unMany result) of
ys :> (Str xs) | "::" `isSuffixOf` xs -> do
codeblock <- option mempty codeBlockBody
return $ B.para (B.Many ys <> B.str (take (length xs - 1) xs))
<> codeblock
_ -> return (B.para result)
result <- trimInlines . mconcat <$> many1 inline
option (B.plain result) $ try $ do
newline
blanklines
case viewr (B.unMany result) of
ys :> (Str xs) | "::" `isSuffixOf` xs -> do
codeblock <- option mempty codeBlockBody
return $ B.para (B.Many ys <> B.str (take (length xs - 1) xs))
<> codeblock
_ -> return (B.para result)
plain :: Parser [Char] ParserState Blocks
plain = B.plain . trimInlines . mconcat <$> many1 inline