diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-03-16 12:02:40 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-03-16 12:02:40 -0700 |
commit | 619b2e8ca207b39829b74683cfc514ffbf4ddbbb (patch) | |
tree | c8f9c2d44621ccab0398ecb064e7e23cb0f4339a /tests | |
parent | 6fc578b79a43f1f2f522d1ba52b9133ce95b52dc (diff) | |
parent | 59c4d28d8c70e3d23428897d78a3c401e30612e5 (diff) | |
download | pandoc-619b2e8ca207b39829b74683cfc514ffbf4ddbbb.tar.gz |
Merge pull request #1968 from lierdakil/issue1607
Fixes for multiple docx writer style bugs.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Tests/Writers/Docx.hs | 128 | ||||
-rw-r--r-- | tests/docx/image_no_embed_writer.native | 2 | ||||
-rw-r--r-- | tests/docx/inline_formatting_writer.native | 5 | ||||
-rw-r--r-- | tests/docx/inline_images_writer.native | 2 | ||||
-rw-r--r-- | tests/docx/links_writer.native | 6 | ||||
-rw-r--r-- | tests/docx/lists_writer.native | 17 | ||||
-rw-r--r-- | tests/media/rId25.jpg | 0 | ||||
-rw-r--r-- | tests/media/rId26.jpg | 0 | ||||
-rw-r--r-- | tests/media/rId27.jpg | 0 | ||||
-rw-r--r-- | tests/test-pandoc.hs | 2 |
10 files changed, 162 insertions, 0 deletions
diff --git a/tests/Tests/Writers/Docx.hs b/tests/Tests/Writers/Docx.hs new file mode 100644 index 000000000..80ce0014d --- /dev/null +++ b/tests/Tests/Writers/Docx.hs @@ -0,0 +1,128 @@ +module Tests.Writers.Docx (tests) where + +import Text.Pandoc.Options +import Text.Pandoc.Readers.Native +import Text.Pandoc.Definition +import Tests.Helpers +import Test.Framework +import Text.Pandoc.Readers.Docx +import Text.Pandoc.Writers.Docx + +type Options = (WriterOptions, ReaderOptions) + +compareOutput :: Options + -> FilePath + -> IO (Pandoc, Pandoc) +compareOutput opts nativeFile = do + nf <- Prelude.readFile nativeFile + df <- writeDocx (fst opts) (readNative nf) + let (p, _) = readDocx (snd opts) df + return (p, readNative nf) + +testCompareWithOptsIO :: Options -> String -> FilePath -> IO Test +testCompareWithOptsIO opts name nativeFile = do + (dp, np) <- compareOutput opts nativeFile + return $ test id name (dp, np) + +testCompareWithOpts :: Options -> String -> FilePath -> Test +testCompareWithOpts opts name nativeFile = + buildTest $ testCompareWithOptsIO opts name nativeFile + +testCompare :: String -> FilePath -> Test +testCompare = testCompareWithOpts def + +tests :: [Test] +tests = [ testGroup "inlines" + [ testCompare + "font formatting" + "docx/inline_formatting_writer.native" + , testCompare + "font formatting with character styles" + "docx/char_styles.native" + , testCompare + "hyperlinks" + "docx/links_writer.native" + , testCompare + "inline image" + "docx/image_no_embed_writer.native" + , testCompare + "inline image in links" + "docx/inline_images_writer.native" + , testCompare + "handling unicode input" + "docx/unicode.native" + , testCompare + "literal tabs" + "docx/tabs.native" + , testCompare + "normalizing inlines" + "docx/normalize.native" + , testCompare + "normalizing inlines deep inside blocks" + "docx/deep_normalize.native" + , testCompare + "move trailing spaces outside of formatting" + "docx/trailing_spaces_in_formatting.native" + , testCompare + "inline code (with VerbatimChar style)" + "docx/inline_code.native" + , testCompare + "inline code in subscript and superscript" + "docx/verbatim_subsuper.native" + ] + , testGroup "blocks" + [ testCompare + "headers" + "docx/headers.native" + , testCompare + "headers already having auto identifiers" + "docx/already_auto_ident.native" + , testCompare + "numbered headers automatically made into list" + "docx/numbered_header.native" + , testCompare + "i18n blocks (headers and blockquotes)" + "docx/i18n_blocks.native" + -- Continuation does not survive round-trip + , testCompare + "lists" + "docx/lists_writer.native" + , testCompare + "definition lists" + "docx/definition_list.native" + , testCompare + "custom defined lists in styles" + "docx/german_styled_lists.native" + , testCompare + "footnotes and endnotes" + "docx/notes.native" + , testCompare + "blockquotes (parsing indent as blockquote)" + "docx/block_quotes_parse_indent.native" + , testCompare + "hanging indents" + "docx/hanging_indent.native" + -- tables headers do not survive round-trip, should look into that + , testCompare + "tables" + "docx/tables.native" + , testCompare + "tables with lists in cells" + "docx/table_with_list_cell.native" + , testCompare + "code block" + "docx/codeblock.native" + , testCompare + "dropcap paragraphs" + "docx/drop_cap.native" + ] + , testGroup "metadata" + [ testCompareWithOpts (def,def{readerStandalone=True}) + "metadata fields" + "docx/metadata.native" + , testCompareWithOpts (def,def{readerStandalone=True}) + "stop recording metadata with normal text" + "docx/metadata_after_normal.native" + ] + + ] diff --git a/tests/docx/image_no_embed_writer.native b/tests/docx/image_no_embed_writer.native new file mode 100644 index 000000000..21802ebd1 --- /dev/null +++ b/tests/docx/image_no_embed_writer.native @@ -0,0 +1,2 @@ +[Para [Str "An",Space,Str "image:"] +,Para [Image [] ("media/rId25.jpg","")]] diff --git a/tests/docx/inline_formatting_writer.native b/tests/docx/inline_formatting_writer.native new file mode 100644 index 000000000..be346204e --- /dev/null +++ b/tests/docx/inline_formatting_writer.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,Emph [Str "single",Space,Str "underlines",Space,Str "for",Space,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/inline_images_writer.native b/tests/docx/inline_images_writer.native new file mode 100644 index 000000000..da2a2709b --- /dev/null +++ b/tests/docx/inline_images_writer.native @@ -0,0 +1,2 @@ +[Para [Str "This",Space,Str "picture",Space,Image [] ("media/rId26.jpg",""),Space,Str "is",Space,Str "an",Space,Str "identicon."] +,Para [Str "Here",Space,Str "is",Space,Link [Str "one",Space,Image [] ("media/rId27.jpg",""),Space,Str "that"] ("http://www.google.com",""),Space,Str "links."]] diff --git a/tests/docx/links_writer.native b/tests/docx/links_writer.native new file mode 100644 index 000000000..cc00e4326 --- /dev/null +++ b/tests/docx/links_writer.native @@ -0,0 +1,6 @@ +[Header 2 ("an-internal-link-and-an-external-link",[],[]) [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 "external",Space,Str "link"] ("http://johnmacfarlane.net/pandoc/README.html#synopsis",""),Space,Str "to",Space,Str "a",Space,Str "website",Space,Str "with",Space,Str "an",Space,Str "anchor."] +,Para [Str "An",Space,Link [Str "internal",Space,Str "link"] ("#a-section-for-testing-link-targets",""),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-testing-link-targets",[],[]) [Str "A",Space,Str "section",Space,Str "for",Space,Str "testing",Space,Str "link",Space,Str "targets"]] diff --git a/tests/docx/lists_writer.native b/tests/docx/lists_writer.native new file mode 100644 index 000000000..4c44ea603 --- /dev/null +++ b/tests/docx/lists_writer.native @@ -0,0 +1,17 @@ +[Header 2 ("some-nested-lists",[],[]) [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 "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/media/rId25.jpg b/tests/media/rId25.jpg new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/media/rId25.jpg diff --git a/tests/media/rId26.jpg b/tests/media/rId26.jpg new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/media/rId26.jpg diff --git a/tests/media/rId27.jpg b/tests/media/rId27.jpg new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/media/rId27.jpg diff --git a/tests/test-pandoc.hs b/tests/test-pandoc.hs index b7b1c30b1..dd92a271a 100644 --- a/tests/test-pandoc.hs +++ b/tests/test-pandoc.hs @@ -20,6 +20,7 @@ import qualified Tests.Writers.Native import qualified Tests.Writers.Markdown import qualified Tests.Writers.Plain import qualified Tests.Writers.AsciiDoc +import qualified Tests.Writers.Docx import qualified Tests.Shared import qualified Tests.Walk import Text.Pandoc.Shared (inDirectory) @@ -38,6 +39,7 @@ tests = [ testGroup "Old" Tests.Old.tests , testGroup "Markdown" Tests.Writers.Markdown.tests , testGroup "Plain" Tests.Writers.Plain.tests , testGroup "AsciiDoc" Tests.Writers.AsciiDoc.tests + , testGroup "Docx" Tests.Writers.Docx.tests ] , testGroup "Readers" [ testGroup "LaTeX" Tests.Readers.LaTeX.tests |