diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2021-07-17 18:10:34 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2021-07-17 18:46:16 +0200 |
commit | 48459559a13a20083fc9b31eb523b8ea2bf0a63f (patch) | |
tree | 1c04e75709457403110a6f8c5c90099f22369de3 /test/Tests/Readers/Docx.hs | |
parent | 0c39509d9b6a58958228cebf5d643598e5c98950 (diff) | |
parent | 46099e79defe662e541b12548200caf29063c1c6 (diff) | |
download | pandoc-48459559a13a20083fc9b31eb523b8ea2bf0a63f.tar.gz |
Merge branch 'master' of https://github.com/jgm/pandoc
Diffstat (limited to 'test/Tests/Readers/Docx.hs')
-rw-r--r-- | test/Tests/Readers/Docx.hs | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs index 12007f502..220c7d9c5 100644 --- a/test/Tests/Readers/Docx.hs +++ b/test/Tests/Readers/Docx.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Docx @@ -13,7 +12,6 @@ Tests for the word docx reader. -} module Tests.Readers.Docx (tests) where -import Prelude import Codec.Archive.Zip import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as B @@ -26,7 +24,7 @@ import Test.Tasty.HUnit import Tests.Helpers import Text.Pandoc import qualified Text.Pandoc.Class as P -import Text.Pandoc.MediaBag (MediaBag, lookupMedia, mediaDirectory) +import qualified Text.Pandoc.MediaBag as MB import Text.Pandoc.UTF8 as UTF8 -- We define a wrapper around pandoc that doesn't normalize in the @@ -93,11 +91,11 @@ getMedia :: FilePath -> FilePath -> IO (Maybe B.ByteString) getMedia archivePath mediaPath = fmap fromEntry . findEntryByPath ("word/" ++ mediaPath) . toArchive <$> B.readFile archivePath -compareMediaPathIO :: FilePath -> MediaBag -> FilePath -> IO Bool +compareMediaPathIO :: FilePath -> MB.MediaBag -> FilePath -> IO Bool compareMediaPathIO mediaPath mediaBag docxPath = do docxMedia <- getMedia docxPath mediaPath - let mbBS = case lookupMedia mediaPath mediaBag of - Just (_, bs) -> bs + let mbBS = case MB.lookupMedia mediaPath mediaBag of + Just item -> MB.mediaContents item Nothing -> error ("couldn't find " ++ mediaPath ++ " in media bag") @@ -112,7 +110,7 @@ compareMediaBagIO docxFile = do mb <- runIOorExplode $ readDocx defopts df >> P.getMediaBag bools <- mapM (\(fp, _, _) -> compareMediaPathIO fp mb docxFile) - (mediaDirectory mb) + (MB.mediaDirectory mb) return $ and bools testMediaBagIO :: String -> FilePath -> IO TestTree @@ -158,6 +156,10 @@ tests = [ testGroup "document" "docx/image_vml.docx" "docx/image_vml.native" , testCompare + "VML image as object" + "docx/image_vml_as_object.docx" + "docx/image_vml_as_object.native" + , testCompare "inline image in links" "docx/inline_images.docx" "docx/inline_images.native" @@ -316,14 +318,30 @@ tests = [ testGroup "document" "docx/table_with_list_cell.docx" "docx/table_with_list_cell.native" , testCompare + "a table with a header which contains rowspans greater than 1" + "docx/table_header_rowspan.docx" + "docx/table_header_rowspan.native" + , testCompare "tables with one row" "docx/table_one_row.docx" "docx/table_one_row.native" , testCompare + "tables with just one row, which is a header" + "docx/table_one_header_row.docx" + "docx/table_one_header_row.native" + , testCompare "tables with variable width" "docx/table_variable_width.docx" "docx/table_variable_width.native" , testCompare + "tables with captions which contain a Table field" + "docx/table_captions_with_field.docx" + "docx/table_captions_with_field.native" + , testCompare + "tables with captions which don't contain a Table field" + "docx/table_captions_no_field.docx" + "docx/table_captions_no_field.native" + , testCompare "code block" "docx/codeblock.docx" "docx/codeblock.native" |