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

commitfc291efad3430be0645e979e0279c93195012075 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 17 Jun 2014, 00:38 (12 years ago) parent7d60c79
1 file changed+7−3
src/Text/Pandoc/Readers/LaTeX.hs+7−3
src/Text/Pandoc/Readers/LaTeX.hs+7−3
@@ -1255,10 +1255,14 @@ parseTableRow :: Int -- ^ number of columns
12551255parseTableRow cols = try $ do
12561256 let tableCellInline = notFollowedBy (amp <|> lbreak) >> inline
12571257 let tableCell = (plain . trimInlines . mconcat) <$> many tableCellInline
1258− cells' <- sepBy tableCell amp
1259− guard $ length cells' == cols
1258+ cells' <- sepBy1 tableCell amp
1259+ let numcells = length cells'
1260+ guard $ numcells <= cols && numcells >= 1
1261+ guard $ cells' /= [mempty]
1262+ -- note: a & b in a three-column table leaves an empty 3rd cell:
1263+ let cells'' = cells' ++ replicate (cols - numcells) mempty
12601264 spaces
1261− return cells'
1265+ return cells''
12621266
12631267simpTable :: LP Blocks
12641268simpTable = try $ do