From 5d74932578ddaa564eae88158bfb4c7f92dc7dd5 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 23 Aug 2017 09:12:34 +0300 Subject: Muse reader: avoid crashes on multiparagraph inline tags (#3866) Test checks that behavior is consistent with Amusewiki --- src/Text/Pandoc/Readers/Muse.hs | 4 ++-- test/Tests/Readers/Muse.hs | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index f64f9d04f..74622a639 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -129,7 +129,7 @@ parseHtmlContentWithAttrs :: PandocMonad m => String -> MuseParser m a -> MuseParser m (Attr, [a]) parseHtmlContentWithAttrs tag parser = do (attr, content) <- htmlElement tag - parsedContent <- try $ parseContent (content ++ "\n") + parsedContent <- parseContent (content ++ "\n") return (attr, parsedContent) where parseContent = parseFromString $ nested $ manyTill parser endOfContent @@ -536,7 +536,7 @@ inlineTag :: PandocMonad m => (Inlines -> Inlines) -> String -> MuseParser m (F Inlines) -inlineTag f s = do +inlineTag f s = try $ do res <- parseHtmlContent s inline return $ f <$> mconcat res diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs index dac980c90..8d4ad0b15 100644 --- a/test/Tests/Readers/Muse.hs +++ b/test/Tests/Readers/Muse.hs @@ -60,6 +60,16 @@ tests = , "Tag soup" =: "foo bar baz" =?> para "foo bar baz" + -- Both inline tags must be within the same paragraph + , "No multiparagraph inline tags" =: + T.unlines [ "First line" + , "Second line" + , "" + , "Fourth line" + ] =?> + para "First line Second line" <> + para "Fourth line" + , "Linebreak" =: "Line
break" =?> para ("Line" <> linebreak <> "break") , "Code" =: "=foo(bar)=" =?> para (code "foo(bar)") -- cgit v1.2.3