aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs5
-rw-r--r--src/Text/Pandoc/Writers/RST.hs8
2 files changed, 8 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index e93806e7b..fe8e0c2de 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -400,9 +400,10 @@ inlineToMarkdown _ (HtmlInline str) = return $ text str
inlineToMarkdown _ (LineBreak) = return $ text " \n"
inlineToMarkdown _ Space = return $ char ' '
inlineToMarkdown opts (Cite _ cits) = inlineListToMarkdown opts cits
-inlineToMarkdown opts (Link txt (src, tit)) = do
+inlineToMarkdown opts (Link txt (src', tit)) = do
linktext <- inlineListToMarkdown opts txt
let linktitle = if null tit then empty else text $ " \"" ++ tit ++ "\""
+ let src = unescapeURI src'
let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src
let useRefLinks = writerReferenceLinks opts
let useAuto = null tit && txt == [Code srcSuffix]
@@ -423,7 +424,7 @@ inlineToMarkdown opts (Image alternate (source, tit)) = do
(alternate == [Str source]) -- to prevent autolinks
then [Str "image"]
else alternate
- linkPart <- inlineToMarkdown opts (Link txt (source, tit))
+ linkPart <- inlineToMarkdown opts (Link txt (unescapeURI source, tit))
return $ char '!' <> linkPart
inlineToMarkdown _ (Note contents) = do
modify (\st -> st{ stNotes = contents : stNotes st })
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
index f22e31d7d..f4dfb2aa6 100644
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -305,8 +305,9 @@ inlineToRST Space = return $ char ' '
inlineToRST (Link [Code str] (src, _)) | src == str ||
src == "mailto:" ++ str = do
let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src
- return $ text srcSuffix
-inlineToRST (Link txt (src, tit)) = do
+ return $ text $ unescapeURI srcSuffix
+inlineToRST (Link txt (src', tit)) = do
+ let src = unescapeURI src'
useReferenceLinks <- get >>= (return . writerReferenceLinks . stOptions)
linktext <- inlineListToRST $ normalizeSpaces txt
if useReferenceLinks
@@ -317,7 +318,8 @@ inlineToRST (Link txt (src, tit)) = do
modify $ \st -> st { stLinks = refs' }
return $ char '`' <> linktext <> text "`_"
else return $ char '`' <> linktext <> text " <" <> text src <> text ">`_"
-inlineToRST (Image alternate (source, tit)) = do
+inlineToRST (Image alternate (source', tit)) = do
+ let source = unescapeURI source'
pics <- get >>= (return . stImages)
let labelsUsed = map fst pics
let txt = if null alternate || alternate == [Str ""] ||