@@ -218,48 +218,23 @@ blockToPseudoPod opts (BlockQuote blocks) = do
218218 contents <- blockListToPseudoPod opts blocks
219219 return $ "=begin blockquote" <> blankline <> contents <> blankline <> "=end blockquote" <> blankline
220220
221−blockToPseudoPod opts (Table caption aligns widths headers rows) = do
221+-- | =begin table <caption> / =headrow / =row / =cell / =bodyrows / =row / =cell / =end table
222+blockToPseudoPod opts (Table caption _ _ headers rows) = do
222223 caption' <- inlineListToPseudoPod opts caption
223− let caption'' = if null caption
224− then empty
225− else blankline <> ": " <> caption' <> blankline
226224 headers' <- mapM (blockListToPseudoPod opts) headers
227− let alignHeader alignment = case alignment of
228− AlignLeft -> lblock
229− AlignCenter -> cblock
230− AlignRight -> rblock
231− AlignDefault -> lblock
225+
232226 rawRows <- mapM (mapM (blockListToPseudoPod opts)) rows
233− let isSimple = all (==0) widths
234− let numChars = maximum . map offset
235− let widthsInChars =
236− if isSimple
237− then map ((+2) . numChars) $ transpose (headers' : rawRows)
238− else map (floor . (fromIntegral (writerColumns opts) *)) widths
239− let makeRow = hcat . intersperse (lblock 1 (text " ")) .
240− (zipWith3 alignHeader aligns widthsInChars)
227+ let makeRow = hcat . intersperse (text("\n=cell "))
228+ let makeRowBlock = hcat . intersperse (text("\n=row\n\n=cell "))
229+
241230 let rows' = map makeRow rawRows
231+ let rows'' = makeRowBlock rows'
232+ let rows''' = "=row" <> blankline <> "=cell " <> rows''
233+
242234 let head' = makeRow headers'
243− let maxRowHeight = maximum $ map height (head':rows')
244− let underline = cat $ intersperse (text " ") $
245− map (\width -> text (replicate width '-')) widthsInChars
246− let border = if maxRowHeight > 1
247− then text (replicate (sum widthsInChars +
248− length widthsInChars - 1) '-')
249− else if all null headers
250− then underline
251− else empty
252− let head'' = if all null headers
253− then empty
254− else border <> cr <> head'
255− let body = if maxRowHeight > 1
256− then vsep rows'
257− else vcat rows'
258− let bottom = if all null headers
259− then underline
260− else border
261− return $ nest 2 $ head'' $$ underline $$ body $$
262− bottom $$ blankline $$ caption'' $$ blankline
235+ let head'' = "=row" <> blankline <> "=cell " <> head'
236+
237+ return $ "=begin table " <> caption' <> blankline <> "=headrow" <> blankline <> head'' <> blankline <> "=bodyrows" <> blankline <> rows''' <> blankline <> "=end table" <> blankline
263238
264239-- | =over / =item * / =back
265240blockToPseudoPod opts (BulletList items) = do