git.iko.soy/typeable/pandoc
on master help sign in
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.

commit7e99178a097ad824c60c72f8f289626dff04e0ff authorJohn MacFarlane <jgm@berkeley.edu> dateThu 5 Apr 2018, 10:13 (9 years ago) parent26fdd40
4 files changed+16−5
src/Text/Pandoc/Readers/Docx.hs+5−1 src/Text/Pandoc/Readers/HTML.hs+4−2 test/Tests/Writers/Muse.hs+4−2 test/docx/table_variable_width.native+3
src/Text/Pandoc/Readers/Docx.hs+5−1
@@ -688,6 +688,10 @@ bodyPartToBlocks (Tbl cap _ look parts@(r:rs)) = do
688688 rowLength :: Row -> Int
689689 rowLength (Row c) = length c
690690
691+ -- pad cells. New Text.Pandoc.Builder will do that for us,
692+ -- so this is for compatibility while we switch over.
693+ let cells' = map (\row -> take width (row ++ repeat mempty)) cells
694+
691695 hdrCells <- case hdr of
692696 Just r' -> rowToBlocksList r'
693697 Nothing -> return $ replicate width mempty
@@ -700,7 +704,7 @@ bodyPartToBlocks (Tbl cap _ look parts@(r:rs)) = do
700704 let alignments = replicate width AlignDefault
701705 widths = replicate width 0 :: [Double]
702706
703− return $ table caption (zip alignments widths) hdrCells cells
707+ return $ table caption (zip alignments widths) hdrCells cells'
704708bodyPartToBlocks (OMathPara e) =
705709 return $ para $ displayMath (writeTeX e)
706710
src/Text/Pandoc/Readers/HTML.hs+4−2
@@ -510,14 +510,16 @@ pTable = try $ do
510510 [Plain _] -> True
511511 _ -> False
512512 let isSimple = all isSinglePlain $ concat (head':rows''')
513− let cols = length $ if null head' then head rows''' else head'
513+ let cols = if null head'
514+ then maximum (map length rows''')
515+ else length head'
514516 -- add empty cells to short rows
515517 let addEmpties r = case cols - length r of
516518 n | n > 0 -> r <> replicate n mempty
517519 | otherwise -> r
518520 let rows = map addEmpties rows'''
519521 let aligns = case rows'' of
520− (cs:_) -> map fst cs
522+ (cs:_) -> take cols $ map fst cs ++ repeat AlignDefault
521523 _ -> replicate cols AlignDefault
522524 let widths = if null widths'
523525 then if isSimple
test/Tests/Writers/Muse.hs+4−2
@@ -267,7 +267,8 @@ tests = [ testGroup "block elements"
267267 [ "table without header" =:
268268 let rows = [[para $ text "Para 1.1", para $ text "Para 1.2"]
269269 ,[para $ text "Para 2.1", para $ text "Para 2.2"]]
270− in simpleTable [] rows
270+ in table mempty [(AlignDefault,0.0),(AlignDefault,0.0)]
271+ [mempty, mempty] rows
271272 =?>
272273 unlines [ " Para 1.1 | Para 1.2"
273274 , " Para 2.1 | Para 2.2"
@@ -287,7 +288,8 @@ tests = [ testGroup "block elements"
287288 headers = [plain $ text "header 1", plain $ text "header 2"]
288289 rows = [[para $ text "Para 1.1", para $ text "Para 1.2"]
289290 ,[para $ text "Para 2.1", para $ text "Para 2.2"]]
290− in table caption mempty headers rows
291+ in table caption [(AlignDefault,0.0),(AlignDefault,0.0)]
292+ headers rows
291293 =?> unlines [ " header 1 || header 2"
292294 , " Para 1.1 | Para 1.2"
293295 , " Para 2.1 | Para 2.2"
test/docx/table_variable_width.native+3
@@ -5,9 +5,12 @@
55 ,[Plain [Str "h4"]]
66 ,[Plain [Str "h5"]]]
77 [[[Plain [Str "c11"]]
8+ ,[]
9+ ,[]
810 ,[]
911 ,[]]
1012 ,[[]
1113 ,[Plain [Str "c22"]]
1214 ,[Plain [Str "c23"]]
15+ ,[]
1316 ,[]]]]