From f1f2728259ca0258a9870028a5c05b5973efdc20 Mon Sep 17 00:00:00 2001 From: Andy Morris Date: Fri, 30 Oct 2020 15:22:46 +0100 Subject: Fix duplicate "class" attribute in HTML writer --- src/Text/Pandoc/Writers/HTML.hs | 6 ++++-- test/tables/nordics.html4 | 12 ++++++------ test/tables/nordics.html5 | 12 ++++++------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index b6bde7f8f..bac720c66 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -1089,16 +1089,18 @@ tableRowToHtml :: PandocMonad m -> TableRow -> StateT WriterState m Html tableRowToHtml opts (TableRow tblpart attr rownum rowhead rowbody) = do - let rowclass = A.class_ $ case rownum of + let rowclass = case rownum of Ann.RowNumber x | x `rem` 2 == 1 -> "odd" _ | tblpart /= Thead -> "even" _ -> "header" + let attr' = case attr of + (id', classes, rest) -> (id', rowclass:classes, rest) let celltype = case tblpart of Thead -> HeaderCell _ -> BodyCell headcells <- mapM (cellToHtml opts HeaderCell) rowhead bodycells <- mapM (cellToHtml opts celltype) rowbody - rowHtml <- addAttrs opts attr $ H.tr ! rowclass $ do + rowHtml <- addAttrs opts attr' $ H.tr $ do nl opts mconcat headcells mconcat bodycells diff --git a/test/tables/nordics.html4 b/test/tables/nordics.html4 index a0d15e1bd..841ab03e5 100644 --- a/test/tables/nordics.html4 +++ b/test/tables/nordics.html4 @@ -17,38 +17,38 @@ - + Denmark Copenhagen 5,809,502 43,094 - + Finland Helsinki 5,537,364 338,145 - + Iceland Reykjavik 343,518 103,000 - + Norway Oslo 5,372,191 323,802 - + Sweden Stockholm 10,313,447 450,295 - + Total 27,376,022 diff --git a/test/tables/nordics.html5 b/test/tables/nordics.html5 index f52cf8e4c..0d639d4ea 100644 --- a/test/tables/nordics.html5 +++ b/test/tables/nordics.html5 @@ -17,38 +17,38 @@ - + Denmark Copenhagen 5,809,502 43,094 - + Finland Helsinki 5,537,364 338,145 - + Iceland Reykjavik 343,518 103,000 - + Norway Oslo 5,372,191 323,802 - + Sweden Stockholm 10,313,447 450,295 - + Total 27,376,022 -- cgit v1.2.3