@@ -13,8 +13,8 @@ import Text.Pandoc.Writers.Native (writeNative)
13import qualified Data.Map as M
13import qualified Data.Map as M
14import Text.Pandoc.MediaBag (MediaBag, lookupMedia, mediaDirectory)
14import Text.Pandoc.MediaBag (MediaBag, lookupMedia, mediaDirectory)
15import Codec.Archive.Zip
15import Codec.Archive.Zip
16−import Text.Pandoc.Error
17import Text.Pandoc.Class (runIOorExplode)
16import Text.Pandoc.Class (runIOorExplode)
17+import qualified Text.Pandoc.Class as P
19-- We define a wrapper around pandoc that doesn't normalize in the
19-- We define a wrapper around pandoc that doesn't normalize in the
20-- tests. Since we do our own normalization, we want to make sure
20-- tests. Since we do our own normalization, we want to make sure
@@ -43,9 +43,9 @@ compareOutput :: ReaderOptions
43compareOutput opts docxFile nativeFile = do
43compareOutput opts docxFile nativeFile = do
44 df <- B.readFile docxFile
44 df <- B.readFile docxFile
45 nf <- Prelude.readFile nativeFile
45 nf <- Prelude.readFile nativeFile
46− let (p, _) = handleError $ readDocx opts df
46+ p <- runIOorExplode $ readDocx opts df
47 df' <- runIOorExplode $ readNative nf
47 df' <- runIOorExplode $ readNative nf
48− return $ (noNorm p, noNorm $ handleError df')
48+ return $ (noNorm p, noNorm df')
50testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO Test
50testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO Test
51testCompareWithOptsIO opts name docxFile nativeFile = do
51testCompareWithOptsIO opts name docxFile nativeFile = do
@@ -62,7 +62,7 @@ testCompare = testCompareWithOpts def
62testForWarningsWithOptsIO :: ReaderOptions -> String -> FilePath -> [String] -> IO Test
62testForWarningsWithOptsIO :: ReaderOptions -> String -> FilePath -> [String] -> IO Test
63testForWarningsWithOptsIO opts name docxFile expected = do
63testForWarningsWithOptsIO opts name docxFile expected = do
64 df <- B.readFile docxFile
64 df <- B.readFile docxFile
65− let (_, _, warns) = handleError $ readDocxWithWarnings opts df
65+ warns <- runIOorExplode (readDocx opts df >> P.getWarnings)
66 return $ test id name (unlines warns, unlines expected)
66 return $ test id name (unlines warns, unlines expected)
68testForWarningsWithOpts :: ReaderOptions -> String -> FilePath -> [String] -> Test
68testForWarningsWithOpts :: ReaderOptions -> String -> FilePath -> [String] -> Test
@@ -95,7 +95,7 @@ compareMediaPathIO mediaPath mediaBag docxPath = do
95compareMediaBagIO :: FilePath -> IO Bool
95compareMediaBagIO :: FilePath -> IO Bool
96compareMediaBagIO docxFile = do
96compareMediaBagIO docxFile = do
97 df <- B.readFile docxFile
97 df <- B.readFile docxFile
98− let (_, mb) = handleError $ readDocx def df
98+ mb <- runIOorExplode (readDocx def df >> P.getMediaBag)
99 bools <- mapM
99 bools <- mapM
100 (\(fp, _, _) -> compareMediaPathIO fp mb docxFile)
100 (\(fp, _, _) -> compareMediaPathIO fp mb docxFile)
101 (mediaDirectory mb)
101 (mediaDirectory mb)