git.iko.soy/typeable/pandoc
on master help sign in
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.

commit12bf0ff3e528464cfc4173544bb9b4a0057c671e authorMathias Schenner <mathias.schenner@langsci-press.org> dateSun 8 Mar 2015, 15:47 (12 years ago) parent1e3ef0e
2 files changed+6−1
src/Text/Pandoc/Readers/LaTeX.hs+1−1 tests/Tests/Readers/LaTeX.hs+5
src/Text/Pandoc/Readers/LaTeX.hs+1−1
@@ -1275,7 +1275,7 @@ complexNatbibCitation mode = try $ do
12751275parseAligns :: LP [Alignment]
12761276parseAligns = try $ do
12771277 char '{'
1278− let maybeBar = skipMany $ sp <|> () <$ char '|' <|> () <$ try (string "@{}")
1278+ let maybeBar = skipMany $ sp <|> () <$ char '|' <|> () <$ (char '@' >> braced)
12791279 maybeBar
12801280 let cAlign = AlignCenter <$ char 'c'
12811281 let lAlign = AlignLeft <$ char 'l'
tests/Tests/Readers/LaTeX.hs+5
@@ -91,6 +91,11 @@ tests = [ testGroup "basic"
9191 , "Table with empty column separators" =:
9292 "\\begin{tabular}{@{}r@{}l}One & Two\\\\ \\end{tabular}" =?>
9393 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"]]
9499 , "Table with vertical alignment argument" =:
95100 "\\begin{tabular}[t]{r|r}One & Two\\\\ \\end{tabular}" =?>
96101 simpleTable' [AlignRight,AlignRight] [[plain "One", plain "Two"]]