git.iko.soy/typeable/pandoc
on master help sign in
RST reader: Support :target: on .. image:: blocks.

Still not supported on substitution definitions.

commitf76478bcb9a651623d33c6d4ad766a126bc590a1 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 26 Sep 2012, 22:22 (14 years ago) parent90a42fa
2 files changed+10−6
src/Text/Pandoc/Readers/RST.hs+8−4 tests/rst-reader.native+2−2
src/Text/Pandoc/Readers/RST.hs+8−4
@@ -257,10 +257,14 @@ imageBlock = try $ do
257257 fields <- try $ do indent <- lookAhead $ many (oneOf " /t")
258258 many $ rawFieldListItem indent
259259 optional blanklines
260− case lookup "alt" fields of
261− Just alt -> return $ Plain [Image [Str $ removeTrailingSpace alt]
262− (src, "")]
263− Nothing -> return $ Plain [Image [Str "image"] (src, "")]
260+ let alt = maybe [Str "image"] (\x -> [Str $ removeTrailingSpace x])
261+ $ lookup "alt" fields
262+ let img = Image alt (src,"")
263+ return $ Para [case lookup "target" fields of
264+ Just t -> Link [img]
265+ (escapeURI $ removeLeadingTrailingSpace t,"")
266+ Nothing -> img]
267+
264268--
265269-- header blocks
266270--
tests/rst-reader.native+2−2
@@ -223,8 +223,8 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":
223223,CodeBlock ("",[],[]) "http://example.com/"
224224,Header 1 [Str "Images"]
225225,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","")]
227−,Plain [Image [Str "Voyage dans la Lune"] ("lalune.jpg","")]
226+,Para [Image [Str "image"] ("lalune.jpg","")]
227+,Para [Image [Str "Voyage dans la Lune"] ("lalune.jpg","")]
228228,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon",Str "."]
229229,Header 1 [Str "Comments"]
230230,Para [Str "First",Space,Str "paragraph"]