@@ -238,30 +238,26 @@ pTable = try $ do
238 caption <- option mempty $ pInTags "caption" inline >>~ skipMany pBlank
238 caption <- option mempty $ pInTags "caption" inline >>~ skipMany pBlank
239 -- TODO actually read these and take width information from them
239 -- TODO actually read these and take width information from them
240 widths' <- pColgroup <|> many pCol
240 widths' <- pColgroup <|> many pCol
241− head' <- option mempty $ pOptInTag "thead" $ pInTags "tr" (pCell "th")
241+ head' <- option [] $ pOptInTag "thead" $ pInTags "tr" (pCell "th")
242 skipMany pBlank
242 skipMany pBlank
243 rows <- pOptInTag "tbody"
243 rows <- pOptInTag "tbody"
244 $ many1 $ try $ skipMany pBlank >> pInTags "tr" (pCell "td")
244 $ many1 $ try $ skipMany pBlank >> pInTags "tr" (pCell "td")
245 skipMany pBlank
245 skipMany pBlank
246 TagClose _ <- pSatisfy (~== TagClose "table")
246 TagClose _ <- pSatisfy (~== TagClose "table")
247− let isSinglePlain [] = True
247+ let isSinglePlain x = case B.toList x of
248− isSinglePlain [Plain _] = True
248+ [Plain _] -> True
249− isSinglePlain _ = False
249+ _ -> False
250− let lHead = B.toList head'
251− let lRows = map B.toList rows
252− let isSimple = all isSinglePlain (lHead:lRows)
250+ let isSimple = all isSinglePlain $ concat (head':rows)
253− let cols = length $ if null lHead
251+ let cols = length $ if null head' then head rows else head'
256 -- fail if there are colspans or rowspans
252 -- fail if there are colspans or rowspans
257− guard $ all (\r -> length r == cols) lRows
253+ guard $ all (\r -> length r == cols) rows
258− let aligns = replicate cols AlignLeft
254+ let aligns = replicate cols AlignDefault
259 let widths = if null widths'
255 let widths = if null widths'
260 then if isSimple
256 then if isSimple
261 then replicate cols 0
257 then replicate cols 0
262 else replicate cols (1.0 / fromIntegral cols)
258 else replicate cols (1.0 / fromIntegral cols)
263 else widths'
259 else widths'
264− return $ B.table caption (zip aligns widths) [head'] [rows]
260+ return $ B.table caption (zip aligns widths) head' rows
266pCol :: TagParser Double
262pCol :: TagParser Double
267pCol = try $ do
263pCol = try $ do
@@ -279,12 +275,12 @@ pColgroup = try $ do
279 skipMany pBlank
275 skipMany pBlank
280 manyTill pCol (pCloses "colgroup" <|> eof) <* skipMany pBlank
276 manyTill pCol (pCloses "colgroup" <|> eof) <* skipMany pBlank
282−pCell :: String -> TagParser Blocks
278+pCell :: String -> TagParser [Blocks]
283pCell celltype = try $ do
279pCell celltype = try $ do
284 skipMany pBlank
280 skipMany pBlank
285 res <- pInTags celltype block
281 res <- pInTags celltype block
286 skipMany pBlank
282 skipMany pBlank
287− return res
283+ return [res]
289pBlockQuote :: TagParser Blocks
285pBlockQuote :: TagParser Blocks
290pBlockQuote = do
286pBlockQuote = do