From 1e3ef0e36f8576bf87115ece66675b56651c7a28 Mon Sep 17 00:00:00 2001 From: Mathias Schenner Date: Sun, 8 Mar 2015 15:30:05 +0100 Subject: LaTeX reader: allow valign argument in tables The `tabular` environment takes an optional parameter for vertical alignment. Previously, pandoc would fail to parse tables if this parameter was present. With this commit, the parameter is still ignored, but the table gets parsed. A test case is included. --- src/Text/Pandoc/Readers/LaTeX.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index a071578fe..8689fde45 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1314,7 +1314,7 @@ parseTableRow cols = try $ do simpTable :: Bool -> LP Blocks simpTable hasWidthParameter = try $ do when hasWidthParameter $ () <$ (spaces >> tok) - spaces + skipopts aligns <- parseAligns let cols = length aligns optional hline -- cgit v1.2.3 From 12bf0ff3e528464cfc4173544bb9b4a0057c671e Mon Sep 17 00:00:00 2001 From: Mathias Schenner Date: Sun, 8 Mar 2015 15:47:39 +0100 Subject: LaTeX reader: allow non-empty colsep in tables The `tabular` environment allows non-empty column separators with the "@{...}" syntax. Previously, pandoc would fail to parse tables if a non-empty colsep was present. With this commit, these separators are still ignored, but the table gets parsed. A test case is included. --- src/Text/Pandoc/Readers/LaTeX.hs | 2 +- tests/Tests/Readers/LaTeX.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 8689fde45..1df2d4caf 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1275,7 +1275,7 @@ complexNatbibCitation mode = try $ do parseAligns :: LP [Alignment] parseAligns = try $ do char '{' - let maybeBar = skipMany $ sp <|> () <$ char '|' <|> () <$ try (string "@{}") + let maybeBar = skipMany $ sp <|> () <$ char '|' <|> () <$ (char '@' >> braced) maybeBar let cAlign = AlignCenter <$ char 'c' let lAlign = AlignLeft <$ char 'l' diff --git a/tests/Tests/Readers/LaTeX.hs b/tests/Tests/Readers/LaTeX.hs index 614075652..47916b0c0 100644 --- a/tests/Tests/Readers/LaTeX.hs +++ b/tests/Tests/Readers/LaTeX.hs @@ -91,6 +91,11 @@ tests = [ testGroup "basic" , "Table with empty column separators" =: "\\begin{tabular}{@{}r@{}l}One & Two\\\\ \\end{tabular}" =?> simpleTable' [AlignRight,AlignLeft] [[plain "One", plain "Two"]] + , "Table with custom column separators" =: + unlines [ "\\begin{tabular}{@{($\\to$)}r@{\\hspace{2cm}}l}" + , "One&Two\\\\" + , "\\end{tabular}" ] =?> + simpleTable' [AlignRight,AlignLeft] [[plain "One", plain "Two"]] , "Table with vertical alignment argument" =: "\\begin{tabular}[t]{r|r}One & Two\\\\ \\end{tabular}" =?> simpleTable' [AlignRight,AlignRight] [[plain "One", plain "Two"]] -- cgit v1.2.3