git.iko.soy/typeable/pandoc
on master help sign in
HTML writer: Add colgroup around col tags.
f3c9d37John MacFarlane
src/Text/Pandoc/Writers/HTML.hs+10−5
@@ -533,11 +533,16 @@ blockToHtml opts (Table capt aligns widths headers rows') = do
533 let percent w = show (truncate (100*w) :: Integer) ++ "%"
533 let percent w = show (truncate (100*w) :: Integer) ++ "%"
534 let coltags = if all (== 0.0) widths
534 let coltags = if all (== 0.0) widths
535 then mempty
535 then mempty
536− else mconcat $ map (\w ->
536+ else do
537+ H.colgroup $ do
538+ nl opts
539+ mapM_ (\w -> do
537− if writerHtml5 opts
540+ if writerHtml5 opts
538− then H.col ! A.style (toValue $ "width: " ++ percent w)
541+ then H.col ! A.style (toValue $ "width: " ++
542+ percent w)
539− else H.col ! A.width (toValue $ percent w) >> nl opts)
543+ else H.col ! A.width (toValue $ percent w)
540− widths
544+ nl opts) widths
545+ nl opts
541 head' <- if all null headers
546 head' <- if all null headers
542 then return mempty
547 then return mempty
543 else do
548 else do
tests/tables.html+6
@@ -96,10 +96,12 @@
96<p>Multiline table with caption:</p>
96<p>Multiline table with caption:</p>
97<table>
97<table>
98<caption>Here's the caption. It may span multiple lines.</caption>
98<caption>Here's the caption. It may span multiple lines.</caption>
99+<colgroup>
99<col width="15%" />
100<col width="15%" />
100<col width="13%" />
101<col width="13%" />
101<col width="16%" />
102<col width="16%" />
102<col width="33%" />
103<col width="33%" />
104+</colgroup>
103<thead>
105<thead>
104<tr class="header">
106<tr class="header">
105<th align="center">Centered Header</th>
107<th align="center">Centered Header</th>
@@ -125,10 +127,12 @@
125</table>
127</table>
126<p>Multiline table without caption:</p>
128<p>Multiline table without caption:</p>
127<table>
129<table>
130+<colgroup>
128<col width="15%" />
131<col width="15%" />
129<col width="13%" />
132<col width="13%" />
130<col width="16%" />
133<col width="16%" />
131<col width="33%" />
134<col width="33%" />
135+</colgroup>
132<thead>
136<thead>
133<tr class="header">
137<tr class="header">
134<th align="center">Centered Header</th>
138<th align="center">Centered Header</th>
@@ -177,10 +181,12 @@
177</table>
181</table>
178<p>Multiline table without column headers:</p>
182<p>Multiline table without column headers:</p>
179<table>
183<table>
184+<colgroup>
180<col width="15%" />
185<col width="15%" />
181<col width="13%" />
186<col width="13%" />
182<col width="16%" />
187<col width="16%" />
183<col width="33%" />
188<col width="33%" />
189+</colgroup>
184<tbody>
190<tbody>
185<tr class="odd">
191<tr class="odd">
186<td align="center">First</td>
192<td align="center">First</td>