aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/RST.hs5
-rw-r--r--tests/rst-reader.native1
-rw-r--r--tests/rst-reader.rst2
3 files changed, 7 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 296c55f32..60d69638b 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -1126,7 +1126,10 @@ explicitLink = try $ do
skipSpaces
string "`_"
optional $ char '_' -- anonymous form
- return $ B.link (escapeURI $ trim src) "" label'
+ let label'' = if label' == mempty
+ then B.str src
+ else label'
+ return $ B.link (escapeURI $ trim src) "" label''
referenceLink :: RSTParser Inlines
referenceLink = try $ do
diff --git a/tests/rst-reader.native b/tests/rst-reader.native
index 4752d76ff..d44fa5efb 100644
--- a/tests/rst-reader.native
+++ b/tests/rst-reader.native
@@ -211,6 +211,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
,Para [Str "Minus:",Space,Str "-"]
,Header 1 ("links",[],[]) [Str "Links"]
,Para [Str "Explicit:",Space,Str "a",Space,Link ("",[],[]) [Str "URL"] ("/url/",""),Str "."]
+,Para [Str "Explicit",Space,Str "with",Space,Str "no",Space,Str "label:",Space,Link ("",[],[]) [Str "foo"] ("foo",""),Str "."]
,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/","")]
,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."]
,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 "."]
diff --git a/tests/rst-reader.rst b/tests/rst-reader.rst
index ff10abe24..450f2b939 100644
--- a/tests/rst-reader.rst
+++ b/tests/rst-reader.rst
@@ -378,6 +378,8 @@ Links
Explicit: a `URL </url/>`_.
+Explicit with no label: `<foo>`_.
+
Two anonymous links: `the first`__ and `the second`__
__ /url1/