diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-06-17 00:38:55 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-06-17 00:38:55 -0700 |
commit | fc291efad3430be0645e979e0279c93195012075 (patch) | |
tree | 4f2710267c09782f5232fe87261890f4b5297ec0 /src/Text | |
parent | 7d60c798bf12a93ca4d7f4d973c917ba0d5a96ff (diff) | |
download | pandoc-fc291efad3430be0645e979e0279c93195012075.tar.gz |
LaTeX reader: Correctly handle table rows with too few cells.
LaTeX seems to treat them as if they have empty cells at the
end. Closes #241.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 3c4d4ee52..97bfaa455 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1255,10 +1255,14 @@ parseTableRow :: Int -- ^ number of columns parseTableRow cols = try $ do let tableCellInline = notFollowedBy (amp <|> lbreak) >> inline let tableCell = (plain . trimInlines . mconcat) <$> many tableCellInline - cells' <- sepBy tableCell amp - guard $ length cells' == cols + cells' <- sepBy1 tableCell amp + let numcells = length cells' + guard $ numcells <= cols && numcells >= 1 + guard $ cells' /= [mempty] + -- note: a & b in a three-column table leaves an empty 3rd cell: + let cells'' = cells' ++ replicate (cols - numcells) mempty spaces - return cells' + return cells'' simpTable :: LP Blocks simpTable = try $ do |