From 0c84630549c4b452d2eb5a3d82df5fc62ca593e6 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Mon, 5 Nov 2018 07:27:55 +0300 Subject: Muse writer: add support for --reference-location= Address #107 --- test/Tests/Writers/Muse.hs | 88 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs index 57fbb3e57..ad4f421a3 100644 --- a/test/Tests/Writers/Muse.hs +++ b/test/Tests/Writers/Muse.hs @@ -9,10 +9,13 @@ import Text.Pandoc import Text.Pandoc.Arbitrary () import Text.Pandoc.Builder +defopts :: WriterOptions +defopts = def{ writerWrapText = WrapPreserve, + writerExtensions = extensionsFromList [Ext_amuse, + Ext_auto_identifiers] } + muse :: (ToPandoc a) => a -> String -muse = museWithOpts def{ writerWrapText = WrapPreserve, - writerExtensions = extensionsFromList [Ext_amuse, - Ext_auto_identifiers] } +muse = museWithOpts defopts museWithOpts :: (ToPandoc a) => WriterOptions -> a -> String museWithOpts opts = unpack . purely (writeMuse opts) . toPandoc @@ -22,6 +25,84 @@ infix 4 =: => String -> (a, String) -> TestTree (=:) = test muse +noteLocationTestDoc :: Blocks +noteLocationTestDoc = + header 1 (text "First Header") <> + para (text "This is a footnote." <> + note (para (text "First note."))) <> + blockQuote (para (text "A note inside a block quote." <> + note (para (text "The second note."))) <> + para (text "A second paragraph.")) <> + header 1 (text "Second Header") <> + para (text "Some more text.") + +noteLocationTests :: TestTree +noteLocationTests = testGroup "note location" + [ test (museWithOpts defopts {writerReferenceLocation=EndOfDocument}) + "footnotes at the end of document" $ + noteLocationTestDoc =?> + (unlines [ "* First Header" + , "" + , "This is a footnote.[1]" + , "" + , "" + , "A note inside a block quote.[2]" + , "" + , "A second paragraph." + , "" + , "" + , "* Second Header" + , "" + , "Some more text." + , "" + , "[1] First note." + , "" + , "[2] The second note." + ]) + , test (museWithOpts defopts {writerReferenceLocation=EndOfBlock}) + "footnotes at the end of block" $ + noteLocationTestDoc =?> + (unlines [ "* First Header" + , "" + , "This is a footnote.[1]" + , "" + , "[1] First note." + , "" + , "" + , "A note inside a block quote.[2]" + , "" + , "[2] The second note." + , "" + , "A second paragraph." + , "" + , "" + , "* Second Header" + , "" + , "Some more text." + ]) + , test (museWithOpts defopts {writerReferenceLocation=EndOfSection}) + "footnotes at the end of section" $ + noteLocationTestDoc =?> + (unlines [ "* First Header" + , "" + , "This is a footnote.[1]" + , "" + , "" + , "A note inside a block quote.[2]" + , "" + , "A second paragraph." + , "" + , "" + , "[1] First note." + , "" + , "[2] The second note." + , "" + , "* Second Header" + , "" + , "Some more text." + ]) + ] + tests :: [TestTree] tests = [ testGroup "block elements" [ "plain" =: plain (text "Foo bar.") =?> "Foo bar." @@ -501,6 +582,7 @@ tests = [ testGroup "block elements" , "" , "[1] Foo" ] + , noteLocationTests , "span with class" =: spanWith ("",["foobar"],[]) (text "Some text") =?> "Some text" , "span without class" =: spanWith ("",[],[]) (text "Some text") -- cgit v1.2.3