From aadac3c8911300676333596f8428532dd43d461f Mon Sep 17 00:00:00 2001 From: "laptop1\\Andrew" Date: Sat, 24 Feb 2018 00:25:05 +0800 Subject: Docx test: adjust test for fix of bug This commit adjusts the test cases for the Docx writer after the fix of #3930. - Adjusted test cases with inline images. The inline images now have the correct sizing, title and description. - Modified the test case to include an image multiple times with different sizing each time. - Tested on Windows 8.1 with Word 2007 (12.0.6705.5000) The files are not corrupted and display exactly what is expected. --- test/docx/golden/image.docx | Bin 26296 -> 26452 bytes test/docx/golden/inline_images.docx | Bin 26460 -> 26506 bytes test/docx/image_writer_test.native | 13 ++++++++----- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'test/docx') diff --git a/test/docx/golden/image.docx b/test/docx/golden/image.docx index dc49f266b..95a28a098 100644 Binary files a/test/docx/golden/image.docx and b/test/docx/golden/image.docx differ diff --git a/test/docx/golden/inline_images.docx b/test/docx/golden/inline_images.docx index 6bd4b3a34..62c5943ba 100644 Binary files a/test/docx/golden/inline_images.docx and b/test/docx/golden/inline_images.docx differ diff --git a/test/docx/image_writer_test.native b/test/docx/image_writer_test.native index a568cbca0..a0fb3ee3a 100644 --- a/test/docx/image_writer_test.native +++ b/test/docx/image_writer_test.native @@ -1,5 +1,8 @@ -Pandoc (Meta {unMeta = fromList []}) -[Para [Image ("",[],[]) [] ("lalune.jpg","")] -,Para [Image ("",[],[]) [Str "The",Space,Str "Moon"] ("lalune.jpg","fig:")] -,Header 1 ("one-more",[],[]) [Str "One",Space,Str "More"] -,Para [Image ("",[],[]) [Str "The",Space,Str "Moon"] ("lalune.jpg","fig:")]] \ No newline at end of file +[Para [Str "No",Space,Str "width",Space,Str "given:"] +,Para [Image ("",[],[]) [Str "testimg"] ("lalune.jpg","fig:")] +,Para [Str "With",Space,Str "height",Space,Str "10cm:"] +,Para [Image ("",[],[("height","10cm")]) [Str "2testimg"] ("lalune.jpg","fig:")] +,Para [Str "With",Space,Str "width",Space,Str "6cm:"] +,Para [Image ("",[],[("width","6cm")]) [Str "3testimg"] ("lalune.jpg","fig:")] +,Header 1 ("with-height-3in-and-width-6in",[],[]) [Str "With",Space,Str "height",Space,Str "3in",Space,Str "and",Space,Str "width",Space,Str "6in:"] +,Para [Image ("",[],[("width","6in"),("height","3in")]) [Str "4testimg"] ("lalune.jpg","fig:")]] \ No newline at end of file -- cgit v1.2.3 From 5ada5cceaceb05316dbb7241bca7d3effb4d9767 Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Fri, 23 Feb 2018 14:23:14 -0500 Subject: Docx reader: Don't look up dependant run styles if +styles is enabled. It makes more sense not to interpret -- otherwise using the original document as the reference-doc would produce two of everything: the interpreted version and the uninterpreted style version. --- MANUAL.txt | 4 +- src/Text/Pandoc/Readers/Docx.hs | 75 ++++++++++++++++--------------- test/docx/custom-style-with-styles.native | 2 +- 3 files changed, 42 insertions(+), 39 deletions(-) (limited to 'test/docx') diff --git a/MANUAL.txt b/MANUAL.txt index 144ec8494..cf95d8f6c 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -4562,8 +4562,8 @@ And with the extension: ::: ::: {custom-style="BodyText"} - This is text with an [*emphasized*]{custom-style="Emphatic"} text style. - And this is text with a [**strengthened**]{custom-style="Strengthened"} + This is text with an [emphasized]{custom-style="Emphatic"} text style. + And this is text with a [strengthened]{custom-style="Strengthened"} text style. ::: diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index 5f2ca0fff..f1683a394 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -252,33 +252,36 @@ parPartToString _ = "" blacklistedCharStyles :: [String] blacklistedCharStyles = ["Hyperlink"] -resolveDependentRunStyle :: RunStyle -> RunStyle +resolveDependentRunStyle :: PandocMonad m => RunStyle -> DocxContext m RunStyle resolveDependentRunStyle rPr | Just (s, _) <- rStyle rPr, s `elem` blacklistedCharStyles = - rPr - | Just (_, cs) <- rStyle rPr = - let rPr' = resolveDependentRunStyle cs - in - RunStyle { isBold = case isBold rPr of - Just bool -> Just bool - Nothing -> isBold rPr' - , isItalic = case isItalic rPr of - Just bool -> Just bool - Nothing -> isItalic rPr' - , isSmallCaps = case isSmallCaps rPr of - Just bool -> Just bool - Nothing -> isSmallCaps rPr' - , isStrike = case isStrike rPr of - Just bool -> Just bool - Nothing -> isStrike rPr' - , rVertAlign = case rVertAlign rPr of - Just valign -> Just valign - Nothing -> rVertAlign rPr' - , rUnderline = case rUnderline rPr of - Just ulstyle -> Just ulstyle - Nothing -> rUnderline rPr' - , rStyle = rStyle rPr } - | otherwise = rPr + return rPr + | Just (_, cs) <- rStyle rPr = do + opts <- asks docxOptions + if isEnabled Ext_styles opts + then return rPr + else do rPr' <- resolveDependentRunStyle cs + return $ + RunStyle { isBold = case isBold rPr of + Just bool -> Just bool + Nothing -> isBold rPr' + , isItalic = case isItalic rPr of + Just bool -> Just bool + Nothing -> isItalic rPr' + , isSmallCaps = case isSmallCaps rPr of + Just bool -> Just bool + Nothing -> isSmallCaps rPr' + , isStrike = case isStrike rPr of + Just bool -> Just bool + Nothing -> isStrike rPr' + , rVertAlign = case rVertAlign rPr of + Just valign -> Just valign + Nothing -> rVertAlign rPr' + , rUnderline = case rUnderline rPr of + Just ulstyle -> Just ulstyle + Nothing -> rUnderline rPr' + , rStyle = rStyle rPr } + | otherwise = return rPr extraRunStyleInfo :: PandocMonad m => RunStyle -> DocxContext m (Inlines -> Inlines) extraRunStyleInfo rPr @@ -337,18 +340,18 @@ runStyleToTransform rPr runToInlines :: PandocMonad m => Run -> DocxContext m Inlines runToInlines (Run rs runElems) | Just (s, _) <- rStyle rs - , s `elem` codeStyles = - let rPr = resolveDependentRunStyle rs - codeString = code $ concatMap runElemToString runElems - in - return $ case rVertAlign rPr of - Just SupScrpt -> superscript codeString - Just SubScrpt -> subscript codeString - _ -> codeString + , s `elem` codeStyles = do + rPr <- resolveDependentRunStyle rs + let codeString = code $ concatMap runElemToString runElems + return $ case rVertAlign rPr of + Just SupScrpt -> superscript codeString + Just SubScrpt -> subscript codeString + _ -> codeString | otherwise = do - let ils = smushInlines (map runElemToInlines runElems) - transform <- runStyleToTransform $ resolveDependentRunStyle rs - return $ transform ils + rPr <- resolveDependentRunStyle rs + let ils = smushInlines (map runElemToInlines runElems) + transform <- runStyleToTransform rPr + return $ transform ils runToInlines (Footnote bps) = do blksList <- smushBlocks <$> mapM bodyPartToBlocks bps return $ note blksList diff --git a/test/docx/custom-style-with-styles.native b/test/docx/custom-style-with-styles.native index 6b0381408..61f11911d 100644 --- a/test/docx/custom-style-with-styles.native +++ b/test/docx/custom-style-with-styles.native @@ -1,7 +1,7 @@ [Div ("",[],[("custom-style","FirstParagraph")]) [Para [Str "This",Space,Str "is",Space,Str "some",Space,Str "text."]] ,Div ("",[],[("custom-style","BodyText")]) - [Para [Str "This",Space,Str "is",Space,Str "text",Space,Str "with",Space,Str "an",Space,Span ("",[],[("custom-style","Emphatic")]) [Emph [Str "emphasized"]],Space,Str "text",Space,Str "style.",Space,Str "And",Space,Str "this",Space,Str "is",Space,Str "text",Space,Str "with",Space,Str "a",Space,Span ("",[],[("custom-style","Strengthened")]) [Strong [Str "strengthened"]],Space,Str "text",Space,Str "style."]] + [Para [Str "This",Space,Str "is",Space,Str "text",Space,Str "with",Space,Str "an",Space,Span ("",[],[("custom-style","Emphatic")]) [Str "emphasized"],Space,Str "text",Space,Str "style.",Space,Str "And",Space,Str "this",Space,Str "is",Space,Str "text",Space,Str "with",Space,Str "a",Space,Span ("",[],[("custom-style","Strengthened")]) [Str "strengthened"],Space,Str "text",Space,Str "style."]] ,Div ("",[],[("custom-style","MyBlockStyle")]) [BlockQuote [Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "styled",Space,Str "paragraph",Space,Str "that",Space,Str "inherits",Space,Str "from",Space,Str "Block",Space,Str "Text."]]]] -- cgit v1.2.3 From 7d3e7a5a6d9e7b139fd15e10a52b85f87aba42b1 Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Wed, 28 Feb 2018 16:27:18 -0500 Subject: Docx reader: Handle nested sdt tags. Previously we had only unwrapped one level of sdt tags. Now we recurse if we find them. Closes: #4415 --- src/Text/Pandoc/Readers/Docx/Parse.hs | 2 +- test/Tests/Readers/Docx.hs | 4 ++++ test/docx/nested_sdt.docx | Bin 0 -> 11694 bytes test/docx/nested_sdt.native | 3 +++ 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/docx/nested_sdt.docx create mode 100644 test/docx/nested_sdt.native (limited to 'test/docx') diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs index c123a0018..1f7f07e36 100644 --- a/src/Text/Pandoc/Readers/Docx/Parse.hs +++ b/src/Text/Pandoc/Readers/Docx/Parse.hs @@ -136,7 +136,7 @@ unwrapSDT :: NameSpaces -> Content -> [Content] unwrapSDT ns (Elem element) | isElem ns "w" "sdt" element , Just sdtContent <- findChildByName ns "w" "sdtContent" element - = map Elem $ elChildren sdtContent + = concatMap (unwrapSDT ns) $ map Elem $ elChildren sdtContent unwrapSDT _ content = [content] unwrapSDTchild :: NameSpaces -> Content -> Content diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs index cef80d6d1..0ba765c93 100644 --- a/test/Tests/Readers/Docx.hs +++ b/test/Tests/Readers/Docx.hs @@ -178,6 +178,10 @@ tests = [ testGroup "inlines" "inlines inside of Structured Document Tags" "docx/sdt_elements.docx" "docx/sdt_elements.native" + , testCompare + "nested Structured Document Tags" + "docx/nested_sdt.docx" + "docx/nested_sdt.native" , testCompare "remove anchor spans with nothing pointing to them" "docx/unused_anchors.docx" diff --git a/test/docx/nested_sdt.docx b/test/docx/nested_sdt.docx new file mode 100644 index 000000000..1a0827db3 Binary files /dev/null and b/test/docx/nested_sdt.docx differ diff --git a/test/docx/nested_sdt.native b/test/docx/nested_sdt.native new file mode 100644 index 000000000..d0adc05ac --- /dev/null +++ b/test/docx/nested_sdt.native @@ -0,0 +1,3 @@ +[Para [Str "Test",Space,Str "Paragraph1"] +,Para [Str "Test",Space,Str "Paragraph2"] +,Para [Str "Test",Space,Str "Paragraph3"]] -- cgit v1.2.3 From 85a65c6a513421b373bbf23d81f53a16d62aa013 Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Tue, 13 Mar 2018 22:12:55 -0400 Subject: Docx reader: add tests for nested smart tags. --- test/Tests/Readers/Docx.hs | 4 ++++ test/docx/nested_smart_tags.docx | Bin 0 -> 13641 bytes test/docx/nested_smart_tags.native | 7 +++++++ 3 files changed, 11 insertions(+) create mode 100644 test/docx/nested_smart_tags.docx create mode 100644 test/docx/nested_smart_tags.native (limited to 'test/docx') diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs index 0ba765c93..9bbe85cba 100644 --- a/test/Tests/Readers/Docx.hs +++ b/test/Tests/Readers/Docx.hs @@ -182,6 +182,10 @@ tests = [ testGroup "inlines" "nested Structured Document Tags" "docx/nested_sdt.docx" "docx/nested_sdt.native" + , testCompare + "nested Smart Tags" + "docx/nested_smart_tags.docx" + "docx/nested_smart_tags.native" , testCompare "remove anchor spans with nothing pointing to them" "docx/unused_anchors.docx" diff --git a/test/docx/nested_smart_tags.docx b/test/docx/nested_smart_tags.docx new file mode 100644 index 000000000..6719c44a8 Binary files /dev/null and b/test/docx/nested_smart_tags.docx differ diff --git a/test/docx/nested_smart_tags.native b/test/docx/nested_smart_tags.native new file mode 100644 index 000000000..e6c776a63 --- /dev/null +++ b/test/docx/nested_smart_tags.native @@ -0,0 +1,7 @@ +[Header 2 ("and-it-came-to-pass-in-the-course-of-those-many-days",["Myheading2"],[]) [Str "159.",Space,Str "And",Space,Str "It",Space,Str "Came",Space,Str "to",Space,Str "Pass",Space,Str "in",Space,Str "the",Space,Str "Course",Space,Str "of",Space,Str "Those",Space,Str "Many",Space,Str "Days"] +,Para [Str "I",Space,Str "heard"] +,Para [Str "\8220And",Space,Str "it",Space,Str "came",Space,Str "to",Space,Str "pass",Space,Str "in",Space,Str "the",Space,Str "course",Space,Str "of",Space,Str "those",Space,Str "many",Space,Str "days",Space,Str "that",Space,Str "the",Space,Str "king",Space,Str "of",Space,Str "Egypt",Space,Str "died;",Space,Str "and",Space,Str "the",Space,Str "children",Space,Str "of",Space,Str "Israel",Space,Str "sighed",Space,Str "by",Space,Str "reason",Space,Str "of",Space,Str "the",Space,Str "bondage,",Space,Str "and",Space,Str "they",Space,Str "cried,",Space,Str "and",Space,Str "their",Space,Str "cry",Space,Str "came",Space,Str "up",Space,Str "unto",Space,Str "God",Space,Str "by",Space,Str "reason",Space,Str "of",Space,Str "the",Space,Str "bondage.",Space,Str "And",Space,Str "God",Space,Str "heard",Space,Str "their",Space,Str "groaning\8221",Space,Str "(Exodus",Space,Str "2:23-4).",Space,Str "This",Space,Str "means",Space,Str "that",Space,Str "they",Space,Str "suffered",Space,Str "so",Space,Str "much",Space,Str "that",Space,Str "they",Space,Str "could",Space,Str "not",Space,Str "bear",Space,Str "it",Space,Str "any",Space,Str "longer.",Space,Str "And",Space,Str "they",Space,Str "so",Space,Str "pleaded",Space,Str "with",Space,Str "prayer,",Space,Str "that",Space,Str "\8220their",Space,Str "cry",Space,Str "came",Space,Str "up",Space,Str "unto",Space,Str "God.\8221"] +,Para [Str "But",Space,Str "we",Space,Str "can",Space,Str "see",Space,Str "that",Space,Str "they",Space,Str "were",Space,Str "saying,",Space,Str "\8220Would",Space,Str "that",Space,Str "we",Space,Str "had\8230",Space,Str "when",Space,Str "we",Space,Str "sat",Space,Str "by",Space,Str "the",Space,Str "flesh-pots,",Space,Str "when",Space,Str "we",Space,Str "did",Space,Str "eat",Space,Str "bread",Space,Str "to",Space,Str "the",Space,Str "full.\8221",Space,Str "And",Space,Str "they",Space,Str "also",Space,Str "said,",Space,Str "\8220We",Space,Str "remember",Space,Str "the",Space,Str "fish,",Space,Str "which",Space,Str "we",Space,Str "would",Space,Str "eat",Space,Str "in",Space,Str "Egypt",Space,Str "for",Space,Str "naught;",Space,Str "the",Space,Str "cucumbers,",Space,Str "and",Space,Str "the",Space,Str "melons,",Space,Str "and",Space,Str "the",Space,Str "leeks,",Space,Str "and",Space,Str "the",Space,Str "onions,",Space,Str "and",Space,Str "the",Space,Str "garlic.\8221"] +,Para [Str "The",Space,Str "thing",Space,Str "is",Space,Str "that,",Space,Str "indeed,",Space,Str "they",Space,Str "were",Space,Str "very",Space,Str "fond",Space,Str "of",Space,Str "the",Space,Str "work",Space,Str "in",Space,Str "Egypt.",Space,Str "This",Space,Str "is",Space,Str "the",Space,Str "meaning",Space,Str "of",Space,Str "\8220But",Space,Str "mingled",Space,Str "themselves",Space,Str "with",Space,Str "the",Space,Str "nations,",Space,Str "and",Space,Str "learned",Space,Str "their",Space,Str "works.\8221",Space,Str "It",Space,Str "means",Space,Str "that",Space,Str "if",Space,Str "Israel",Space,Str "are",Space,Str "under",Space,Str "the",Space,Str "dominion",Space,Str "of",Space,Str "a",Space,Str "certain",Space,Str "nation,",Space,Str "that",Space,Str "nation",Space,Str "controls",Space,Str "them",Space,Str "and",Space,Str "they",Space,Str "cannot",Space,Str "retire",Space,Str "from",Space,Str "their",Space,Str "dominion.",Space,Str "Thus,",Space,Str "they",Space,Str "tasted",Space,Str "sufficient",Space,Str "flavor",Space,Str "in",Space,Str "that",Space,Str "work",Space,Str "and",Space,Str "could",Space,Str "not",Space,Str "be",Space,Str "redeemed."] +,Para [Str "So",Space,Str "what",Space,Str "did",Space,Str "the",Space,Str "Creator",Space,Str "do?",Space,Str "\8220The",Space,Str "king",Space,Str "of",Space,Str "Egypt",Space,Str "died,\8221",Space,Str "meaning",Space,Str "they",Space,Str "had",Space,Str "lost",Space,Str "this",Space,Str "servitude.",Space,Str "Thus",Space,Str "they",Space,Str "could",Space,Str "no",Space,Str "longer",Space,Str "work;",Space,Str "they",Space,Str "understood",Space,Str "that",Space,Str "if",Space,Str "there",Space,Str "is",Space,Str "no",Space,Str "perfection",Space,Str "of",Space,Str "the",Space,Emph [Str "Mochin"],Str ",",Space,Str "the",Space,Str "servitude",Space,Str "is",Space,Str "also",Space,Str "incomplete.",Space,Str "Hence,",Space,Str "\8220and",Space,Str "the",Space,Str "children",Space,Str "of",Space,Str "Israel",Space,Str "sighed",Space,Str "by",Space,Str "reason",Space,Str "of",Space,Str "the",Space,Str "bondage.\8221",Space,Str "The",Space,Str "work",Space,Str "means",Space,Str "that",Space,Str "they",Space,Str "did",Space,Str "not",Space,Str "suffice",Space,Str "for",Space,Str "the",Space,Str "work,",Space,Str "that",Space,Str "they",Space,Str "had",Space,Str "no",Space,Str "liveliness",Space,Str "in",Space,Str "the",Space,Str "servitude."] +,Para [Str "This",Space,Str "is",Space,Str "the",Space,Str "meaning",Space,Str "of",Space,Str "\8220the",Space,Str "king",Space,Str "of",Space,Str "Egypt",Space,Str "died,\8221",Space,Str "that",Space,Str "all",Space,Str "the",Space,Str "dominations",Space,Str "of",Space,Str "the",Space,Str "king",Space,Str "of",Space,Str "Egypt,",Space,Str "which",Space,Str "he",Space,Str "was",Space,Str "providing",Space,Str "for",Space,Str "and",Space,Str "nourishing,",Space,Str "had",Space,Str "died.",Space,Str "This",Space,Str "is",Space,Str "why",Space,Str "they",Space,Str "had",Space,Str "room",Space,Str "for",Space,Str "prayer.",Space,Str "And",Space,Str "they",Space,Str "were",Space,Str "immediately",Space,Str "salvaged.",Space,Str "And",Space,Str "afterwards,",Space,Str "when",Space,Str "they",Space,Str "walked",Space,Str "in",Space,Str "the",Space,Str "desert",Space,Str "and",Space,Str "came",Space,Str "to",Space,Str "a",Space,Str "state",Space,Str "of",Space,Emph [Str "Katnut"],Space,Str "(smallness),",Space,Str "they",Space,Str "craved",Space,Str "the",Space,Str "servitude",Space,Str "that",Space,Str "they",Space,Str "had",Space,Str "had",Space,Str "prior",Space,Str "to",Space,Str "the",Space,Str "death",Space,Str "of",Space,Str "the",Space,Str "king",Space,Str "of",Space,Str "Egypt."]] -- cgit v1.2.3 From 7e99178a097ad824c60c72f8f289626dff04e0ff Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 5 Apr 2018 10:13:15 -0700 Subject: Changes to tests to accommodate changes in pandoc-types. In https://github.com/jgm/pandoc-types/pull/36 we changed the table builder to pad cells. This commit changes tests (and two readers) to accord with this behavior. --- src/Text/Pandoc/Readers/Docx.hs | 6 +++++- src/Text/Pandoc/Readers/HTML.hs | 6 ++++-- test/Tests/Writers/Muse.hs | 6 ++++-- test/docx/table_variable_width.native | 3 +++ 4 files changed, 16 insertions(+), 5 deletions(-) (limited to 'test/docx') diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index 00603603a..ca9f8c8dd 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -688,6 +688,10 @@ bodyPartToBlocks (Tbl cap _ look parts@(r:rs)) = do rowLength :: Row -> Int rowLength (Row c) = length c + -- pad cells. New Text.Pandoc.Builder will do that for us, + -- so this is for compatibility while we switch over. + let cells' = map (\row -> take width (row ++ repeat mempty)) cells + hdrCells <- case hdr of Just r' -> rowToBlocksList r' Nothing -> return $ replicate width mempty @@ -700,7 +704,7 @@ bodyPartToBlocks (Tbl cap _ look parts@(r:rs)) = do let alignments = replicate width AlignDefault widths = replicate width 0 :: [Double] - return $ table caption (zip alignments widths) hdrCells cells + return $ table caption (zip alignments widths) hdrCells cells' bodyPartToBlocks (OMathPara e) = return $ para $ displayMath (writeTeX e) diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index b221b6fb2..32a1ba5a6 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -510,14 +510,16 @@ pTable = try $ do [Plain _] -> True _ -> False let isSimple = all isSinglePlain $ concat (head':rows''') - let cols = length $ if null head' then head rows''' else head' + let cols = if null head' + then maximum (map length rows''') + else length head' -- add empty cells to short rows let addEmpties r = case cols - length r of n | n > 0 -> r <> replicate n mempty | otherwise -> r let rows = map addEmpties rows''' let aligns = case rows'' of - (cs:_) -> map fst cs + (cs:_) -> take cols $ map fst cs ++ repeat AlignDefault _ -> replicate cols AlignDefault let widths = if null widths' then if isSimple diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs index 115a00f83..96f506cd5 100644 --- a/test/Tests/Writers/Muse.hs +++ b/test/Tests/Writers/Muse.hs @@ -267,7 +267,8 @@ tests = [ testGroup "block elements" [ "table without header" =: let rows = [[para $ text "Para 1.1", para $ text "Para 1.2"] ,[para $ text "Para 2.1", para $ text "Para 2.2"]] - in simpleTable [] rows + in table mempty [(AlignDefault,0.0),(AlignDefault,0.0)] + [mempty, mempty] rows =?> unlines [ " Para 1.1 | Para 1.2" , " Para 2.1 | Para 2.2" @@ -287,7 +288,8 @@ tests = [ testGroup "block elements" headers = [plain $ text "header 1", plain $ text "header 2"] rows = [[para $ text "Para 1.1", para $ text "Para 1.2"] ,[para $ text "Para 2.1", para $ text "Para 2.2"]] - in table caption mempty headers rows + in table caption [(AlignDefault,0.0),(AlignDefault,0.0)] + headers rows =?> unlines [ " header 1 || header 2" , " Para 1.1 | Para 1.2" , " Para 2.1 | Para 2.2" diff --git a/test/docx/table_variable_width.native b/test/docx/table_variable_width.native index 9d3b961df..b85e58d41 100644 --- a/test/docx/table_variable_width.native +++ b/test/docx/table_variable_width.native @@ -5,9 +5,12 @@ ,[Plain [Str "h4"]] ,[Plain [Str "h5"]]] [[[Plain [Str "c11"]] + ,[] + ,[] ,[] ,[]] ,[[] ,[Plain [Str "c22"]] ,[Plain [Str "c23"]] + ,[] ,[]]]] -- cgit v1.2.3 From c5d8fab058ee5a9b069b17399a1ef93ce3ca8e0e Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Tue, 17 Apr 2018 09:29:54 -0400 Subject: Docx reader tests: Test for combining adjacent code blocks. --- test/Tests/Readers/Docx.hs | 4 ++++ test/docx/adjacent_codeblocks.docx | Bin 0 -> 22437 bytes test/docx/adjacent_codeblocks.native | 6 ++++++ 3 files changed, 10 insertions(+) create mode 100644 test/docx/adjacent_codeblocks.docx create mode 100644 test/docx/adjacent_codeblocks.native (limited to 'test/docx') diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs index 4f2ad524a..a02e1f35a 100644 --- a/test/Tests/Readers/Docx.hs +++ b/test/Tests/Readers/Docx.hs @@ -290,6 +290,10 @@ tests = [ testGroup "inlines" "code block" "docx/codeblock.docx" "docx/codeblock.native" + , testCompare + "combine adjacent code blocks" + "docx/adjacent_codeblocks.docx" + "docx/adjacent_codeblocks.native" , testCompare "dropcap paragraphs" "docx/drop_cap.docx" diff --git a/test/docx/adjacent_codeblocks.docx b/test/docx/adjacent_codeblocks.docx new file mode 100644 index 000000000..d61fb45d5 Binary files /dev/null and b/test/docx/adjacent_codeblocks.docx differ diff --git a/test/docx/adjacent_codeblocks.native b/test/docx/adjacent_codeblocks.native new file mode 100644 index 000000000..ec1e2416e --- /dev/null +++ b/test/docx/adjacent_codeblocks.native @@ -0,0 +1,6 @@ +[Para [Str "Next,",Space,Str "open",Space,Str "the",Space,Str "terminal",Space,Str "window.",Space,Str "Using",Space,Str "the",Space,Str "terminal",Space,Str "window,",Space,Str "run",Space,Str "the",Space,Str "\"ifconfig",Space,Str "-a\"",Space,Str "command",Space,Str "to",Space,Str "list",Space,Str "all",Space,Str "the",Space,Str "interfaces",Space,Str "on",Space,Str "your",Space,Str "system,",Space,Str "as",Space,Str "shown",Space,Str "here."] +,CodeBlock ("",[],[]) "# ifconfig -a\neth0 Link encap:Ethernet HWaddr 00:0c:29:69:12:7c \n inet addr:172.16.0.108 Bcast:172.16.0.255 Mask:255.255.255.0\n inet6 addr: fc00:660:0:1:20c:29ff:fe69:127c/64 Scope:Global\n inet6 addr: fe80::20c:29ff:fe69:127c/64 Scope:Link\n UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1\n RX packets:9859 errors:0 dropped:0 overruns:0 frame:0\n TX packets:1399 errors:0 dropped:0 overruns:0 carrier:0\n collisions:0 txqueuelen:1000 \n RX bytes:1920894 (1.8 MiB) TX bytes:233088 (227.6 KiB)\n Interrupt:19 Base address:0x2000 \n\nlo Link encap:Local Loopback \n inet addr:127.0.0.1 Mask:255.0.0.0\n inet6 addr: ::1/128 Scope:Host\n UP LOOPBACK RUNNING MTU:65536 Metric:1\n RX packets:372 errors:0 dropped:0 overruns:0 frame:0\n TX packets:372 errors:0 dropped:0 overruns:0 carrier:0\n collisions:0 txqueuelen:0 \n RX bytes:22320 (21.7 KiB) TX bytes:22320 (21.7 KiB)\n\nwlan0 Link encap:Ethernet HWaddr 00:c0:ca:85:00:ba \n UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1\n RX packets:0 errors:0 dropped:0 overruns:0 frame:0\n TX packets:0 errors:0 dropped:0 overruns:0 carrier:0\n collisions:0 txqueuelen:1000 \n RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)" +,Para [Str "The",Space,Str "ALFA",Space,Str "wireless",Space,Str "card",Space,Str "is",Space,Str "represented",Space,Str "by",Space,Str "the",Space,Str "\"wlan0\"",Space,Str "interface."] +,Para [Str "In",Space,Str "addition",Space,Str "to",Space,Str "the",Space,Str "interfaces",Space,Str "shown",Space,Str "in",Space,Str "the",Space,Str "ifconfig",Space,Str "output,",Space,Str "there",Space,Str "is",Space,Str "another",Space,Str "interface",Space,Str "known",Space,Str "as",Space,Str "the",Space,Emph [Str "wireless",Space,Str "physical",Space,Str "interface"],Str ".",Space,Str "We",Space,Str "can",Space,Str "identify",Space,Str "this",Space,Str "interface",Space,Str "by",Space,Str "listing",Space,Str "the",Space,Str "contents",Space,Str "of",Space,Str "the",Space,Str "/sys/class/ieee80211",Space,Str "directory,",Space,Str "as",Space,Str "shown."] +,CodeBlock ("",[],[]) "# ls /sys/class/ieee80211/\nphy0" +,Para [Str "The",Space,Str "\"phy0\"",Space,Str "interface",Space,Str "is",Space,Str "the",Space,Str "parent",Space,Str "interface",Space,Str "used",Space,Str "to",Space,Str "create",Space,Str "child",Space,Str "interfaces.",Space,Str "Note",Space,Str "that",Space,Str "if",Space,Str "you",Space,Str "unplug",Space,Str "and",Space,Str "replug",Space,Str "the",Space,Str "USB",Space,Str "interface,",Space,Str "the",Space,Str "\"phy\"",Space,Str "interface",Space,Str "number",Space,Str "will",Space,Str "increment",Space,Str "by",Space,Str "one",Space,Str "until",Space,Str "you",Space,Str "reboot",Space,Str "your",Space,Str "system."]] -- cgit v1.2.3 From 97916f0881465312bdb53793ba36df151710b47c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 25 Apr 2018 17:00:21 -0700 Subject: Remove nonfree ICC profiles from thumbnails in test docx files. Closes #4588. --- test/docx/block_quotes.docx | Bin 41855 -> 28138 bytes test/docx/char_styles.docx | Bin 30134 -> 18059 bytes test/docx/deep_normalize.docx | Bin 29246 -> 18131 bytes test/docx/drop_cap.docx | Bin 26931 -> 15671 bytes test/docx/hanging_indent.docx | Bin 29924 -> 14754 bytes test/docx/headers.docx | Bin 29659 -> 18926 bytes test/docx/inline_formatting.docx | Bin 32322 -> 20047 bytes test/docx/inline_images.docx | Bin 15875 -> 14305 bytes test/docx/link_in_notes.docx | Bin 27357 -> 16269 bytes test/docx/links.docx | Bin 45115 -> 32356 bytes test/docx/lists.docx | Bin 31775 -> 19845 bytes test/docx/metadata.docx | Bin 39538 -> 26077 bytes test/docx/metadata_after_normal.docx | Bin 56276 -> 38654 bytes test/docx/normalize.docx | Bin 25791 -> 14622 bytes test/docx/notes.docx | Bin 30734 -> 19056 bytes test/docx/numbered_header.docx | Bin 26129 -> 15467 bytes test/docx/table_with_list_cell.docx | Bin 32615 -> 19028 bytes test/docx/tables.docx | Bin 49780 -> 31751 bytes 18 files changed, 0 insertions(+), 0 deletions(-) (limited to 'test/docx') diff --git a/test/docx/block_quotes.docx b/test/docx/block_quotes.docx index 729ae1f43..aa2fef00e 100644 Binary files a/test/docx/block_quotes.docx and b/test/docx/block_quotes.docx differ diff --git a/test/docx/char_styles.docx b/test/docx/char_styles.docx index 05979b9a7..ef6106215 100644 Binary files a/test/docx/char_styles.docx and b/test/docx/char_styles.docx differ diff --git a/test/docx/deep_normalize.docx b/test/docx/deep_normalize.docx index 7626d59ce..4905ebe14 100644 Binary files a/test/docx/deep_normalize.docx and b/test/docx/deep_normalize.docx differ diff --git a/test/docx/drop_cap.docx b/test/docx/drop_cap.docx index 19fab4a52..2f14c2c1d 100644 Binary files a/test/docx/drop_cap.docx and b/test/docx/drop_cap.docx differ diff --git a/test/docx/hanging_indent.docx b/test/docx/hanging_indent.docx index 6f62dc731..62d41fdad 100644 Binary files a/test/docx/hanging_indent.docx and b/test/docx/hanging_indent.docx differ diff --git a/test/docx/headers.docx b/test/docx/headers.docx index e1fbbcc75..6c4701716 100644 Binary files a/test/docx/headers.docx and b/test/docx/headers.docx differ diff --git a/test/docx/inline_formatting.docx b/test/docx/inline_formatting.docx index eccf26425..49f383e73 100644 Binary files a/test/docx/inline_formatting.docx and b/test/docx/inline_formatting.docx differ diff --git a/test/docx/inline_images.docx b/test/docx/inline_images.docx index 2f01a251e..af433bb79 100644 Binary files a/test/docx/inline_images.docx and b/test/docx/inline_images.docx differ diff --git a/test/docx/link_in_notes.docx b/test/docx/link_in_notes.docx index f3398f438..b5e4e2bf6 100644 Binary files a/test/docx/link_in_notes.docx and b/test/docx/link_in_notes.docx differ diff --git a/test/docx/links.docx b/test/docx/links.docx index 80fecacaf..f23007f11 100644 Binary files a/test/docx/links.docx and b/test/docx/links.docx differ diff --git a/test/docx/lists.docx b/test/docx/lists.docx index bf7fd8ae4..8b46351d9 100644 Binary files a/test/docx/lists.docx and b/test/docx/lists.docx differ diff --git a/test/docx/metadata.docx b/test/docx/metadata.docx index ccf50b475..d5a4fb255 100644 Binary files a/test/docx/metadata.docx and b/test/docx/metadata.docx differ diff --git a/test/docx/metadata_after_normal.docx b/test/docx/metadata_after_normal.docx index b94a016cb..f43110e96 100644 Binary files a/test/docx/metadata_after_normal.docx and b/test/docx/metadata_after_normal.docx differ diff --git a/test/docx/normalize.docx b/test/docx/normalize.docx index b4fc55818..a20c5ddd1 100644 Binary files a/test/docx/normalize.docx and b/test/docx/normalize.docx differ diff --git a/test/docx/notes.docx b/test/docx/notes.docx index eb6fa12d4..e6a63342d 100644 Binary files a/test/docx/notes.docx and b/test/docx/notes.docx differ diff --git a/test/docx/numbered_header.docx b/test/docx/numbered_header.docx index 66ce7648d..b81caea69 100644 Binary files a/test/docx/numbered_header.docx and b/test/docx/numbered_header.docx differ diff --git a/test/docx/table_with_list_cell.docx b/test/docx/table_with_list_cell.docx index 1db065770..bf58c1abe 100644 Binary files a/test/docx/table_with_list_cell.docx and b/test/docx/table_with_list_cell.docx differ diff --git a/test/docx/tables.docx b/test/docx/tables.docx index 28087ead5..f99ea249d 100644 Binary files a/test/docx/tables.docx and b/test/docx/tables.docx differ -- cgit v1.2.3 From 40603dd4cd80f633239d1f48da3c3c834412b02e Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 8 May 2018 10:17:51 -0700 Subject: Support underline in docx writer. Updated golden test and confirmed validity of file. Closes #4633. --- src/Text/Pandoc/Writers/Docx.hs | 3 +++ test/docx/golden/inline_formatting.docx | Bin 9737 -> 9747 bytes 2 files changed, 3 insertions(+) (limited to 'test/docx') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 9b65e6ec7..1666c0562 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -1111,6 +1111,9 @@ inlineToOpenXML' _ (Str str) = formattedString str inlineToOpenXML' opts Space = inlineToOpenXML opts (Str " ") inlineToOpenXML' opts SoftBreak = inlineToOpenXML opts (Str " ") +inlineToOpenXML' opts (Span (_,["underline"],_) ils) = do + withTextProp (mknode "w:u" [("w:val","single")] ()) $ + inlinesToOpenXML opts ils inlineToOpenXML' _ (Span (ident,["comment-start"],kvs) ils) = do -- prefer the "id" in kvs, since that is the one produced by the docx -- reader. diff --git a/test/docx/golden/inline_formatting.docx b/test/docx/golden/inline_formatting.docx index 367654e53..9e07bd25d 100644 Binary files a/test/docx/golden/inline_formatting.docx and b/test/docx/golden/inline_formatting.docx differ -- cgit v1.2.3