From 871164051281b50a5b4b28cacee3dd15344d81f1 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Sun, 13 Sep 2020 20:23:55 +0200 Subject: HTML writer: support attributes on all table elements Add attributes to tbody and tr elements. --- src/Text/Pandoc/Writers/HTML.hs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index decc487c1..9e6e22283 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -948,8 +948,8 @@ tableBodyToHtml :: PandocMonad m => WriterOptions -> Ann.TableBody -> StateT WriterState m Html -tableBodyToHtml opts (Ann.TableBody _attr _rowHeadCols _intm rows) = - H.tbody <$> bodyRowsToHtml opts rows +tableBodyToHtml opts (Ann.TableBody attr _rowHeadCols _intm rows) = + addAttrs opts attr . H.tbody =<< bodyRowsToHtml opts rows tableHeadToHtml :: PandocMonad m => WriterOptions @@ -1060,7 +1060,7 @@ tableRowToHtml :: PandocMonad m => WriterOptions -> TableRow -> StateT WriterState m Html -tableRowToHtml opts (TableRow tblpart _attr rownum rowhead rowbody) = do +tableRowToHtml opts (TableRow tblpart attr rownum rowhead rowbody) = do let rowclass = A.class_ $ case rownum of Ann.RowNumber x | x `rem` 2 == 1 -> "odd" _ | tblpart /= Thead -> "even" @@ -1068,10 +1068,14 @@ tableRowToHtml opts (TableRow tblpart _attr rownum rowhead rowbody) = do let celltype = case tblpart of Thead -> HeaderCell _ -> BodyCell - head' <- mapM (cellToHtml opts HeaderCell) rowhead - body <- mapM (cellToHtml opts celltype) rowbody + headcells <- mapM (cellToHtml opts HeaderCell) rowhead + bodycells <- mapM (cellToHtml opts celltype) rowbody + rowHtml <- addAttrs opts attr $ H.tr ! rowclass $ do + nl opts + mconcat headcells + mconcat bodycells return $ do - H.tr ! rowclass $ nl opts *> mconcat (head' <> body) + rowHtml nl opts alignmentToString :: Alignment -> Maybe Text -- cgit v1.2.3