@@ -238,30 +238,26 @@ pTable = try $ do
238238 caption <- option mempty $ pInTags "caption" inline >>~ skipMany pBlank
239239 -- TODO actually read these and take width information from them
240240 widths' <- pColgroup <|> many pCol
241− head' <- option mempty $ pOptInTag "thead" $ pInTags "tr" (pCell "th")
241+ head' <- option [] $ pOptInTag "thead" $ pInTags "tr" (pCell "th")
242242 skipMany pBlank
243243 rows <- pOptInTag "tbody"
244244 $ many1 $ try $ skipMany pBlank >> pInTags "tr" (pCell "td")
245245 skipMany pBlank
246246 TagClose _ <- pSatisfy (~== TagClose "table")
247− let isSinglePlain [] = True
248− isSinglePlain [Plain _] = True
249− isSinglePlain _ = False
250− let lHead = B.toList head'
251− let lRows = map B.toList rows
252− let isSimple = all isSinglePlain (lHead:lRows)
253− let cols = length $ if null lHead
254− then head lRows
255− else lHead
247+ let isSinglePlain x = case B.toList x of
248+ [Plain _] -> True
249+ _ -> False
250+ let isSimple = all isSinglePlain $ concat (head':rows)
251+ let cols = length $ if null head' then head rows else head'
256252 -- fail if there are colspans or rowspans
257− guard $ all (\r -> length r == cols) lRows
258− let aligns = replicate cols AlignLeft
253+ guard $ all (\r -> length r == cols) rows
254+ let aligns = replicate cols AlignDefault
259255 let widths = if null widths'
260256 then if isSimple
261257 then replicate cols 0
262258 else replicate cols (1.0 / fromIntegral cols)
263259 else widths'
264− return $ B.table caption (zip aligns widths) [head'] [rows]
260+ return $ B.table caption (zip aligns widths) head' rows
265261
266262pCol :: TagParser Double
267263pCol = try $ do
@@ -279,12 +275,12 @@ pColgroup = try $ do
279275 skipMany pBlank
280276 manyTill pCol (pCloses "colgroup" <|> eof) <* skipMany pBlank
281277
282−pCell :: String -> TagParser Blocks
278+pCell :: String -> TagParser [Blocks]
283279pCell celltype = try $ do
284280 skipMany pBlank
285281 res <- pInTags celltype block
286282 skipMany pBlank
287− return res
283+ return [res]
288284
289285pBlockQuote :: TagParser Blocks
290286pBlockQuote = do