git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: Correctly handle table rows with too few cells.
fc291efJohn MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+7−3
@@ -1255,10 +1255,14 @@ parseTableRow :: Int -- ^ number of columns
1255parseTableRow cols = try $ do
1255parseTableRow cols = try $ do
1256 let tableCellInline = notFollowedBy (amp <|> lbreak) >> inline
1256 let tableCellInline = notFollowedBy (amp <|> lbreak) >> inline
1257 let tableCell = (plain . trimInlines . mconcat) <$> many tableCellInline
1257 let tableCell = (plain . trimInlines . mconcat) <$> many tableCellInline
1258− cells' <- sepBy tableCell amp
1258+ cells' <- sepBy1 tableCell amp
1259− guard $ length cells' == cols
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
1260 spaces
1264 spaces
1261− return cells'
1265+ return cells''
1262
1266
1263simpTable :: LP Blocks
1267simpTable :: LP Blocks
1264simpTable = try $ do
1268simpTable = try $ do