diff options
-rw-r--r-- | src/Text/Pandoc/Readers/Muse.hs | 26 | ||||
-rw-r--r-- | test/Tests/Readers/Muse.hs | 35 |
2 files changed, 34 insertions, 27 deletions
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 diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs index 33fe2aeb3..c5c973f00 100644 --- a/test/Tests/Readers/Muse.hs +++ b/test/Tests/Readers/Muse.hs @@ -32,7 +32,7 @@ tests = [ testGroup "Inlines" [ "Plain String" =: "Hello, World" =?> - para (spcSep [ "Hello,", "World" ]) + para "Hello, World" , "Emphasis" =: "*Foo bar*" =?> para (emph . spcSep $ ["Foo", "bar"]) @@ -102,12 +102,35 @@ tests = , "5 dashes is a horizontal rule" =: "-----" =?> horizontalRule , "4 dashes with spaces is a horizontal rule" =: "---- " =?> horizontalRule ] + , testGroup "Paragraphs" + [ "Simple paragraph" =: + T.unlines [ "First line" + , "second line." + ] =?> + para "First line second line." + , "Indented paragraph" =: + T.unlines [ " First line" + , "second line." + ] =?> + para "First line second line." + -- Emacs Muse starts a blockquote on the second line. + -- We copy Amusewiki behavior and require a blank line to start a blockquote. + , "Indentation in the middle of paragraph" =: + T.unlines [ "First line" + , " second line" + , "third line" + ] =?> + para "First line second line third line" + , "Quote" =: + " This is a quotation\n" =?> + blockQuote (para "This is a quotation") + , "Multiline quote" =: + T.unlines [ " This is a quotation" + , " with a continuation" + ] =?> + blockQuote (para "This is a quotation with a continuation") + ] , "Quote tag" =: "<quote>Hello, world</quote>" =?> blockQuote (para $ text "Hello, world") - , "Quote" =: " This is a quotation\n" =?> blockQuote (para $ text "This is a quotation") - , "Multiline quote" =: T.unlines [ " This is a quotation" - , " with a continuation" - ] - =?> blockQuote (para $ text "This is a quotation with a continuation") , "Center" =: "<center>Hello, world</center>" =?> para (text "Hello, world") , "Right" =: "<right>Hello, world</right>" =?> para (text "Hello, world") , testGroup "Comments" |