diff options
author | Alexander Krotov <ilabdsf@gmail.com> | 2019-05-25 19:13:28 +0300 |
---|---|---|
committer | Alexander Krotov <ilabdsf@gmail.com> | 2019-05-25 19:17:16 +0300 |
commit | f807f5b3833e841d9e6b831acbe50f3be8e42881 (patch) | |
tree | 5fb9849e69235bb68fce129f5758ca954caac00d | |
parent | 751427745417c7702a1546b1368db297a44b21e0 (diff) | |
download | pandoc-f807f5b3833e841d9e6b831acbe50f3be8e42881.tar.gz |
Muse reader: allow images inside link descriptions
-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" |