aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Tests/Readers/DocX.hs68
-rw-r--r--tests/docx.block_quotes.docxbin0 -> 41855 bytes
-rw-r--r--tests/docx.block_quotes_parse_indent.native8
-rw-r--r--tests/docx.headers.docxbin0 -> 30298 bytes
-rw-r--r--tests/docx.headers.native5
-rw-r--r--tests/docx.image.docxbin0 -> 109656 bytes
-rw-r--r--tests/docx.image_no_embed.native2
-rw-r--r--tests/docx.inline_formatting.docxbin0 -> 32322 bytes
-rw-r--r--tests/docx.inline_formatting.native5
-rw-r--r--tests/docx.links.docxbin0 -> 41751 bytes
-rw-r--r--tests/docx.links.native6
-rw-r--r--tests/docx.lists.docxbin0 -> 31775 bytes
-rw-r--r--tests/docx.lists.native18
-rw-r--r--tests/docx.notes.docxbin0 -> 30734 bytes
-rw-r--r--tests/docx.notes.native2
-rw-r--r--tests/docx.tables.docxbin0 -> 42792 bytes
-rw-r--r--tests/docx.tables.native24
-rw-r--r--tests/docx.unicode.docxbin0 -> 13098 bytes
-rw-r--r--tests/docx.unicode.native1
19 files changed, 139 insertions, 0 deletions
diff --git a/tests/Tests/Readers/DocX.hs b/tests/Tests/Readers/DocX.hs
new file mode 100644
index 000000000..f4564ea1d
--- /dev/null
+++ b/tests/Tests/Readers/DocX.hs
@@ -0,0 +1,68 @@
+module Tests.Readers.DocX (tests) where
+
+import Text.Pandoc.Options
+import Text.Pandoc.Readers.Native
+import Text.Pandoc.Definition
+import Tests.Helpers
+import Test.Framework
+import qualified Data.ByteString.Lazy as B
+import Text.Pandoc.Readers.DocX
+
+compareOutput :: FilePath -> FilePath -> IO (Pandoc, Pandoc)
+compareOutput docxFile nativeFile = do
+ df <- B.readFile docxFile
+ nf <- Prelude.readFile nativeFile
+ return $ (readDocX def df, readNative nf)
+
+testCompare' :: String -> FilePath -> FilePath -> IO Test
+testCompare' name docxFile nativeFile = do
+ (dp, np) <- compareOutput docxFile nativeFile
+ return $ test id name (dp, np)
+
+testCompare :: String -> FilePath -> FilePath -> Test
+testCompare name docxFile nativeFile =
+ buildTest $ testCompare' name docxFile nativeFile
+
+
+tests :: [Test]
+tests = [ testGroup "inlines"
+ [ testCompare
+ "font formatting"
+ "docx.inline_formatting.docx"
+ "docx.inline_formatting.native"
+ , testCompare
+ "hyperlinks"
+ "docx.links.docx"
+ "docx.links.native"
+ , testCompare
+ "inline image with reference output"
+ "docx.image.docx"
+ "docx.image_no_embed.native"
+ , testCompare
+ "handling unicode input"
+ "docx.unicode.docx"
+ "docx.unicode.native"]
+ , testGroup "blocks"
+ [ testCompare
+ "headers"
+ "docx.headers.docx"
+ "docx.headers.native"
+ , testCompare
+ "lists"
+ "docx.lists.docx"
+ "docx.lists.native"
+ , testCompare
+ "footnotes and endnotes"
+ "docx.notes.docx"
+ "docx.notes.native"
+ , testCompare
+ "blockquotes (parsing indent as blockquote)"
+ "docx.block_quotes.docx"
+ "docx.block_quotes_parse_indent.native"
+ , testCompare
+ "tables"
+ "docx.tables.docx"
+ "docx.tables.native"
+ ]
+ ]
+
diff --git a/tests/docx.block_quotes.docx b/tests/docx.block_quotes.docx
new file mode 100644
index 000000000..729ae1f43
--- /dev/null
+++ b/tests/docx.block_quotes.docx
Binary files differ
diff --git a/tests/docx.block_quotes_parse_indent.native b/tests/docx.block_quotes_parse_indent.native
new file mode 100644
index 000000000..da1cef110
--- /dev/null
+++ b/tests/docx.block_quotes_parse_indent.native
@@ -0,0 +1,8 @@
+[Header 2 ("",[],[]) [Str "Some",Space,Str "block",Space,Str "quotes,",Space,Str "in",Space,Str "different",Space,Str "ways"]
+,Para [Str "This",Space,Str "is",Space,Str "the",Space,Str "proper",Space,Str "way,",Space,Str "with",Space,Str "a",Space,Str "style"]
+,BlockQuote
+ [Para [Str "I",Space,Str "don\8217t",Space,Str "know",Space,Str "why",Space,Str "this",Space,Str "would",Space,Str "be",Space,Str "in",Space,Str "italics,",Space,Str "but",Space,Str "so",Space,Str "it",Space,Str "appears",Space,Str "to",Space,Str "be",Space,Str "on",Space,Str "my",Space,Str "screen."]]
+,Para [Str "And",Space,Str "this",Space,Str "is",Space,Str "the",Space,Str "way",Space,Str "that",Space,Str "most",Space,Str "people",Space,Str "do",Space,Str "it:"]
+,BlockQuote
+ [Para [Str "I",Space,Str "just",Space,Str "indented",Space,Str "this,",Space,Str "so",Space,Str "it",Space,Str "looks",Space,Str "like",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "I",Space,Str "think",Space,Str "this",Space,Str "is",Space,Str "how",Space,Str "most",Space,Str "people",Space,Str "do",Space,Str "block",Space,Str "quotes",Space,Str "in",Space,Str "their",Space,Str "documents."]]
+,Para [Str "And",Space,Str "back",Space,Str "to",Space,Str "the",Space,Str "normal",Space,Str "style."]]
diff --git a/tests/docx.headers.docx b/tests/docx.headers.docx
new file mode 100644
index 000000000..630b6bfc5
--- /dev/null
+++ b/tests/docx.headers.docx
Binary files differ
diff --git a/tests/docx.headers.native b/tests/docx.headers.native
new file mode 100644
index 000000000..e4d4a4781
--- /dev/null
+++ b/tests/docx.headers.native
@@ -0,0 +1,5 @@
+[Header 1 ("",[],[]) [Str "A",Space,Str "Test",Space,Str "of",Space,Str "Headers"]
+,Header 2 ("",[],[]) [Str "Second",Space,Str "Level"]
+,Para [Str "Some",Space,Str "plain",Space,Str "text."]
+,Header 3 ("",[],[]) [Str "Third",Space,Str "level"]
+,Para [Str "Some",Space,Str "more",Space,Str "plain",Space,Str "text."]]
diff --git a/tests/docx.image.docx b/tests/docx.image.docx
new file mode 100644
index 000000000..060f2b204
--- /dev/null
+++ b/tests/docx.image.docx
Binary files differ
diff --git a/tests/docx.image_no_embed.native b/tests/docx.image_no_embed.native
new file mode 100644
index 000000000..18debf135
--- /dev/null
+++ b/tests/docx.image_no_embed.native
@@ -0,0 +1,2 @@
+[Header 2 ("",[],[]) [Str "An",Space,Str "image"]
+,Para [Image [] ("word/media/image1.jpeg","")]]
diff --git a/tests/docx.inline_formatting.docx b/tests/docx.inline_formatting.docx
new file mode 100644
index 000000000..eccf26425
--- /dev/null
+++ b/tests/docx.inline_formatting.docx
Binary files differ
diff --git a/tests/docx.inline_formatting.native b/tests/docx.inline_formatting.native
new file mode 100644
index 000000000..dc8a3d19a
--- /dev/null
+++ b/tests/docx.inline_formatting.native
@@ -0,0 +1,5 @@
+[Para [Str "Regular",Space,Str "text",Space,Emph [Str "italics"],Space,Strong [Str "bold",Space,Emph [Str "bold",Space,Str "italics"]],Str "."]
+,Para [Str "This",Space,Str "is",Space,SmallCaps [Str "Small",Space,Str "Caps"],Str ",",Space,Str "and",Space,Str "this",Space,Str "is",Space,Strikeout [Str "strikethrough"],Str "."]
+,Para [Str "Some",Space,Str "people",Space,Str "use",Space,Span ("",[],[("underline","single")]) [Str "single",Space,Str "underlines",Space,Str "for",Space,Emph [Str "emphasis"]],Str "."]
+,Para [Str "Above",Space,Str "the",Space,Str "line",Space,Str "is",Space,Superscript [Str "superscript"],Space,Str "and",Space,Str "below",Space,Str "the",Space,Str "line",Space,Str "is",Space,Subscript [Str "subscript"],Str "."]
+,Para [Str "A",Space,Str "line",LineBreak,Str "break."]]
diff --git a/tests/docx.links.docx b/tests/docx.links.docx
new file mode 100644
index 000000000..10ec62fd7
--- /dev/null
+++ b/tests/docx.links.docx
Binary files differ
diff --git a/tests/docx.links.native b/tests/docx.links.native
new file mode 100644
index 000000000..98768de5a
--- /dev/null
+++ b/tests/docx.links.native
@@ -0,0 +1,6 @@
+[Header 2 ("",[],[]) [Str "An",Space,Str "internal",Space,Str "link",Space,Str "and",Space,Str "an",Space,Str "external",Space,Str "link"]
+,Para [Str "An",Space,Link [Str "external",Space,Str "link"] ("http://google.com",""),Space,Str "to",Space,Str "a",Space,Str "popular",Space,Str "website."]
+,Para [Str "An",Space,Link [Str "internal",Space,Str "link"] ("#_A_section_for",""),Space,Str "to",Space,Str "a",Space,Str "section",Space,Str "header."]
+,Para [Str "An",Space,Link [Str "internal",Space,Str "link"] ("#my_bookmark",""),Space,Str "to",Space,Str "a",Space,Str "bookmark."]
+,Header 2 ("_A_section_for",[],[]) [Str "A",Space,Str "section",Space,Str "for",Space,Str "testing",Space,Str "link",Space,Str "targets"]
+,Para [Str "A",Space,Str "bookmark",Space,Str "right",Space,Span ("my_bookmark",["anchor"],[]) [],Str "here"]]
diff --git a/tests/docx.lists.docx b/tests/docx.lists.docx
new file mode 100644
index 000000000..bf7fd8ae4
--- /dev/null
+++ b/tests/docx.lists.docx
Binary files differ
diff --git a/tests/docx.lists.native b/tests/docx.lists.native
new file mode 100644
index 000000000..e46bc140b
--- /dev/null
+++ b/tests/docx.lists.native
@@ -0,0 +1,18 @@
+[Header 2 ("",[],[]) [Str "Some",Space,Str "nested",Space,Str "lists"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "one"]]
+ ,[Para [Str "two"]
+ ,OrderedList (1,LowerAlpha,DefaultDelim)
+ [[Para [Str "a"]]
+ ,[Para [Str "b"]]]]]
+,BulletList
+ [[Para [Str "one"]]
+ ,[Para [Str "two"]
+ ,BulletList
+ [[Para [Str "three"]
+ ,BulletList
+ [[Para [Str "four"]
+ ,Para [Str "Sub",Space,Str "paragraph"]]]]]]
+ ,[Para [Str "Same",Space,Str "list"]]]
+,BulletList
+ [[Para [Str "Different",Space,Str "list",Space,Str "adjacent",Space,Str "to",Space,Str "the",Space,Str "one",Space,Str "above."]]]]
diff --git a/tests/docx.notes.docx b/tests/docx.notes.docx
new file mode 100644
index 000000000..eb6fa12d4
--- /dev/null
+++ b/tests/docx.notes.docx
Binary files differ
diff --git a/tests/docx.notes.native b/tests/docx.notes.native
new file mode 100644
index 000000000..1e9b6bba4
--- /dev/null
+++ b/tests/docx.notes.native
@@ -0,0 +1,2 @@
+[Header 2 ("",[],[]) [Str "A",Space,Str "footnote"]
+,Para [Str "Test",Space,Str "footnote.",Note [Para [Space,Str "My",Space,Str "note."]],Space,Str "Test",Space,Str "endnote.",Note [Para [Space,Str "This",Space,Str "is",Space,Str "an",Space,Str "endnote",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."]]]]
diff --git a/tests/docx.tables.docx b/tests/docx.tables.docx
new file mode 100644
index 000000000..7dcff8d35
--- /dev/null
+++ b/tests/docx.tables.docx
Binary files differ
diff --git a/tests/docx.tables.native b/tests/docx.tables.native
new file mode 100644
index 000000000..8dbaabda7
--- /dev/null
+++ b/tests/docx.tables.native
@@ -0,0 +1,24 @@
+[Header 2 ("",[],[]) [Str "A",Space,Str "table,",Space,Str "with",Space,Str "and",Space,Str "without",Space,Str "a",Space,Str "header",Space,Str "row"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0,0.0]
+ [[Para [Str "Name"]]
+ ,[Para [Str "Game"]]
+ ,[Para [Str "Fame"]]
+ ,[Para [Str "Blame"]]]
+ [[[Para [Str "Lebron",Space,Str "James"]]
+ ,[Para [Str "Basketball"]]
+ ,[Para [Str "Very",Space,Str "High"]]
+ ,[Para [Str "Leaving",Space,Str "Cleveland"]]]
+ ,[[Para [Str "Ryan",Space,Str "Braun"]]
+ ,[Para [Str "Baseball"]]
+ ,[Para [Str "Moderate"]]
+ ,[Para [Str "Steroids"]]]
+ ,[[Para [Str "Russell",Space,Str "Wilson"]]
+ ,[Para [Str "Football"]]
+ ,[Para [Str "High"]]
+ ,[Para [Str "Tacky",Space,Str "uniform"]]]]
+,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
+ []
+ [[[Para [Str "Sinple"]]
+ ,[Para [Str "Table"]]]
+ ,[[Para [Str "Without"]]
+ ,[Para [Str "Header"]]]]]
diff --git a/tests/docx.unicode.docx b/tests/docx.unicode.docx
new file mode 100644
index 000000000..78d0107a1
--- /dev/null
+++ b/tests/docx.unicode.docx
Binary files differ
diff --git a/tests/docx.unicode.native b/tests/docx.unicode.native
new file mode 100644
index 000000000..e636355c7
--- /dev/null
+++ b/tests/docx.unicode.native
@@ -0,0 +1 @@
+[Para [Str "Hello,",Space,Str "\19990\30028.",Space,Str "This",Space,Str "costs",Space,Str "\8364\&10."]]