@@ -11,6 +11,9 @@ import Tests.Arbitrary()
11markdown :: (ToPandoc a) => a -> String
11markdown :: (ToPandoc a) => a -> String
12markdown = writeMarkdown def . toPandoc
12markdown = writeMarkdown def . toPandoc
14+markdownWithOpts :: (ToPandoc a) => WriterOptions -> a -> String
15+markdownWithOpts opts x = writeMarkdown opts $ toPandoc x
15 "my test" =: X =?> Y
18 "my test" =: X =?> Y
@@ -36,13 +39,146 @@ tests = [ "indented code after list"
36 =: bulletList [ plain "foo" <> bulletList [ plain "bar" ],
39 =: bulletList [ plain "foo" <> bulletList [ plain "bar" ],
37 plain "baz" ]
40 plain "baz" ]
38 =?> "- foo\n - bar\n- baz\n"
41 =?> "- foo\n - bar\n- baz\n"
39− ] ++ [shortcutLinkRefsTests]
42+ ] ++ [noteTests] ++ [shortcutLinkRefsTests]
46+Testing with the following text:
51+This is a footnote.[^1] And this is a [link](https://www.google.com).
53+> A note inside a block quote.[^2]
65+[^2]: The second note.
71+ header 1 "First Header" <>
72+ para ("This is a footnote." <>
73+ note (para "Down here.") <>
75+ link "https://www.google.com" "" "link" <>
77+ blockQuote (para ("A note inside a block quote." <>
78+ note (para "The second note.")) <>
79+ para ("A second paragraph.")) <>
80+ header 1 "Second Header" <>
81+ para "Some more text."
86+noteTests = testGroup "note and reference location"
87+ [ test (markdownWithOpts def)
88+ "footnotes at the end of a document" $
90+ (unlines $ [ "First Header"
93+ , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
95+ , "> A note inside a block quote.[^2]"
97+ , "> A second paragraph."
104+ , "[^1]: Down here."
106+ , "[^2]: The second note."
108+ , test (markdownWithOpts def{writerReferenceLocation=EndOfBlock})
109+ "footnotes at the end of blocks" $
111+ (unlines $ [ "First Header"
114+ , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
116+ , "[^1]: Down here."
118+ , "> A note inside a block quote.[^2]"
120+ , "> A second paragraph."
122+ , "[^2]: The second note."
129+ , test (markdownWithOpts def{writerReferenceLocation=EndOfBlock, writerReferenceLinks=True})
130+ "footnotes and reference links at the end of blocks" $
132+ (unlines $ [ "First Header"
135+ , "This is a footnote.[^1] And this is a [link]."
137+ , "[^1]: Down here."
139+ , " [link]: https://www.google.com"
141+ , "> A note inside a block quote.[^2]"
143+ , "> A second paragraph."
145+ , "[^2]: The second note."
152+ , test (markdownWithOpts def{writerReferenceLocation=EndOfSection})
153+ "footnotes at the end of section" $
155+ (unlines $ [ "First Header"
158+ , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
160+ , "> A note inside a block quote.[^2]"
162+ , "> A second paragraph."
164+ , "[^1]: Down here."
166+ , "[^2]: The second note."
41shortcutLinkRefsTests :: Test
176shortcutLinkRefsTests :: Test
42shortcutLinkRefsTests =
177shortcutLinkRefsTests =
43 let infix 4 =:
178 let infix 4 =:
44 (=:) :: (ToString a, ToPandoc a)
179 (=:) :: (ToString a, ToPandoc a)
45− => String -> (a, String) -> Test
181+ => String -> (a, String) -> Test
46 (=:) = test (writeMarkdown (def {writerReferenceLinks = True}) . toPandoc)
182 (=:) = test (writeMarkdown (def {writerReferenceLinks = True}) . toPandoc)
47 in testGroup "Shortcut reference links"
183 in testGroup "Shortcut reference links"
48 [ "Simple link (shortcutable)"
184 [ "Simple link (shortcutable)"