diff options
author | despresc <christian.j.j.despres@gmail.com> | 2020-04-09 20:08:49 -0400 |
---|---|---|
committer | despresc <christian.j.j.despres@gmail.com> | 2020-04-15 23:03:22 -0400 |
commit | c7814f31e155da212bd3323294db08fe1f4d8ab9 (patch) | |
tree | 9b933ba5d6071bf7e8ca6a17af71cc2780174e7f /test/Tests/Readers/Org | |
parent | d368536a4ebfc542a58bd9bec6718590711c6efb (diff) | |
download | pandoc-c7814f31e155da212bd3323294db08fe1f4d8ab9.tar.gz |
Use the new builders, modify readers to preserve empty headers
The Builder.simpleTable now only adds a row to the TableHead when the
given header row is not null. This uncovered an inconsistency in the
readers: some would unconditionally emit a header filled with empty
cells, even if the header was not present. Now every reader has the
conditional behaviour. Only the XWiki writer depended on the header
row being always present; it now pads its head as necessary.
Diffstat (limited to 'test/Tests/Readers/Org')
-rw-r--r-- | test/Tests/Readers/Org/Block/Table.hs | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/test/Tests/Readers/Org/Block/Table.hs b/test/Tests/Readers/Org/Block/Table.hs index 4b76f4a58..d35d17979 100644 --- a/test/Tests/Readers/Org/Block/Table.hs +++ b/test/Tests/Readers/Org/Block/Table.hs @@ -24,7 +24,18 @@ simpleTable' :: Int -> [Blocks] -> [[Blocks]] -> Blocks -simpleTable' n = table "" (replicate n (AlignDefault, ColWidthDefault)) +simpleTable' n = simpleTable'' emptyCaption $ replicate n (AlignDefault, ColWidthDefault) + +simpleTable'' :: Caption -> [ColSpec] -> [Blocks] -> [[Blocks]] -> Blocks +simpleTable'' capt spec headers rows + = table capt + spec + (TableHead nullAttr $ toHeaderRow headers) + [TableBody nullAttr 0 [] $ map toRow rows] + (TableFoot nullAttr []) + where + toRow = Row nullAttr . map simpleCell + toHeaderRow l = if null l then [] else [toRow l] tests :: [TestTree] tests = @@ -121,14 +132,16 @@ tests = , "| 1 | One | foo |" , "| 2 | Two | bar |" ] =?> - table "" (zip - [AlignCenter, AlignRight, AlignDefault] - [ColWidthDefault, ColWidthDefault, ColWidthDefault]) - [] - [ [ plain "Numbers", plain "Text", plain "More" ] - , [ plain "1" , plain "One" , plain "foo" ] - , [ plain "2" , plain "Two" , plain "bar" ] - ] + simpleTable'' + emptyCaption + (zip + [AlignCenter, AlignRight, AlignDefault] + [ColWidthDefault, ColWidthDefault, ColWidthDefault]) + [] + [ [ plain "Numbers", plain "Text", plain "More" ] + , [ plain "1" , plain "One" , plain "foo" ] + , [ plain "2" , plain "Two" , plain "bar" ] + ] , "Pipe within text doesn't start a table" =: "Ceci n'est pas une | pipe " =?> @@ -145,23 +158,26 @@ tests = , "| 1 | One | foo |" , "| 2" ] =?> - table "" (zip [AlignCenter, AlignRight] [ColWidthDefault, ColWidthDefault]) - [ plain "Numbers", plain "Text" ] - [ [ plain "1" , plain "One" , plain "foo" ] - , [ plain "2" ] - ] + simpleTable'' + emptyCaption + (zip [AlignCenter, AlignRight] [ColWidthDefault, ColWidthDefault]) + [ plain "Numbers", plain "Text" ] + [ [ plain "1" , plain "One" , plain "foo" ] + , [ plain "2" ] + ] , "Table with caption" =: T.unlines [ "#+CAPTION: Hitchhiker's Multiplication Table" , "| x | 6 |" , "| 9 | 42 |" ] =?> - table "Hitchhiker's Multiplication Table" - [(AlignDefault, ColWidthDefault), (AlignDefault, ColWidthDefault)] - [] - [ [ plain "x", plain "6" ] - , [ plain "9", plain "42" ] - ] + simpleTable'' + (simpleCaption $ plain "Hitchhiker's Multiplication Table") + [(AlignDefault, ColWidthDefault), (AlignDefault, ColWidthDefault)] + [] + [ [ plain "x", plain "6" ] + , [ plain "9", plain "42" ] + ] , "named table" =: T.unlines [ "#+NAME: x-marks-the-spot" |