diff options
| author | Albert Krewinkel <albert@zeitkraut.de> | 2022-10-02 21:00:18 +0200 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2022-10-03 08:47:32 -0700 |
| commit | 309163f5bc88884b2f021ce480537d1f8c57e068 (patch) | |
| tree | 27e998c87c9f0de613850d3c6c12b3b6f60466da /pandoc-lua-engine/test/Tests | |
| parent | 3b0e70072023d519cfb97d25ab668cf0284a5e24 (diff) | |
[API Change] Base custom writers on Writer type.
The `T.P.Lua.writeCustom` function changed to allow either a TextWriter
or ByteStringWriter to be returned. The global variables
`PANDOC_DOCUMENT` and `PANDOC_WRITER_OPTIONS` are no longer set when the
writer script is loaded. Both variables are still set in classic writers
before the conversion is started, so they can be used when they are
wrapped in functions.
Diffstat (limited to 'pandoc-lua-engine/test/Tests')
| -rw-r--r-- | pandoc-lua-engine/test/Tests/Lua/Writer.hs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pandoc-lua-engine/test/Tests/Lua/Writer.hs b/pandoc-lua-engine/test/Tests/Lua/Writer.hs index 4086b9768..80d743dd5 100644 --- a/pandoc-lua-engine/test/Tests/Lua/Writer.hs +++ b/pandoc-lua-engine/test/Tests/Lua/Writer.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE LambdaCase #-} {- | Module : Tests.Lua.Writer Copyright : © 2019-2022 Albert Krewinkel @@ -15,6 +16,7 @@ import Data.Default (Default (def)) import Text.Pandoc.Class (runIOorExplode, readFileStrict) import Text.Pandoc.Lua (writeCustom) import Text.Pandoc.Readers (readNative) +import Text.Pandoc.Writers (Writer (TextWriter)) import Test.Tasty (TestTree) import Test.Tasty.Golden (goldenVsString) @@ -28,7 +30,9 @@ tests = (runIOorExplode $ do source <- UTF8.toText <$> readFileStrict "testsuite.native" doc <- readNative def source - txt <- writeCustom "sample.lua" def doc + txt <- writeCustom "sample.lua" >>= \case + TextWriter f -> f def doc + _ -> error "Expected a text writer" pure $ BL.fromStrict (UTF8.fromText txt)) , goldenVsString "tables testsuite" @@ -36,6 +40,8 @@ tests = (runIOorExplode $ do source <- UTF8.toText <$> readFileStrict "tables.native" doc <- readNative def source - txt <- writeCustom "sample.lua" def doc + txt <- writeCustom "sample.lua" >>= \case + TextWriter f -> f def doc + _ -> error "Expected a text writer" pure $ BL.fromStrict (UTF8.fromText txt)) ] |
