git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: allow images inside link descriptions
commitf807f5b3833e841d9e6b831acbe50f3be8e42881 authorAlexander Krotov <ilabdsf@gmail.com> dateSat 25 May 2019, 19:13 (7 years ago) parent7514277
2 files changed+7−5
src/Text/Pandoc/Readers/Muse.hs+4−5 test/Tests/Readers/Muse.hs+3
src/Text/Pandoc/Readers/Muse.hs+4−5
@@ -903,10 +903,7 @@ symbol = pure . B.str . pure <$> nonspaceChar
903903
904904-- | Parse a link or image.
905905linkOrImage :: PandocMonad m => MuseParser m (F Inlines)
906−linkOrImage = try $ do
907− inLink <- asks museInLink
908− guard $ not inLink
909− local (\s -> s { museInLink = True }) (link "URL:" <|> image <|> link "")
906+linkOrImage = try $ link "URL:" <|> image <|> link ""
910907
911908linkContent :: PandocMonad m => MuseParser m (F Inlines)
912909linkContent = trimInlinesF . mconcat
@@ -916,9 +913,11 @@ linkContent = trimInlinesF . mconcat
916913-- | Parse a link starting with (possibly null) prefix
917914link :: PandocMonad m => String -> MuseParser m (F Inlines)
918915link prefix = try $ do
916+ inLink <- asks museInLink
917+ guard $ not inLink
919918 string $ "[[" ++ prefix
920919 url <- manyTill anyChar $ char ']'
921− content <- option (pure $ B.str url) linkContent
920+ content <- option (pure $ B.str url) (local (\s -> s { museInLink = True }) linkContent)
922921 char ']'
923922 return $ B.link url "" <$> content
924923
test/Tests/Readers/Muse.hs+3
@@ -289,6 +289,9 @@ tests =
289289 , "No footnotes inside links" =:
290290 "[[https://amusewiki.org/][foo[1]]" =?>
291291 para (link "https://amusewiki.org/" "" (text "foo[1"))
292+ , "Image inside link" =:
293+ "[[https://amusewiki.org/][Image [[image.png][with it's own description]] inside link description]]" =?>
294+ para (link "https://amusewiki.org/" "" (text "Image " <> (image "image.png" "" (text "with it's own description")) <> text " inside link description"))
292295 ]
293296
294297 , testGroup "Literal"