diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-10-24 09:53:29 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-10-24 09:53:29 -0700 |
commit | 513b16a71b30a04cc91c056a22e2761f7ea554d2 (patch) | |
tree | 6eed586aee6ab229e035b69e71eb575372cfaa5a /src/Text/Pandoc/Readers | |
parent | 312db3b851a0f3f52f535bc8762b566c2dd560b3 (diff) | |
download | pandoc-513b16a71b30a04cc91c056a22e2761f7ea554d2.tar.gz |
Fenced divs: ensure that paragraph at end doesn't become Plain.
Added test case.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 13 |
1 files changed, 9 insertions, 4 deletions
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 ':') |