@@ -346,27 +346,32 @@ blockToHtml opts (Table capt aligns widths headers rows') = do
346346 captionDoc <- if null capt
347347 then return noHtml
348348 else inlineListToHtml opts capt >>= return . caption
349− let zeros = replicate (length headers) (0.0 :: Double)
350− let (rownums, rows'') = if all null headers
351− then ([1..], rows')
352− else ([0..], (headers : rows'))
353− body' <- mapM (tableRowToHtml opts alignStrings) $
354− zip3 rownums (widths : repeat zeros) rows''
355− return $ table $ captionDoc +++ body'
349+ let percent w = show (truncate (100*w) :: Integer) ++ "%"
350+ let coltags = if all (== 0.0) widths
351+ then noHtml
352+ else concatHtml $ map
353+ (\w -> col ! [width $ percent w] $ noHtml) widths
354+ head' <- if all null headers
355+ then return noHtml
356+ else liftM (thead <<) $ tableRowToHtml opts alignStrings 0 headers
357+ body' <- liftM (tbody <<) $
358+ zipWithM (tableRowToHtml opts alignStrings) [1..] rows'
359+ return $ table $ captionDoc +++ coltags +++ head' +++ body'
356360
357361tableRowToHtml :: WriterOptions
358362 -> [String]
359− -> (Int, [Double], [[Block]])
363+ -> Int
364+ -> [[Block]]
360365 -> State WriterState Html
361−tableRowToHtml opts alignStrings (rownum, widths, cols') = do
366+tableRowToHtml opts alignStrings rownum cols' = do
362367 let mkcell = if rownum == 0 then th else td
363368 let rowclass = case rownum of
364369 0 -> "header"
365370 x | x `rem` 2 == 1 -> "odd"
366371 _ -> "even"
367− cols'' <- sequence $ zipWith3
368− (\alignment columnwidth item -> tableItemToHtml opts mkcell alignment columnwidth item)
369− alignStrings widths cols'
372+ cols'' <- sequence $ zipWith
373+ (\alignment item -> tableItemToHtml opts mkcell alignment item)
374+ alignStrings cols'
370375 return $ tr ! [theclass rowclass] $ toHtmlFromList cols''
371376
372377alignmentToString :: Alignment -> [Char]
@@ -379,16 +384,11 @@ alignmentToString alignment = case alignment of
379384tableItemToHtml :: WriterOptions
380385 -> (Html -> Html)
381386 -> [Char]
382− -> Double
383387 -> [Block]
384388 -> State WriterState Html
385−tableItemToHtml opts tag' align' width' item = do
389+tableItemToHtml opts tag' align' item = do
386390 contents <- blockListToHtml opts item
387− let attrib = [align align'] ++
388− if width' /= 0
389− then [thestyle ("width: " ++ (show (truncate (100 * width') :: Integer)) ++ "%;")]
390− else []
391− return $ tag' ! attrib $ contents
391+ return $ tag' ! [align align'] $ contents
392392
393393blockListToHtml :: WriterOptions -> [Block] -> State WriterState Html
394394blockListToHtml opts lst =