diff options
Diffstat (limited to 'pandoc-lua-engine/test')
| -rw-r--r-- | pandoc-lua-engine/test/Tests/Lua/Writer.hs | 23 | ||||
| -rw-r--r-- | pandoc-lua-engine/test/writer-template.lua | 7 | ||||
| -rw-r--r-- | pandoc-lua-engine/test/writer-template.out.txt | 4 |
3 files changed, 28 insertions, 6 deletions
diff --git a/pandoc-lua-engine/test/Tests/Lua/Writer.hs b/pandoc-lua-engine/test/Tests/Lua/Writer.hs index 8b6e82816..18274d124 100644 --- a/pandoc-lua-engine/test/Tests/Lua/Writer.hs +++ b/pandoc-lua-engine/test/Tests/Lua/Writer.hs @@ -35,7 +35,7 @@ tests = source <- UTF8.toText <$> readFileStrict "testsuite.native" doc <- readNative def source txt <- writeCustom "sample.lua" >>= \case - (TextWriter f, _) -> f def doc + (TextWriter f, _, _) -> f def doc _ -> error "Expected a text writer" pure $ BL.fromStrict (UTF8.fromText txt)) @@ -45,23 +45,34 @@ tests = source <- UTF8.toText <$> readFileStrict "tables.native" doc <- readNative def source txt <- writeCustom "sample.lua" >>= \case - (TextWriter f, _) -> f def doc + (TextWriter f, _, _) -> f def doc _ -> error "Expected a text writer" pure $ BL.fromStrict (UTF8.fromText txt)) - , goldenVsString "tables testsuite" + , goldenVsString "bytestring writer" "bytestring.bin" (runIOorExplode $ do txt <- writeCustom "bytestring.lua" >>= \case - (ByteStringWriter f, _) -> f def mempty + (ByteStringWriter f, _, _) -> f def mempty _ -> error "Expected a bytestring writer" pure txt) + , goldenVsString "template" + "writer-template.out.txt" + (runIOorExplode $ do + txt <- writeCustom "writer-template.lua" >>= \case + (TextWriter f, _, mt) -> do + template <- mt + let opts = def{ writerTemplate = Just template } + f opts (B.doc (B.plain (B.str "body goes here"))) + _ -> error "Expected a text writer" + pure $ BL.fromStrict (UTF8.fromText txt)) + , testCase "preset extensions" $ do let ediff = ExtensionsDiff{extsToEnable = [], extsToDisable = []} let format = FlavoredFormat "extensions.lua" ediff result <- runIOorExplode $ writeCustom "extensions.lua" >>= \case - (TextWriter write, extsConf) -> do + (TextWriter write, extsConf, _) -> do exts <- applyExtensionsDiff extsConf format write def{writerExtensions = exts} (B.doc mempty) _ -> error "Expected a text writer" @@ -73,7 +84,7 @@ tests = } let format = FlavoredFormat "extensions.lua" ediff result <- runIOorExplode $ writeCustom "extensions.lua" >>= \case - (TextWriter write, extsConf) -> do + (TextWriter write, extsConf, _) -> do exts <- applyExtensionsDiff extsConf format write def{writerExtensions = exts} (B.doc mempty) _ -> error "Expected a text writer" diff --git a/pandoc-lua-engine/test/writer-template.lua b/pandoc-lua-engine/test/writer-template.lua new file mode 100644 index 000000000..c90f7c1ef --- /dev/null +++ b/pandoc-lua-engine/test/writer-template.lua @@ -0,0 +1,7 @@ +function Writer (doc, opts) + return pandoc.write(doc, 'gfm', opts) +end + +function Template () + return pandoc.template.compile '<!-- start -->\n$body$\n<!-- stop -->\n' +end diff --git a/pandoc-lua-engine/test/writer-template.out.txt b/pandoc-lua-engine/test/writer-template.out.txt new file mode 100644 index 000000000..1fb343c28 --- /dev/null +++ b/pandoc-lua-engine/test/writer-template.out.txt @@ -0,0 +1,4 @@ +<!-- start --> +body goes here + +<!-- stop --> |
