From c1ff16515412d8466e1415d449d5235c2af74c3e Mon Sep 17 00:00:00 2001
From: Nikolay Yakimov <root@livid.pp.ru>
Date: Fri, 17 Apr 2015 17:30:55 +0300
Subject: [PATCH] MD Reader: Tests for links/footnotes after citations

In-text citation suffix clashes with links and footnotes
---
 tests/Tests/Readers/Markdown.hs | 41 +++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/tests/Tests/Readers/Markdown.hs b/tests/Tests/Readers/Markdown.hs
index 4ae144556..02d49a70e 100644
--- a/tests/Tests/Readers/Markdown.hs
+++ b/tests/Tests/Readers/Markdown.hs
@@ -324,4 +324,45 @@ tests = [ testGroup "inline code"
                         }
                 ] "@1657:huyghens")
           ]
+        , let citation = cite [Citation "cita" [] [] AuthorInText 0 0] (str "@cita")
+          in testGroup "footnote/link following citation" -- issue #2083
+          [ "footnote" =:
+              unlines [ "@cita[^note]"
+                      , ""
+                      , "[^note]: note" ] =?>
+              para (
+                citation <> note (para $ str "note")
+              )
+          , "normal link" =:
+              "@cita [link](http://www.com)" =?>
+              para (
+                citation <> space <> link "http://www.com" "" (str "link")
+              )
+          , "reference link" =:
+              unlines [ "@cita [link][link]"
+                      , ""
+                      , "[link]: http://www.com" ] =?>
+              para (
+                citation <> space <> link "http://www.com" "" (str "link")
+              )
+          , "short reference link" =:
+              unlines [ "@cita [link]"
+                      , ""
+                      , "[link]: http://www.com" ] =?>
+              para (
+                citation <> space <> link "http://www.com" "" (str "link")
+              )
+          , "implicit header link" =:
+              unlines [ "# Header"
+                      , "@cita [Header]" ] =?>
+              headerWith ("header",[],[]) 1 (str "Header") <> para (
+                citation <> space <> link "#header" "" (str "Header")
+              )
+          , "regular citation" =:
+              "@cita [foo]" =?>
+              para (
+                cite [Citation "cita" [] [Str "foo"] AuthorInText 0 0]
+                  (str "@cita" <> space <> str "[foo]")
+              )
+          ]
         ]