git.iko.soy/typeable/pandoc
on master help sign in
HTML writer: Add colgroup around col tags.

Also affects EPUB writer. Closes #877.

commitf3c9d3788530e450d1bb23a4fd829bc5a6eed266 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 5 Mar 2014, 13:01 (13 years ago) parent6fda361
2 files changed+16−5
src/Text/Pandoc/Writers/HTML.hs+10−5 tests/tables.html+6
src/Text/Pandoc/Writers/HTML.hs+10−5
@@ -533,11 +533,16 @@ blockToHtml opts (Table capt aligns widths headers rows') = do
533533 let percent w = show (truncate (100*w) :: Integer) ++ "%"
534534 let coltags = if all (== 0.0) widths
535535 then mempty
536− else mconcat $ map (\w ->
537− if writerHtml5 opts
538− then H.col ! A.style (toValue $ "width: " ++ percent w)
539− else H.col ! A.width (toValue $ percent w) >> nl opts)
540− widths
536+ else do
537+ H.colgroup $ do
538+ nl opts
539+ mapM_ (\w -> do
540+ if writerHtml5 opts
541+ then H.col ! A.style (toValue $ "width: " ++
542+ percent w)
543+ else H.col ! A.width (toValue $ percent w)
544+ nl opts) widths
545+ nl opts
541546 head' <- if all null headers
542547 then return mempty
543548 else do
tests/tables.html+6
@@ -96,10 +96,12 @@
9696<p>Multiline table with caption:</p>
9797<table>
9898<caption>Here's the caption. It may span multiple lines.</caption>
99+<colgroup>
99100<col width="15%" />
100101<col width="13%" />
101102<col width="16%" />
102103<col width="33%" />
104+</colgroup>
103105<thead>
104106<tr class="header">
105107<th align="center">Centered Header</th>
@@ -125,10 +127,12 @@
125127</table>
126128<p>Multiline table without caption:</p>
127129<table>
130+<colgroup>
128131<col width="15%" />
129132<col width="13%" />
130133<col width="16%" />
131134<col width="33%" />
135+</colgroup>
132136<thead>
133137<tr class="header">
134138<th align="center">Centered Header</th>
@@ -177,10 +181,12 @@
177181</table>
178182<p>Multiline table without column headers:</p>
179183<table>
184+<colgroup>
180185<col width="15%" />
181186<col width="13%" />
182187<col width="16%" />
183188<col width="33%" />
189+</colgroup>
184190<tbody>
185191<tr class="odd">
186192<td align="center">First</td>