@@ -0,0 +1,128 @@
1+module Tests.Writers.Docx (tests) where
2+
3+import Text.Pandoc.Options
4+import Text.Pandoc.Readers.Native
5+import Text.Pandoc.Definition
6+import Tests.Helpers
7+import Test.Framework
8+import Text.Pandoc.Readers.Docx
9+import Text.Pandoc.Writers.Docx
10+
11+type Options = (WriterOptions, ReaderOptions)
12+
13+compareOutput :: Options
14+ -> FilePath
15+ -> IO (Pandoc, Pandoc)
16+compareOutput opts nativeFile = do
17+ nf <- Prelude.readFile nativeFile
18+ df <- writeDocx (fst opts) (readNative nf)
19+ let (p, _) = readDocx (snd opts) df
20+ return (p, readNative nf)
21+
22+testCompareWithOptsIO :: Options -> String -> FilePath -> IO Test
23+testCompareWithOptsIO opts name nativeFile = do
24+ (dp, np) <- compareOutput opts nativeFile
25+ return $ test id name (dp, np)
26+
27+testCompareWithOpts :: Options -> String -> FilePath -> Test
28+testCompareWithOpts opts name nativeFile =
29+ buildTest $ testCompareWithOptsIO opts name nativeFile
30+
31+testCompare :: String -> FilePath -> Test
32+testCompare = testCompareWithOpts def
33+
34+tests :: [Test]
35+tests = [ testGroup "inlines"
36+ [ testCompare
37+ "font formatting"
38+ "docx/inline_formatting_writer.native"
39+ , testCompare
40+ "font formatting with character styles"
41+ "docx/char_styles.native"
42+ , testCompare
43+ "hyperlinks"
44+ "docx/links_writer.native"
45+ , testCompare
46+ "inline image"
47+ "docx/image_no_embed_writer.native"
48+ , testCompare
49+ "inline image in links"
50+ "docx/inline_images_writer.native"
51+ , testCompare
52+ "handling unicode input"
53+ "docx/unicode.native"
54+ , testCompare
55+ "literal tabs"
56+ "docx/tabs.native"
57+ , testCompare
58+ "normalizing inlines"
59+ "docx/normalize.native"
60+ , testCompare
61+ "normalizing inlines deep inside blocks"
62+ "docx/deep_normalize.native"
63+ , testCompare
64+ "move trailing spaces outside of formatting"
65+ "docx/trailing_spaces_in_formatting.native"
66+ , testCompare
67+ "inline code (with VerbatimChar style)"
68+ "docx/inline_code.native"
69+ , testCompare
70+ "inline code in subscript and superscript"
71+ "docx/verbatim_subsuper.native"
72+ ]
73+ , testGroup "blocks"
74+ [ testCompare
75+ "headers"
76+ "docx/headers.native"
77+ , testCompare
78+ "headers already having auto identifiers"
79+ "docx/already_auto_ident.native"
80+ , testCompare
81+ "numbered headers automatically made into list"
82+ "docx/numbered_header.native"
83+ , testCompare
84+ "i18n blocks (headers and blockquotes)"
85+ "docx/i18n_blocks.native"
86+ -- some level problems, look into that
87+ -- , testCompare
88+ -- "lists"
89+ -- "docx/lists.native"
90+ , testCompare
91+ "definition lists"
92+ "docx/definition_list.native"
93+ , testCompare
94+ "custom defined lists in styles"
95+ "docx/german_styled_lists.native"
96+ , testCompare
97+ "footnotes and endnotes"
98+ "docx/notes.native"
99+ , testCompare
100+ "blockquotes (parsing indent as blockquote)"
101+ "docx/block_quotes_parse_indent.native"
102+ , testCompare
103+ "hanging indents"
104+ "docx/hanging_indent.native"
105+ -- tables headers do not survive round-trip, should look into that
106+ -- , testCompare
107+ -- "tables"
108+ -- "docx/tables.native"
109+ -- , testCompare
110+ -- "tables with lists in cells"
111+ -- "docx/table_with_list_cell.native"
112+ , testCompare
113+ "code block"
114+ "docx/codeblock.native"
115+ , testCompare
116+ "dropcap paragraphs"
117+ "docx/drop_cap.native"
118+ ]
119+ , testGroup "metadata"
120+ [ testCompareWithOpts (def,def{readerStandalone=True})
121+ "metadata fields"
122+ "docx/metadata.native"
123+ , testCompareWithOpts (def,def{readerStandalone=True})
124+ "stop recording metadata with normal text"
125+ "docx/metadata_after_normal.native"
126+ ]
127+
128+ ]