From 93a05dffd3d08bf2cb3a41e0523540c3c4bf5814 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 3 Feb 2016 13:31:21 -0800 Subject: HTML writer: don't include alignment attribute for default table columns. Previously these were given "left" alignment. Better to leave off alignment attributes altogether. Closes #2694. --- src/Text/Pandoc/Writers/HTML.hs | 7 +++++-- tests/tables.html | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 6e199583e..c5b6a6db2 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -645,7 +645,7 @@ alignmentToString alignment = case alignment of AlignLeft -> "left" AlignRight -> "right" AlignCenter -> "center" - AlignDefault -> "left" + AlignDefault -> "" tableItemToHtml :: WriterOptions -> (Html -> Html) @@ -658,7 +658,10 @@ tableItemToHtml opts tag' align' item = do let attribs = if writerHtml5 opts then A.style (toValue $ "text-align: " ++ alignStr ++ ";") else A.align (toValue alignStr) - return $ (tag' ! attribs $ contents) >> nl opts + let tag'' = if null alignStr + then tag' + else tag' ! attribs + return $ (tag'' $ contents) >> nl opts toListItems :: WriterOptions -> [Html] -> [Html] toListItems opts items = map (toListItem opts) items ++ [nl opts] diff --git a/tests/tables.html b/tests/tables.html index f5ddf3bcd..0a9ea413c 100644 --- a/tests/tables.html +++ b/tests/tables.html @@ -6,7 +6,7 @@ Right Left Center -Default +Default @@ -14,19 +14,19 @@ 12 12 12 -12 +12 123 123 123 -123 +123 1 1 1 -1 +1 @@ -37,7 +37,7 @@ Right Left Center -Default +Default @@ -45,19 +45,19 @@ 12 12 12 -12 +12 123 123 123 -123 +123 1 1 1 -1 +1 @@ -69,7 +69,7 @@ Right Left Center -Default +Default @@ -77,19 +77,19 @@ 12 12 12 -12 +12 123 123 123 -123 +123 1 1 1 -1 +1 @@ -192,13 +192,13 @@ First row 12.0 -Example of a row that spans multiple lines. +Example of a row that spans multiple lines. Second row 5.0 -Here's another one. Note the blank line between rows. +Here's another one. Note the blank line between rows. -- cgit v1.2.3