From 82f44592ae1f2253a5f7ca52d5d3a2299e9bc7a9 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 27 Dec 2019 11:46:22 -0800 Subject: Fix parsing bug affected indented code after raw HTML. Closes #6009, #5360. --- src/Text/Pandoc/Readers/Markdown.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 9f63a1947..c09c110aa 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1094,18 +1094,20 @@ rawHtmlBlocks = do -- inline will not be parsed as inline tags oldInHtmlBlock <- stateInHtmlBlock <$> getState updateState $ \st -> st{ stateInHtmlBlock = Just tagtype } - let closer = htmlTag (\x -> x ~== TagClose tagtype) - let block' = try $ - do notFollowedBy' closer - gobbleAtMostSpaces indentlevel - block + let closer = htmlTag (~== TagClose tagtype) + let block' = try $ do + gobbleAtMostSpaces indentlevel + notFollowedBy' closer + block contents <- mconcat <$> many block' result <- - (closer >>= \(_, rawcloser) -> return ( - return (B.rawBlock "html" $ stripMarkdownAttribute raw) <> + try + (do gobbleAtMostSpaces indentlevel + (_, rawcloser) <- closer + return (return (B.rawBlock "html" $ stripMarkdownAttribute raw) <> contents <> return (B.rawBlock "html" rawcloser))) - <|> return (return (B.rawBlock "html" raw) <> contents) + <|> (return (return (B.rawBlock "html" raw) <> contents)) updateState $ \st -> st{ stateInHtmlBlock = oldInHtmlBlock } return result -- cgit v1.2.3