Fixed RST links with no explicit link text.
The link `<foo>`_ should have `foo` as both its link text and its URL. See RST spec at <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#embedded-uris-and-aliases> "The reference text may also be omitted, in which case the URI will be duplicated for use as the reference text. This is useful for relative URIs where the address or file name is also the desired reference text: See `<a_named_relative_link>`_ or `<an_anonymous_relative_link>`__ for details." Closes Debian #828167 -- reported by Christian Heller.
This commit is contained in:
parent
a4294800bf
commit
d283f9c864
3 changed files with 7 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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 "."]
|
||||
|
|
|
@ -378,6 +378,8 @@ Links
|
|||
|
||||
Explicit: a `URL </url/>`_.
|
||||
|
||||
Explicit with no label: `<foo>`_.
|
||||
|
||||
Two anonymous links: `the first`__ and `the second`__
|
||||
|
||||
__ /url1/
|
||||
|
|
Loading…
Add table
Reference in a new issue