git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: add some test cases for simple tables
4f9a106Mathias Schenner
tests/Tests/Readers/LaTeX.hs+31
@@ -7,6 +7,7 @@ import Tests.Helpers
7import Tests.Arbitrary()
7import Tests.Arbitrary()
8import Text.Pandoc.Builder
8import Text.Pandoc.Builder
9import Text.Pandoc
9import Text.Pandoc
10+import Data.Monoid (mempty)
10
11
11latex :: String -> Pandoc
12latex :: String -> Pandoc
12latex = readLaTeX def
13latex = readLaTeX def
@@ -16,6 +17,10 @@ infix 4 =:
16 => String -> (String, c) -> Test
17 => String -> (String, c) -> Test
17(=:) = test latex
18(=:) = test latex
18
19
20+simpleTable' :: [Alignment] -> [[Blocks]] -> Blocks
21+simpleTable' aligns = table "" (zip aligns (repeat 0.0))
22+ (map (const mempty) aligns)
23+
19tests :: [Test]
24tests :: [Test]
20tests = [ testGroup "basic"
25tests = [ testGroup "basic"
21 [ "simple" =:
26 [ "simple" =:
@@ -62,6 +67,32 @@ tests = [ testGroup "basic"
62 "\\begin{lstlisting}\\end{lstlisting}" =?> codeBlock ""
67 "\\begin{lstlisting}\\end{lstlisting}" =?> codeBlock ""
63 ]
68 ]
64
69
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+ ]
95+
65 , testGroup "citations"
96 , testGroup "citations"
66 [ natbibCitations
97 [ natbibCitations
67 , biblatexCitations
98 , biblatexCitations