git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: avoid crashes on multiparagraph inline tags (#3866)

Test checks that behavior is consistent with Amusewiki

commit5d74932578ddaa564eae88158bfb4c7f92dc7dd5 authorAlexander <ilabdsf@gmail.com> dateWed 23 Aug 2017, 09:12 (9 years ago) parentc7d4fd8
2 files changed+12−2
src/Text/Pandoc/Readers/Muse.hs+2−2 test/Tests/Readers/Muse.hs+10
src/Text/Pandoc/Readers/Muse.hs+2−2
@@ -129,7 +129,7 @@ parseHtmlContentWithAttrs :: PandocMonad m
129129 => String -> MuseParser m a -> MuseParser m (Attr, [a])
130130parseHtmlContentWithAttrs tag parser = do
131131 (attr, content) <- htmlElement tag
132− parsedContent <- try $ parseContent (content ++ "\n")
132+ parsedContent <- parseContent (content ++ "\n")
133133 return (attr, parsedContent)
134134 where
135135 parseContent = parseFromString $ nested $ manyTill parser endOfContent
@@ -536,7 +536,7 @@ inlineTag :: PandocMonad m
536536 => (Inlines -> Inlines)
537537 -> String
538538 -> MuseParser m (F Inlines)
539−inlineTag f s = do
539+inlineTag f s = try $ do
540540 res <- parseHtmlContent s inline
541541 return $ f <$> mconcat res
542542
test/Tests/Readers/Muse.hs+10
@@ -60,6 +60,16 @@ tests =
6060
6161 , "Tag soup" =: "foo <em> bar </strong>baz" =?> para "foo <em> bar </strong>baz"
6262
63+ -- Both inline tags must be within the same paragraph
64+ , "No multiparagraph inline tags" =:
65+ T.unlines [ "First line"
66+ , "<em>Second line"
67+ , ""
68+ , "Fourth line</em>"
69+ ] =?>
70+ para "First line <em>Second line" <>
71+ para "Fourth line</em>"
72+
6373 , "Linebreak" =: "Line <br> break" =?> para ("Line" <> linebreak <> "break")
6474
6575 , "Code" =: "=foo(bar)=" =?> para (code "foo(bar)")