diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2010-03-10 06:19:53 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2010-03-10 06:19:53 +0000 |
commit | 8382de28de003fd9474d94e04b645fdb9236db5b (patch) | |
tree | ee47dc40b61930e186df750ce42ad5d0df040c7b /src/Text/Pandoc/Writers/HTML.hs | |
parent | 0cf4652ad6cb59f5c10058f1dfc03cb2b2ab620d (diff) | |
download | pandoc-8382de28de003fd9474d94e04b645fdb9236db5b.tar.gz |
HTML writer: Use tbody, thead, and cols in tables.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1875 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc/Writers/HTML.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index b337572fe..2f58c7614 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -346,27 +346,32 @@ blockToHtml opts (Table capt aligns widths headers rows') = do captionDoc <- if null capt then return noHtml else inlineListToHtml opts capt >>= return . caption - let zeros = replicate (length headers) (0.0 :: Double) - let (rownums, rows'') = if all null headers - then ([1..], rows') - else ([0..], (headers : rows')) - body' <- mapM (tableRowToHtml opts alignStrings) $ - zip3 rownums (widths : repeat zeros) rows'' - return $ table $ captionDoc +++ body' + let percent w = show (truncate (100*w) :: Integer) ++ "%" + let coltags = if all (== 0.0) widths + then noHtml + else concatHtml $ map + (\w -> col ! [width $ percent w] $ noHtml) widths + head' <- if all null headers + then return noHtml + else liftM (thead <<) $ tableRowToHtml opts alignStrings 0 headers + body' <- liftM (tbody <<) $ + zipWithM (tableRowToHtml opts alignStrings) [1..] rows' + return $ table $ captionDoc +++ coltags +++ head' +++ body' tableRowToHtml :: WriterOptions -> [String] - -> (Int, [Double], [[Block]]) + -> Int + -> [[Block]] -> State WriterState Html -tableRowToHtml opts alignStrings (rownum, widths, cols') = do +tableRowToHtml opts alignStrings rownum cols' = do let mkcell = if rownum == 0 then th else td let rowclass = case rownum of 0 -> "header" x | x `rem` 2 == 1 -> "odd" _ -> "even" - cols'' <- sequence $ zipWith3 - (\alignment columnwidth item -> tableItemToHtml opts mkcell alignment columnwidth item) - alignStrings widths cols' + cols'' <- sequence $ zipWith + (\alignment item -> tableItemToHtml opts mkcell alignment item) + alignStrings cols' return $ tr ! [theclass rowclass] $ toHtmlFromList cols'' alignmentToString :: Alignment -> [Char] @@ -379,16 +384,11 @@ alignmentToString alignment = case alignment of tableItemToHtml :: WriterOptions -> (Html -> Html) -> [Char] - -> Double -> [Block] -> State WriterState Html -tableItemToHtml opts tag' align' width' item = do +tableItemToHtml opts tag' align' item = do contents <- blockListToHtml opts item - let attrib = [align align'] ++ - if width' /= 0 - then [thestyle ("width: " ++ (show (truncate (100 * width') :: Integer)) ++ "%;")] - else [] - return $ tag' ! attrib $ contents + return $ tag' ! [align align'] $ contents blockListToHtml :: WriterOptions -> [Block] -> State WriterState Html blockListToHtml opts lst = |