diff options
author | Jesse Rosenthal <jrosenthal@jhu.edu> | 2016-10-11 22:26:03 -0400 |
---|---|---|
committer | Jesse Rosenthal <jrosenthal@jhu.edu> | 2016-10-11 22:26:03 -0400 |
commit | 4b0dbdc11822aa57fcd8b96d6e0be5b645d33a87 (patch) | |
tree | 5d1a77d09ea4e8926181b4fd253558b6e8592ee1 /tests/Tests/Writers | |
parent | 14209b2ba0266f1d0aee8bfdfe01a561142930c1 (diff) | |
download | pandoc-4b0dbdc11822aa57fcd8b96d6e0be5b645d33a87.tar.gz |
Markdown writer: add test for note placement.
Diffstat (limited to 'tests/Tests/Writers')
-rw-r--r-- | tests/Tests/Writers/Markdown.hs | 140 |
1 files changed, 138 insertions, 2 deletions
diff --git a/tests/Tests/Writers/Markdown.hs b/tests/Tests/Writers/Markdown.hs index 1c27ebdf4..cfc5f8410 100644 --- a/tests/Tests/Writers/Markdown.hs +++ b/tests/Tests/Writers/Markdown.hs @@ -11,6 +11,9 @@ import Tests.Arbitrary() markdown :: (ToPandoc a) => a -> String markdown = writeMarkdown def . toPandoc +markdownWithOpts :: (ToPandoc a) => WriterOptions -> a -> String +markdownWithOpts opts x = writeMarkdown opts $ toPandoc x + {- "my test" =: X =?> Y @@ -36,13 +39,146 @@ tests = [ "indented code after list" =: bulletList [ plain "foo" <> bulletList [ plain "bar" ], plain "baz" ] =?> "- foo\n - bar\n- baz\n" - ] ++ [shortcutLinkRefsTests] + ] ++ [noteTests] ++ [shortcutLinkRefsTests] + +{- + +Testing with the following text: + +First Header +============ + +This is a footnote.[^1] And this is a [link](https://www.google.com). + +> A note inside a block quote.[^2] +> +> A second paragraph. + +Second Header +============= + +Some more text. + + +[^1]: Down here. + +[^2]: The second note. + +-} + +noteTestDoc :: Blocks +noteTestDoc = + header 1 "First Header" <> + para ("This is a footnote." <> + note (para "Down here.") <> + " And this is a " <> + link "https://www.google.com" "" "link" <> + ".") <> + blockQuote (para ("A note inside a block quote." <> + note (para "The second note.")) <> + para ("A second paragraph.")) <> + header 1 "Second Header" <> + para "Some more text." + + + +noteTests :: Test +noteTests = testGroup "note and reference location" + [ test (markdownWithOpts def) + "footnotes at the end of a document" $ + noteTestDoc =?> + (unlines $ [ "First Header" + , "============" + , "" + , "This is a footnote.[^1] And this is a [link](https://www.google.com)." + , "" + , "> A note inside a block quote.[^2]" + , ">" + , "> A second paragraph." + , "" + , "Second Header" + , "=============" + , "" + , "Some more text." + , "" + , "[^1]: Down here." + , "" + , "[^2]: The second note." + ]) + , test (markdownWithOpts def{writerReferenceLocation=EndOfBlock}) + "footnotes at the end of blocks" $ + noteTestDoc =?> + (unlines $ [ "First Header" + , "============" + , "" + , "This is a footnote.[^1] And this is a [link](https://www.google.com)." + , "" + , "[^1]: Down here." + , "" + , "> A note inside a block quote.[^2]" + , ">" + , "> A second paragraph." + , "" + , "[^2]: The second note." + , "" + , "Second Header" + , "=============" + , "" + , "Some more text." + ]) + , test (markdownWithOpts def{writerReferenceLocation=EndOfBlock, writerReferenceLinks=True}) + "footnotes and reference links at the end of blocks" $ + noteTestDoc =?> + (unlines $ [ "First Header" + , "============" + , "" + , "This is a footnote.[^1] And this is a [link]." + , "" + , "[^1]: Down here." + , "" + , " [link]: https://www.google.com" + , "" + , "> A note inside a block quote.[^2]" + , ">" + , "> A second paragraph." + , "" + , "[^2]: The second note." + , "" + , "Second Header" + , "=============" + , "" + , "Some more text." + ]) + , test (markdownWithOpts def{writerReferenceLocation=EndOfSection}) + "footnotes at the end of section" $ + noteTestDoc =?> + (unlines $ [ "First Header" + , "============" + , "" + , "This is a footnote.[^1] And this is a [link](https://www.google.com)." + , "" + , "> A note inside a block quote.[^2]" + , ">" + , "> A second paragraph." + , "" + , "[^1]: Down here." + , "" + , "[^2]: The second note." + , "" + , "Second Header" + , "=============" + , "" + , "Some more text." + ]) + + ] shortcutLinkRefsTests :: Test shortcutLinkRefsTests = let infix 4 =: (=:) :: (ToString a, ToPandoc a) - => String -> (a, String) -> Test + + => String -> (a, String) -> Test (=:) = test (writeMarkdown (def {writerReferenceLinks = True}) . toPandoc) in testGroup "Shortcut reference links" [ "Simple link (shortcutable)" |