aboutsummaryrefslogtreecommitdiff
path: root/test/Tests/Readers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-07-30 17:23:46 -0600
committerJohn MacFarlane <jgm@berkeley.edu>2021-08-10 10:48:55 -0700
commit6543b05116ee58ef4de62f93dcafeb27617d83e6 (patch)
tree807dcf073285e484329982f3c7bd3d4031f370b7 /test/Tests/Readers
parentc0b68b2030ecdb4ad006443a56ce99aebc92fbc5 (diff)
downloadpandoc-6543b05116ee58ef4de62f93dcafeb27617d83e6.tar.gz
Add RTF reader.
- `rtf` is now supported as an input format as well as output. - New module Text.Pandoc.Readers.RTF (exporting `readRTF`). [API change] Closes #3982.
Diffstat (limited to 'test/Tests/Readers')
-rw-r--r--test/Tests/Readers/FB2.hs2
-rw-r--r--test/Tests/Readers/RTF.hs48
2 files changed, 49 insertions, 1 deletions
diff --git a/test/Tests/Readers/FB2.hs b/test/Tests/Readers/FB2.hs
index 42054a235..d540f8b6a 100644
--- a/test/Tests/Readers/FB2.hs
+++ b/test/Tests/Readers/FB2.hs
@@ -7,7 +7,7 @@
Stability : alpha
Portability : portable
-Tests for the EPUB mediabag.
+Tests for the FB2 reader.
-}
module Tests.Readers.FB2 (tests) where
diff --git a/test/Tests/Readers/RTF.hs b/test/Tests/Readers/RTF.hs
new file mode 100644
index 000000000..2a741bba8
--- /dev/null
+++ b/test/Tests/Readers/RTF.hs
@@ -0,0 +1,48 @@
+{- |
+ Module : Tests.Readers.RTF
+ Copyright : © 2021 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : jgm@berkeley.edu
+ Stability : alpha
+ Portability : portable
+
+Tests for the RTF reader.
+-}
+module Tests.Readers.RTF (tests) where
+
+import Test.Tasty
+import Tests.Helpers
+import Test.Tasty.Golden (goldenVsString)
+import qualified Data.ByteString as BS
+import Text.Pandoc
+import Text.Pandoc.UTF8 (toText, fromStringLazy)
+import Data.Text (Text, unpack)
+import System.FilePath (replaceExtension, (</>), (<.>))
+
+rtfToNative :: Text -> Text
+rtfToNative =
+ purely (writeNative def{ writerTemplate = Just mempty }) .
+ purely (readRTF def)
+
+rtfTest :: TestName -> TestTree
+rtfTest name = goldenVsString name native
+ (fromStringLazy . filter (/='\r') . unpack . rtfToNative . toText
+ <$> BS.readFile path)
+ where native = replaceExtension path ".native"
+ path = "rtf" </> name <.> "rtf"
+
+tests :: [TestTree]
+tests = map rtfTest [ "footnote"
+ , "accent"
+ , "unicode"
+ , "image"
+ , "link"
+ , "heading"
+ , "formatting"
+ , "list_simple"
+ , "list_complex"
+ , "bookmark"
+ , "table_simple"
+ ]
+