diff options
-rw-r--r-- | src/Text/Pandoc/Readers/Muse.hs | 9 | ||||
-rw-r--r-- | test/Tests/Readers/Muse.hs | 3 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index fa19ea767..568287929 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -903,10 +903,7 @@ symbol = pure . B.str . pure <$> nonspaceChar -- | Parse a link or image. linkOrImage :: PandocMonad m => MuseParser m (F Inlines) -linkOrImage = try $ do - inLink <- asks museInLink - guard $ not inLink - local (\s -> s { museInLink = True }) (link "URL:" <|> image <|> link "") +linkOrImage = try $ link "URL:" <|> image <|> link "" linkContent :: PandocMonad m => MuseParser m (F Inlines) linkContent = trimInlinesF . mconcat @@ -916,9 +913,11 @@ linkContent = trimInlinesF . mconcat -- | Parse a link starting with (possibly null) prefix link :: PandocMonad m => String -> MuseParser m (F Inlines) link prefix = try $ do + inLink <- asks museInLink + guard $ not inLink string $ "[[" ++ prefix url <- manyTill anyChar $ char ']' - content <- option (pure $ B.str url) linkContent + content <- option (pure $ B.str url) (local (\s -> s { museInLink = True }) linkContent) char ']' return $ B.link url "" <$> content diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs index e864cb46e..51ccbc1da 100644 --- a/test/Tests/Readers/Muse.hs +++ b/test/Tests/Readers/Muse.hs @@ -289,6 +289,9 @@ tests = , "No footnotes inside links" =: "[[https://amusewiki.org/][foo[1]]" =?> para (link "https://amusewiki.org/" "" (text "foo[1")) + , "Image inside link" =: + "[[https://amusewiki.org/][Image [[image.png][with it's own description]] inside link description]]" =?> + para (link "https://amusewiki.org/" "" (text "Image " <> (image "image.png" "" (text "with it's own description")) <> text " inside link description")) ] , testGroup "Literal" |