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.
This commit is contained in:
John MacFarlane 2018-04-05 10:13:15 -07:00
parent 26fdd40370
commit 7e99178a09
4 changed files with 16 additions and 5 deletions

View file

@ -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)

View file

@ -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

View file

@ -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"

View file

@ -5,9 +5,12 @@
,[Plain [Str "h4"]]
,[Plain [Str "h5"]]]
[[[Plain [Str "c11"]]
,[]
,[]
,[]
,[]]
,[[]
,[Plain [Str "c22"]]
,[Plain [Str "c23"]]
,[]
,[]]]]