From 7b3aaee15ab69cdf3125a214c2124b91622af759 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 17 May 2017 16:23:33 +0200 Subject: Markdown writer: Fixed duplicated reference links with `--reference-links` and `--reference-location=section`. Also ensure that there are no empty link references `[]`. Closes #3674. --- test/command/3674.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/command/3674.md (limited to 'test/command/3674.md') diff --git a/test/command/3674.md b/test/command/3674.md new file mode 100644 index 000000000..09f4e0d1e --- /dev/null +++ b/test/command/3674.md @@ -0,0 +1,26 @@ +Make sure we don't get duplicate reference links, even with +`--reference-location=section`. + +``` +% pandoc --reference-links -t markdown --reference-location=section --atx-headers +# a + +![](a) + +# b + +![](b) + +^D +# a + +![][1] + + [1]: a + +# b + +![][2] + + [2]: b +``` -- cgit v1.2.3 From 818d5c2f354cd4896659493452722c030ae7c766 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 18 May 2017 13:20:32 +0200 Subject: Markdown: allow attributes in reference links to start on next line. This addresses a subsidiary issue in #3674. --- src/Text/Pandoc/Readers/Markdown.hs | 4 +++- test/command/3674.md | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'test/command/3674.md') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 7434ef1f6..af7588562 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -392,7 +392,9 @@ referenceKey = try $ do src <- try betweenAngles <|> sourceURL tit <- option "" referenceTitle attr <- option nullAttr $ try $ - guardEnabled Ext_link_attributes >> skipSpaces >> attributes + do guardEnabled Ext_link_attributes + skipSpaces >> optional newline >> skipSpaces + attributes addKvs <- option [] $ guardEnabled Ext_mmd_link_attributes >> many (try $ spnl >> keyValAttr) blanklines diff --git a/test/command/3674.md b/test/command/3674.md index 09f4e0d1e..92ed4bed7 100644 --- a/test/command/3674.md +++ b/test/command/3674.md @@ -24,3 +24,16 @@ Make sure we don't get duplicate reference links, even with [2]: b ``` + +Subsidiary issue: allow line break between reference link +url/title and attributes: + +``` +% pandoc +[a] + +[a]: url +{.class} +^D +

a

+``` -- cgit v1.2.3