From 0808449547a2ec3469dbcc82c1755d895c1057e5 Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Mon, 11 Aug 2014 23:10:50 -0400 Subject: Docx: Add dropcap tests. --- tests/Tests/Readers/Docx.hs | 10 ++++++---- tests/docx.drop_cap.docx | Bin 0 -> 26931 bytes tests/docx.drop_cap.native | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 tests/docx.drop_cap.docx create mode 100644 tests/docx.drop_cap.native (limited to 'tests') diff --git a/tests/Tests/Readers/Docx.hs b/tests/Tests/Readers/Docx.hs index c310cc8d7..65fdd4a55 100644 --- a/tests/Tests/Readers/Docx.hs +++ b/tests/Tests/Readers/Docx.hs @@ -82,14 +82,14 @@ compareMediaBagIO docxFile = do df <- B.readFile docxFile let (_, mb) = readDocx def df bools <- mapM - (\(fp, _, _) -> compareMediaPathIO fp mb docxFile) + (\(fp, _, _) -> compareMediaPathIO fp mb docxFile) (mediaDirectory mb) return $ and bools testMediaBagIO :: String -> FilePath -> IO Test testMediaBagIO name docxFile = do outcome <- compareMediaBagIO docxFile - return $ testCase name (assertBool + return $ testCase name (assertBool ("Media didn't match media bag in file " ++ docxFile) outcome) @@ -176,7 +176,10 @@ tests = [ testGroup "inlines" "code block" "docx.codeblock.docx" "docx.codeblock.native" - + , testCompare + "dropcap paragraphs" + "docx.drop_cap.docx" + "docx.drop_cap.native" ] , testGroup "track changes" [ testCompare @@ -229,4 +232,3 @@ tests = [ testGroup "inlines" ] ] - diff --git a/tests/docx.drop_cap.docx b/tests/docx.drop_cap.docx new file mode 100644 index 000000000..19fab4a52 Binary files /dev/null and b/tests/docx.drop_cap.docx differ diff --git a/tests/docx.drop_cap.native b/tests/docx.drop_cap.native new file mode 100644 index 000000000..e6eb29de7 --- /dev/null +++ b/tests/docx.drop_cap.native @@ -0,0 +1,4 @@ +[Para [Str "D",Str "rop",Space,Str "cap."] +,Para [Str "Next",Space,Str "paragraph."] +,Para [Str "D",Str "rop",Space,Str "cap",Space,Str "in",Space,Str "margin."] +,Para [Str "Drop",Space,Str "cap",Space,Str "(not",Space,Str "really)."]] -- cgit v1.2.3 From 45ec035e93ec0c32f9fb7d7f2f99ca17de73ebf9 Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Mon, 11 Aug 2014 23:30:12 -0400 Subject: Docx reader: combine inlines properly in dropcaps. Make sure that adjacent inlines are combined properly in dropcaps. This updates the test results as well. --- src/Text/Pandoc/Readers/Docx.hs | 2 +- tests/docx.drop_cap.native | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index d6d5f317c..c856ca30a 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -462,7 +462,7 @@ bodyPartToBlocks (Paragraph pPr parparts) bodyPartToBlocks (Paragraph pPr parparts) = do ils <- parPartsToInlines parparts >>= (return . normalizeSpaces) dropIls <- gets docxDropCap - let ils' = dropIls ++ ils + let ils' = reduceList $ dropIls ++ ils if dropCap pPr then do modify $ \s -> s { docxDropCap = ils' } return [] diff --git a/tests/docx.drop_cap.native b/tests/docx.drop_cap.native index e6eb29de7..d361cfb0b 100644 --- a/tests/docx.drop_cap.native +++ b/tests/docx.drop_cap.native @@ -1,4 +1,4 @@ -[Para [Str "D",Str "rop",Space,Str "cap."] +[Para [Str "Drop",Space,Str "cap."] ,Para [Str "Next",Space,Str "paragraph."] -,Para [Str "D",Str "rop",Space,Str "cap",Space,Str "in",Space,Str "margin."] +,Para [Str "Drop",Space,Str "cap",Space,Str "in",Space,Str "margin."] ,Para [Str "Drop",Space,Str "cap",Space,Str "(not",Space,Str "really)."]] -- cgit v1.2.3