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.
This commit is contained in:
John MacFarlane 2016-02-03 13:31:21 -08:00
parent 7a10507dc8
commit 93a05dffd3
2 changed files with 19 additions and 16 deletions

View file

@ -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]

View file

@ -6,7 +6,7 @@
<th align="right">Right</th>
<th align="left">Left</th>
<th align="center">Center</th>
<th align="left">Default</th>
<th>Default</th>
</tr>
</thead>
<tbody>
@ -14,19 +14,19 @@
<td align="right">12</td>
<td align="left">12</td>
<td align="center">12</td>
<td align="left">12</td>
<td>12</td>
</tr>
<tr class="even">
<td align="right">123</td>
<td align="left">123</td>
<td align="center">123</td>
<td align="left">123</td>
<td>123</td>
</tr>
<tr class="odd">
<td align="right">1</td>
<td align="left">1</td>
<td align="center">1</td>
<td align="left">1</td>
<td>1</td>
</tr>
</tbody>
</table>
@ -37,7 +37,7 @@
<th align="right">Right</th>
<th align="left">Left</th>
<th align="center">Center</th>
<th align="left">Default</th>
<th>Default</th>
</tr>
</thead>
<tbody>
@ -45,19 +45,19 @@
<td align="right">12</td>
<td align="left">12</td>
<td align="center">12</td>
<td align="left">12</td>
<td>12</td>
</tr>
<tr class="even">
<td align="right">123</td>
<td align="left">123</td>
<td align="center">123</td>
<td align="left">123</td>
<td>123</td>
</tr>
<tr class="odd">
<td align="right">1</td>
<td align="left">1</td>
<td align="center">1</td>
<td align="left">1</td>
<td>1</td>
</tr>
</tbody>
</table>
@ -69,7 +69,7 @@
<th align="right">Right</th>
<th align="left">Left</th>
<th align="center">Center</th>
<th align="left">Default</th>
<th>Default</th>
</tr>
</thead>
<tbody>
@ -77,19 +77,19 @@
<td align="right">12</td>
<td align="left">12</td>
<td align="center">12</td>
<td align="left">12</td>
<td>12</td>
</tr>
<tr class="even">
<td align="right">123</td>
<td align="left">123</td>
<td align="center">123</td>
<td align="left">123</td>
<td>123</td>
</tr>
<tr class="odd">
<td align="right">1</td>
<td align="left">1</td>
<td align="center">1</td>
<td align="left">1</td>
<td>1</td>
</tr>
</tbody>
</table>
@ -192,13 +192,13 @@
<td align="center">First</td>
<td align="left">row</td>
<td align="right">12.0</td>
<td align="left">Example of a row that spans multiple lines.</td>
<td>Example of a row that spans multiple lines.</td>
</tr>
<tr class="even">
<td align="center">Second</td>
<td align="left">row</td>
<td align="right">5.0</td>
<td align="left">Here's another one. Note the blank line between rows.</td>
<td>Here's another one. Note the blank line between rows.</td>
</tr>
</tbody>
</table>