From 513b16a71b30a04cc91c056a22e2761f7ea554d2 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 24 Oct 2017 09:53:29 -0700 Subject: Fenced divs: ensure that paragraph at end doesn't become Plain. Added test case. --- src/Text/Pandoc/Readers/Markdown.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 221c834e8..a27e05fed 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1027,6 +1027,11 @@ para = try $ do Just "div" -> () <$ lookAhead (htmlTag (~== TagClose "div")) _ -> mzero + <|> do guardEnabled Ext_fenced_divs + divLevel <- stateFencedDivLevel <$> getState + if divLevel > 0 + then lookAhead divFenceEnd + else mzero return $ do result' <- result case B.toList result' of @@ -1689,7 +1694,7 @@ endline = try $ do notFollowedBy (() <$ (lookAhead (char '`') >> codeBlockFenced)) guardDisabled Ext_fenced_divs <|> do divLevel <- stateFencedDivLevel <$> getState - guard (divLevel < 1) <|> notFollowedBy fenceEnd + guard (divLevel < 1) <|> notFollowedBy divFenceEnd notFollowedByHtmlCloser (eof >> return mempty) <|> (guardEnabled Ext_hard_line_breaks >> return (return B.linebreak)) @@ -1946,12 +1951,12 @@ divFenced = try $ do skipMany (char ':') blankline updateState $ \st -> st{ stateFencedDivLevel = stateFencedDivLevel st + 1 } - bs <- mconcat <$> manyTill block fenceEnd + bs <- mconcat <$> manyTill block divFenceEnd updateState $ \st -> st{ stateFencedDivLevel = stateFencedDivLevel st - 1 } return $ B.divWith attribs <$> bs -fenceEnd :: PandocMonad m => MarkdownParser m () -fenceEnd = try $ do +divFenceEnd :: PandocMonad m => MarkdownParser m () +divFenceEnd = try $ do nonindentSpaces string ":::" skipMany (char ':') -- cgit v1.2.3