From 1b5bfced558d28d45caadc6171f9e7448f3deae1 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 7 Aug 2017 07:43:59 +0300 Subject: Muse reader: debug indented paragraph support (#3839) Take only first line indentation into account and do not start new paragraph on indentation change. --- src/Text/Pandoc/Readers/Muse.hs | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index 201a59fc0..6e4aed94e 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -186,7 +186,6 @@ blockElements = choice [ comment , orderedList , table , commentTag - , indentedBlock , noteBlock ] @@ -249,27 +248,12 @@ quoteTag = withQuoteContext InDoubleQuote $ blockTag B.blockQuote "quote" commentTag :: PandocMonad m => MuseParser m (F Blocks) commentTag = parseHtmlContent "comment" anyChar >> return mempty --- Indented block is either center, right or quote -indentedLine :: PandocMonad m => MuseParser m (Int, String) -indentedLine = try $ do - indent <- length <$> many1 spaceChar - line <- anyLine - return (indent, line) - -rawIndentedBlock :: PandocMonad m => MuseParser m (Int, String) -rawIndentedBlock = try $ do - lns <- many1 indentedLine - let indent = minimum $ map fst lns - return (indent, unlines $ map snd lns) - -indentedBlock :: PandocMonad m => MuseParser m (F Blocks) -indentedBlock = try $ do - (indent, raw) <- rawIndentedBlock - contents <- withQuoteContext InDoubleQuote $ parseFromString parseBlocks raw - return $ (if indent >= 2 && indent < 6 then B.blockQuote else id) <$> contents - +-- Indented paragraph is either center, right or quote para :: PandocMonad m => MuseParser m (F Blocks) -para = liftM B.para . trimInlinesF . mconcat <$> many1Till inline endOfParaElement +para = do + indent <- length <$> many spaceChar + let f = if indent >= 2 && indent < 6 then B.blockQuote else id + liftM (f . B.para) . trimInlinesF . mconcat <$> many1Till inline endOfParaElement where endOfParaElement = lookAhead $ endOfInput <|> endOfPara <|> newBlockElement endOfInput = try $ skipMany blankline >> skipSpaces >> eof -- cgit v1.2.3