@@ -7,6 +7,7 @@ import Tests.Helpers
77import Tests.Arbitrary()
88import Text.Pandoc.Builder
99import Text.Pandoc
10+import Data.Monoid (mempty)
1011
1112latex :: String -> Pandoc
1213latex = readLaTeX def
@@ -16,6 +17,10 @@ infix 4 =:
1617 => String -> (String, c) -> Test
1718(=:) = test latex
1819
20+simpleTable' :: [Alignment] -> [[Blocks]] -> Blocks
21+simpleTable' aligns = table "" (zip aligns (repeat 0.0))
22+ (map (const mempty) aligns)
23+
1924tests :: [Test]
2025tests = [ testGroup "basic"
2126 [ "simple" =:
@@ -62,6 +67,40 @@ tests = [ testGroup "basic"
6267 "\\begin{lstlisting}\\end{lstlisting}" =?> codeBlock ""
6368 ]
6469
70+ , testGroup "tables"
71+ [ "Single cell table" =:
72+ "\\begin{tabular}{|l|}Test\\\\\\end{tabular}" =?>
73+ simpleTable' [AlignLeft] [[plain "Test"]]
74+ , "Multi cell table" =:
75+ "\\begin{tabular}{|rl|}One & Two\\\\ \\end{tabular}" =?>
76+ simpleTable' [AlignRight,AlignLeft] [[plain "One", plain "Two"]]
77+ , "Multi line table" =:
78+ unlines [ "\\begin{tabular}{|c|}"
79+ , "One\\\\"
80+ , "Two\\\\"
81+ , "Three\\\\"
82+ , "\\end{tabular}" ] =?>
83+ simpleTable' [AlignCenter]
84+ [[plain "One"], [plain "Two"], [plain "Three"]]
85+ , "Empty table" =:
86+ "\\begin{tabular}{}\\end{tabular}" =?>
87+ simpleTable' [] []
88+ , "Table with fixed column width" =:
89+ "\\begin{tabular}{|p{5cm}r|}One & Two\\\\ \\end{tabular}" =?>
90+ simpleTable' [AlignLeft,AlignRight] [[plain "One", plain "Two"]]
91+ , "Table with empty column separators" =:
92+ "\\begin{tabular}{@{}r@{}l}One & Two\\\\ \\end{tabular}" =?>
93+ simpleTable' [AlignRight,AlignLeft] [[plain "One", plain "Two"]]
94+ , "Table with custom column separators" =:
95+ unlines [ "\\begin{tabular}{@{($\\to$)}r@{\\hspace{2cm}}l}"
96+ , "One&Two\\\\"
97+ , "\\end{tabular}" ] =?>
98+ simpleTable' [AlignRight,AlignLeft] [[plain "One", plain "Two"]]
99+ , "Table with vertical alignment argument" =:
100+ "\\begin{tabular}[t]{r|r}One & Two\\\\ \\end{tabular}" =?>
101+ simpleTable' [AlignRight,AlignRight] [[plain "One", plain "Two"]]
102+ ]
103+
65104 , testGroup "citations"
66105 [ natbibCitations
67106 , biblatexCitations