aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLaurent P. René de Cotret <LaurentRDC@users.noreply.github.com>2020-07-23 14:23:21 -0400
committerGitHub <noreply@github.com>2020-07-23 11:23:21 -0700
commit8c3b5dd3ae10dade9f8a52fcba456f1cd8d085c9 (patch)
tree9415bfd1c813c9ec8b50a605a7e21d427fed025c /test
parenta0e3172a0bb9f0cb69ede824086ea4655a71eff2 (diff)
downloadpandoc-8c3b5dd3ae10dade9f8a52fcba456f1cd8d085c9.tar.gz
Col-span and row-span in LaTeX reader (#6470)
Add multirow and multicolumn support in LaTex reader. Partially addresses #6311.
Diffstat (limited to 'test')
-rw-r--r--test/Tests/Readers/LaTeX.hs58
1 files changed, 55 insertions, 3 deletions
diff --git a/test/Tests/Readers/LaTeX.hs b/test/Tests/Readers/LaTeX.hs
index 821747f26..74906fab4 100644
--- a/test/Tests/Readers/LaTeX.hs
+++ b/test/Tests/Readers/LaTeX.hs
@@ -35,13 +35,17 @@ infix 4 =:
=> String -> (Text, c) -> TestTree
(=:) = test latex
-simpleTable' :: [Alignment] -> [[Blocks]] -> Blocks
-simpleTable' aligns rows
+table' :: [Alignment] -> [Row] -> Blocks
+table' aligns rows
= table emptyCaption
(zip aligns (repeat ColWidthDefault))
(TableHead nullAttr [])
- [TableBody nullAttr 0 [] $ map toRow rows]
+ [TableBody nullAttr 0 [] rows]
(TableFoot nullAttr [])
+
+simpleTable' :: [Alignment] -> [[Blocks]] -> Blocks
+simpleTable' aligns rows
+ = table' aligns (map toRow rows)
where
toRow = Row nullAttr . map simpleCell
@@ -137,6 +141,54 @@ tests = [ testGroup "tokenization"
, "Table with vertical alignment argument" =:
"\\begin{tabular}[t]{r|r}One & Two\\\\ \\end{tabular}" =?>
simpleTable' [AlignRight,AlignRight] [[plain "One", plain "Two"]]
+ , "Table with multicolumn item" =:
+ "\\begin{tabular}{l c r}\\multicolumn{2}{c}{One} & Two\\\\ \\end{tabular}" =?>
+ table' [AlignLeft, AlignCenter, AlignRight]
+ [ Row nullAttr [ cell AlignCenter (RowSpan 1) (ColSpan 2) (plain "One")
+ , simpleCell (plain "Two")
+ ]
+ ]
+ , "Table with multirow item" =:
+ T.unlines ["\\begin{tabular}{c}"
+ ,"\\multirow{2}{c}{One}\\\\Two\\\\"
+ ,"\\end{tabular}"
+ ] =?>
+ table' [AlignCenter]
+ [ Row nullAttr [ cell AlignCenter (RowSpan 2) (ColSpan 1) (plain "One") ]
+ , Row nullAttr [ simpleCell (plain "Two") ]
+ ]
+ , "Table with nested multirow/multicolumn item" =:
+ T.unlines [ "\\begin{tabular}{c c c}"
+ , "\\multirow{2}{c}{\\multicolumn{2}{c}{One}}&Two\\\\"
+ , "Three\\\\"
+ , "Four&Five&Six\\\\"
+ , "\\end{tabular}"
+ ] =?>
+ table' [AlignCenter, AlignCenter, AlignCenter]
+ [ Row nullAttr [ cell AlignCenter (RowSpan 2) (ColSpan 2) (plain "One")
+ , simpleCell (plain "Two")
+ ]
+ , Row nullAttr [ simpleCell (plain "Three") ]
+ , Row nullAttr [ simpleCell (plain "Four")
+ , simpleCell (plain "Five")
+ , simpleCell (plain "Six")
+ ]
+ ]
+ , "Table with multicolumn header" =:
+ T.unlines [ "\\begin{tabular}{ |l|l| }"
+ , "\\hline\\multicolumn{2}{|c|}{Header}\\\\"
+ , "\\hline key & val\\\\"
+ , "\\hline\\end{tabular}"
+ ] =?>
+ table emptyCaption
+ (zip [AlignLeft, AlignLeft] (repeat ColWidthDefault))
+ (TableHead nullAttr [ Row nullAttr [cell AlignCenter (RowSpan 1) (ColSpan 2) (plain "Header")]])
+ [TableBody nullAttr 0 [] [Row nullAttr [ simpleCell (plain "key")
+ , simpleCell (plain "val")
+ ]
+ ]
+ ]
+ (TableFoot nullAttr [])
]
, testGroup "citations"