From 5b422262d3889c6b303b7942505ac164bd245546 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sat, 18 Oct 2008 23:14:59 +0000 Subject: Include classes on tr elements in HTML output: "header", "odd", "even". This allows tables to be styled with lines in alternating colors. Resolves Issue #91. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1467 788f1e2b-df1e-0410-8736-df70ead52e1b --- Text/Pandoc/Writers/HTML.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Text/Pandoc/Writers') diff --git a/Text/Pandoc/Writers/HTML.hs b/Text/Pandoc/Writers/HTML.hs index 0870c7e18..628e784ed 100644 --- a/Text/Pandoc/Writers/HTML.hs +++ b/Text/Pandoc/Writers/HTML.hs @@ -375,7 +375,7 @@ blockToHtml opts (Table capt aligns widths headers rows') = do else inlineListToHtml opts capt >>= return . caption colHeads <- colHeadsToHtml opts alignStrings widths headers - rows'' <- mapM (tableRowToHtml opts alignStrings) rows' + rows'' <- zipWithM (tableRowToHtml opts alignStrings) (cycle ["odd", "even"]) rows' return $ table $ captionDoc +++ colHeads +++ rows'' colHeadsToHtml :: WriterOptions @@ -387,7 +387,7 @@ colHeadsToHtml opts alignStrings widths headers = do heads <- sequence $ zipWith3 (\alignment columnwidth item -> tableItemToHtml opts th alignment columnwidth item) alignStrings widths headers - return $ tr $ toHtmlFromList heads + return $ tr ! [theclass "header"] $ toHtmlFromList heads alignmentToString :: Alignment -> [Char] alignmentToString alignment = case alignment of @@ -398,11 +398,12 @@ alignmentToString alignment = case alignment of tableRowToHtml :: WriterOptions -> [[Char]] + -> String -> [[Block]] -> State WriterState Html -tableRowToHtml opts aligns columns = +tableRowToHtml opts aligns rowclass columns = (sequence $ zipWith3 (tableItemToHtml opts td) aligns (repeat 0) columns) >>= - return . tr . toHtmlFromList + return . (tr ! [theclass rowclass]) . toHtmlFromList tableItemToHtml :: WriterOptions -> (Html -> Html) -- cgit v1.2.3