diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index c1d50c2ef..d5ec137cd 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -176,7 +176,7 @@ inlineToMarkdown (Link txt (Src src tit)) = inlineToMarkdown (Link txt (Ref ref)) = let first = char '[' <> inlineListToMarkdown txt <> char ']' second = if (txt == ref) - then empty + then text "[]" else char '[' <> inlineListToMarkdown ref <> char ']' in first <> second inlineToMarkdown (Image alternate (Src source tit)) = diff --git a/tests/writer.markdown b/tests/writer.markdown index f41501e37..54b4b3f79 100644 --- a/tests/writer.markdown +++ b/tests/writer.markdown @@ -531,13 +531,13 @@ Foo [bar][a]. With [embedded [brackets]][b]. -[b] by itself should be a link. +[b][] by itself should be a link. -Indented [once]. +Indented [once][]. -Indented [twice]. +Indented [twice][]. -Indented [thrice]. +Indented [thrice][]. This should [not][] be a link. @@ -550,7 +550,7 @@ This should [not][] be a link. [b]: /url/ -Foo [bar]. +Foo [bar][]. Foo [biz](/url/ "Title with "quote" inside"). @@ -595,7 +595,7 @@ Auto-links should not occur here: `<http://example.com/>` From "Voyage dans la Lune" by Georges Melies (1902): -![lalune] +![lalune][] [lalune]: lalune.jpg "Voyage dans la Lune"