Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

HTML writer: Add colgroup around col tags.

Also affects EPUB writer.
Closes #877.
  • Loading branch information...
commit f3c9d3788530e450d1bb23a4fd829bc5a6eed266 1 parent 6fda361
@jgm authored
Showing with 16 additions and 5 deletions.
  1. +10 −5 src/Text/Pandoc/Writers/HTML.hs
  2. +6 −0 tests/tables.html
View
15 src/Text/Pandoc/Writers/HTML.hs
@@ -533,11 +533,16 @@ blockToHtml opts (Table capt aligns widths headers rows') = do
let percent w = show (truncate (100*w) :: Integer) ++ "%"
let coltags = if all (== 0.0) widths
then mempty
- else mconcat $ map (\w ->
- if writerHtml5 opts
- then H.col ! A.style (toValue $ "width: " ++ percent w)
- else H.col ! A.width (toValue $ percent w) >> nl opts)
- widths
+ else do
+ H.colgroup $ do
+ nl opts
+ mapM_ (\w -> do
+ if writerHtml5 opts
+ then H.col ! A.style (toValue $ "width: " ++
+ percent w)
+ else H.col ! A.width (toValue $ percent w)
+ nl opts) widths
+ nl opts
head' <- if all null headers
then return mempty
else do
View
6 tests/tables.html
@@ -96,10 +96,12 @@
<p>Multiline table with caption:</p>
<table>
<caption>Here's the caption. It may span multiple lines.</caption>
+<colgroup>
<col width="15%" />
<col width="13%" />
<col width="16%" />
<col width="33%" />
+</colgroup>
<thead>
<tr class="header">
<th align="center">Centered Header</th>
@@ -125,10 +127,12 @@
</table>
<p>Multiline table without caption:</p>
<table>
+<colgroup>
<col width="15%" />
<col width="13%" />
<col width="16%" />
<col width="33%" />
+</colgroup>
<thead>
<tr class="header">
<th align="center">Centered Header</th>
@@ -177,10 +181,12 @@
</table>
<p>Multiline table without column headers:</p>
<table>
+<colgroup>
<col width="15%" />
<col width="13%" />
<col width="16%" />
<col width="33%" />
+</colgroup>
<tbody>
<tr class="odd">
<td align="center">First</td>
Please sign in to comment.
Something went wrong with that request. Please try again.