git.iko.soy/typeable/pandoc
on master help sign in
Changes to tests to accommodate changes in pandoc-types.
7e99178John MacFarlane
src/Text/Pandoc/Readers/Docx.hs+5−1
@@ -688,6 +688,10 @@ bodyPartToBlocks (Tbl cap _ look parts@(r:rs)) = do
688 rowLength :: Row -> Int
688 rowLength :: Row -> Int
689 rowLength (Row c) = length c
689 rowLength (Row c) = length c
690
690
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+
691 hdrCells <- case hdr of
695 hdrCells <- case hdr of
692 Just r' -> rowToBlocksList r'
696 Just r' -> rowToBlocksList r'
693 Nothing -> return $ replicate width mempty
697 Nothing -> return $ replicate width mempty
@@ -700,7 +704,7 @@ bodyPartToBlocks (Tbl cap _ look parts@(r:rs)) = do
700 let alignments = replicate width AlignDefault
704 let alignments = replicate width AlignDefault
701 widths = replicate width 0 :: [Double]
705 widths = replicate width 0 :: [Double]
702
706
703− return $ table caption (zip alignments widths) hdrCells cells
707+ return $ table caption (zip alignments widths) hdrCells cells'
704bodyPartToBlocks (OMathPara e) =
708bodyPartToBlocks (OMathPara e) =
705 return $ para $ displayMath (writeTeX e)
709 return $ para $ displayMath (writeTeX e)
706
710
src/Text/Pandoc/Readers/HTML.hs+4−2
@@ -510,14 +510,16 @@ pTable = try $ do
510 [Plain _] -> True
510 [Plain _] -> True
511 _ -> False
511 _ -> False
512 let isSimple = all isSinglePlain $ concat (head':rows''')
512 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'
514 -- add empty cells to short rows
516 -- add empty cells to short rows
515 let addEmpties r = case cols - length r of
517 let addEmpties r = case cols - length r of
516 n | n > 0 -> r <> replicate n mempty
518 n | n > 0 -> r <> replicate n mempty
517 | otherwise -> r
519 | otherwise -> r
518 let rows = map addEmpties rows'''
520 let rows = map addEmpties rows'''
519 let aligns = case rows'' of
521 let aligns = case rows'' of
520− (cs:_) -> map fst cs
522+ (cs:_) -> take cols $ map fst cs ++ repeat AlignDefault
521 _ -> replicate cols AlignDefault
523 _ -> replicate cols AlignDefault
522 let widths = if null widths'
524 let widths = if null widths'
523 then if isSimple
525 then if isSimple
test/Tests/Writers/Muse.hs+4−2
@@ -267,7 +267,8 @@ tests = [ testGroup "block elements"
267 [ "table without header" =:
267 [ "table without header" =:
268 let rows = [[para $ text "Para 1.1", para $ text "Para 1.2"]
268 let rows = [[para $ text "Para 1.1", para $ text "Para 1.2"]
269 ,[para $ text "Para 2.1", para $ text "Para 2.2"]]
269 ,[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
271 =?>
272 =?>
272 unlines [ " Para 1.1 | Para 1.2"
273 unlines [ " Para 1.1 | Para 1.2"
273 , " Para 2.1 | Para 2.2"
274 , " Para 2.1 | Para 2.2"
@@ -287,7 +288,8 @@ tests = [ testGroup "block elements"
287 headers = [plain $ text "header 1", plain $ text "header 2"]
288 headers = [plain $ text "header 1", plain $ text "header 2"]
288 rows = [[para $ text "Para 1.1", para $ text "Para 1.2"]
289 rows = [[para $ text "Para 1.1", para $ text "Para 1.2"]
289 ,[para $ text "Para 2.1", para $ text "Para 2.2"]]
290 ,[para $ text "Para 2.1", para $ text "Para 2.2"]]
291+ in table caption [(AlignDefault,0.0),(AlignDefault,0.0)]
290− in table caption mempty headers rows
292+ headers rows
291 =?> unlines [ " header 1 || header 2"
293 =?> unlines [ " header 1 || header 2"
292 , " Para 1.1 | Para 1.2"
294 , " Para 1.1 | Para 1.2"
293 , " Para 2.1 | Para 2.2"
295 , " Para 2.1 | Para 2.2"
test/docx/table_variable_width.native+3
@@ -5,9 +5,12 @@
5 ,[Plain [Str "h4"]]
5 ,[Plain [Str "h4"]]
6 ,[Plain [Str "h5"]]]
6 ,[Plain [Str "h5"]]]
7 [[[Plain [Str "c11"]]
7 [[[Plain [Str "c11"]]
8+ ,[]
9+ ,[]
8 ,[]
10 ,[]
9 ,[]]
11 ,[]]
10 ,[[]
12 ,[[]
11 ,[Plain [Str "c22"]]
13 ,[Plain [Str "c22"]]
12 ,[Plain [Str "c23"]]
14 ,[Plain [Str "c23"]]
15+ ,[]
13 ,[]]]]
16 ,[]]]]