git.iko.soy/typeable/pandoc
on master help sign in
Fixed RST links with no explicit link text.
d283f9cJohn MacFarlane
src/Text/Pandoc/Readers/RST.hs+4−1
@@ -1126,7 +1126,10 @@ explicitLink = try $ do
1126 skipSpaces
1126 skipSpaces
1127 string "`_"
1127 string "`_"
1128 optional $ char '_' -- anonymous form
1128 optional $ char '_' -- anonymous form
1129+ let label'' = if label' == mempty
1130+ then B.str src
1131+ else label'
1129− return $ B.link (escapeURI $ trim src) "" label'
1132+ return $ B.link (escapeURI $ trim src) "" label''
1130
1133
1131referenceLink :: RSTParser Inlines
1134referenceLink :: RSTParser Inlines
1132referenceLink = try $ do
1135referenceLink = try $ do
tests/rst-reader.native+1
@@ -211,6 +211,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
211,Para [Str "Minus:",Space,Str "-"]
211,Para [Str "Minus:",Space,Str "-"]
212,Header 1 ("links",[],[]) [Str "Links"]
212,Header 1 ("links",[],[]) [Str "Links"]
213,Para [Str "Explicit:",Space,Str "a",Space,Link ("",[],[]) [Str "URL"] ("/url/",""),Str "."]
213,Para [Str "Explicit:",Space,Str "a",Space,Link ("",[],[]) [Str "URL"] ("/url/",""),Str "."]
214+,Para [Str "Explicit",Space,Str "with",Space,Str "no",Space,Str "label:",Space,Link ("",[],[]) [Str "foo"] ("foo",""),Str "."]
214,Para [Str "Two",Space,Str "anonymous",Space,Str "links:",Space,Link ("",[],[]) [Str "the",Space,Str "first"] ("/url1/",""),Space,Str "and",Space,Link ("",[],[]) [Str "the",Space,Str "second"] ("/url2/","")]
215,Para [Str "Two",Space,Str "anonymous",Space,Str "links:",Space,Link ("",[],[]) [Str "the",Space,Str "first"] ("/url1/",""),Space,Str "and",Space,Link ("",[],[]) [Str "the",Space,Str "second"] ("/url2/","")]
215,Para [Str "Reference",Space,Str "links:",Space,Link ("",[],[]) [Str "link1"] ("/url1/",""),Space,Str "and",Space,Link ("",[],[]) [Str "link2"] ("/url2/",""),Space,Str "and",Space,Link ("",[],[]) [Str "link1"] ("/url1/",""),Space,Str "again."]
216,Para [Str "Reference",Space,Str "links:",Space,Link ("",[],[]) [Str "link1"] ("/url1/",""),Space,Str "and",Space,Link ("",[],[]) [Str "link2"] ("/url2/",""),Space,Str "and",Space,Link ("",[],[]) [Str "link1"] ("/url1/",""),Space,Str "again."]
216,Para [Str "Here\8217s",Space,Str "a",Space,Link ("",[],[]) [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
217,Para [Str "Here\8217s",Space,Str "a",Space,Link ("",[],[]) [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
tests/rst-reader.rst+2
@@ -378,6 +378,8 @@ Links
378
378
379Explicit: a `URL </url/>`_.
379Explicit: a `URL </url/>`_.
380
380
381+Explicit with no label: `<foo>`_.
382+
381Two anonymous links: `the first`__ and `the second`__
383Two anonymous links: `the first`__ and `the second`__
382
384
383__ /url1/
385__ /url1/