aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/RST.hs12
-rw-r--r--tests/rst-reader.native4
2 files changed, 10 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 1d64ff220..4527dba14 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -257,10 +257,14 @@ imageBlock = try $ do
fields <- try $ do indent <- lookAhead $ many (oneOf " /t")
many $ rawFieldListItem indent
optional blanklines
- case lookup "alt" fields of
- Just alt -> return $ Plain [Image [Str $ removeTrailingSpace alt]
- (src, "")]
- Nothing -> return $ Plain [Image [Str "image"] (src, "")]
+ let alt = maybe [Str "image"] (\x -> [Str $ removeTrailingSpace x])
+ $ lookup "alt" fields
+ let img = Image alt (src,"")
+ return $ Para [case lookup "target" fields of
+ Just t -> Link [img]
+ (escapeURI $ removeLeadingTrailingSpace t,"")
+ Nothing -> img]
+
--
-- header blocks
--
diff --git a/tests/rst-reader.native b/tests/rst-reader.native
index c99e73f07..b49e9873e 100644
--- a/tests/rst-reader.native
+++ b/tests/rst-reader.native
@@ -223,8 +223,8 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":
,CodeBlock ("",[],[]) "http://example.com/"
,Header 1 [Str "Images"]
,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(",Str "1902",Str ")",Str ":"]
-,Plain [Image [Str "image"] ("lalune.jpg","")]
-,Plain [Image [Str "Voyage dans la Lune"] ("lalune.jpg","")]
+,Para [Image [Str "image"] ("lalune.jpg","")]
+,Para [Image [Str "Voyage dans la Lune"] ("lalune.jpg","")]
,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon",Str "."]
,Header 1 [Str "Comments"]
,Para [Str "First",Space,Str "paragraph"]