From 1a06f0ecfb5a4898daf2769f4c072fa12bae6d39 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Mon, 5 Feb 2018 01:44:31 +0300 Subject: Muse reader: make block parsers responsible for parsing newline Block parsers must always stop after newline or at the end of file. --- src/Text/Pandoc/Readers/Muse.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index 1d4b9cc89..63dcac122 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -166,6 +166,7 @@ parseHtmlContent :: PandocMonad m parseHtmlContent tag = do (attr, content) <- htmlElement tag parsedContent <- parseContent (content ++ "\n") + manyTill spaceChar eol -- closing tag must be followed by optional whitespace and newline return (attr, mconcat parsedContent) where parseContent = parseFromString $ manyTill parseBlock endOfContent @@ -229,7 +230,6 @@ directive = do parseBlock :: PandocMonad m => MuseParser m (F Blocks) parseBlock = do res <- blockElements <|> para - optionMaybe blankline trace (take 60 $ show $ B.toList $ runF res def) return res @@ -338,7 +338,7 @@ quoteTag = do st <- getState let oldInQuote = museInQuote st setState $ st{ museInQuote = True } - res <- snd <$> (parseHtmlContent "quote") + res <- snd <$> parseHtmlContent "quote" setState $ st{ museInQuote = oldInQuote } return $ B.blockQuote <$> res @@ -373,7 +373,9 @@ para = do indent <- length <$> many spaceChar st <- museInList <$> getState let f = if not st && indent >= 2 && indent < 6 then B.blockQuote else id - fmap (f . B.para) . trimInlinesF . mconcat <$> many1Till inline endOfParaElement + res <- fmap (f . B.para) . trimInlinesF . mconcat <$> many1Till inline endOfParaElement + manyTill spaceChar eol + return res where endOfParaElement = lookAhead $ try (eof <|> newBlockElement) newBlockElement = blankline >> void blockElements -- cgit v1.2.3