git.iko.soy/typeable/pandoc
on master help sign in
RST reader: Support :target: on .. image:: blocks.
f76478bJohn MacFarlane
src/Text/Pandoc/Readers/RST.hs+8−4
@@ -257,10 +257,14 @@ imageBlock = try $ do
257 fields <- try $ do indent <- lookAhead $ many (oneOf " /t")
257 fields <- try $ do indent <- lookAhead $ many (oneOf " /t")
258 many $ rawFieldListItem indent
258 many $ rawFieldListItem indent
259 optional blanklines
259 optional blanklines
260+ let alt = maybe [Str "image"] (\x -> [Str $ removeTrailingSpace x])
261+ $ lookup "alt" fields
262+ let img = Image alt (src,"")
260− case lookup "alt" fields of
263+ return $ Para [case lookup "target" fields of
261− Just alt -> return $ Plain [Image [Str $ removeTrailingSpace alt]
264+ Just t -> Link [img]
262− (src, "")]
265+ (escapeURI $ removeLeadingTrailingSpace t,"")
263− Nothing -> return $ Plain [Image [Str "image"] (src, "")]
266+ Nothing -> img]
267+
264--
268--
265-- header blocks
269-- header blocks
266--
270--
tests/rst-reader.native+2−2
@@ -223,8 +223,8 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":
223,CodeBlock ("",[],[]) "http://example.com/"
223,CodeBlock ("",[],[]) "http://example.com/"
224,Header 1 [Str "Images"]
224,Header 1 [Str "Images"]
225,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 ":"]
225,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 ":"]
226−,Plain [Image [Str "image"] ("lalune.jpg","")]
226+,Para [Image [Str "image"] ("lalune.jpg","")]
227−,Plain [Image [Str "Voyage dans la Lune"] ("lalune.jpg","")]
227+,Para [Image [Str "Voyage dans la Lune"] ("lalune.jpg","")]
228,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon",Str "."]
228,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon",Str "."]
229,Header 1 [Str "Comments"]
229,Header 1 [Str "Comments"]
230,Para [Str "First",Space,Str "paragraph"]
230,Para [Str "First",Space,Str "paragraph"]