aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/Textile.hs
diff options
context:
space:
mode:
authordespresc <christian.j.j.despres@gmail.com>2020-03-28 18:22:48 -0400
committerdespresc <christian.j.j.despres@gmail.com>2020-04-15 23:03:22 -0400
commit7254a2ae0ba40b29c04b8924f27739614229432b (patch)
tree114e3143953451e3212511e7bf2e178548d3e1bd /src/Text/Pandoc/Writers/Textile.hs
parent83c1ce1d77d3ef058e4e5c645a8eb0379fab780f (diff)
downloadpandoc-7254a2ae0ba40b29c04b8924f27739614229432b.tar.gz
Implement the new Table type
Diffstat (limited to 'src/Text/Pandoc/Writers/Textile.hs')
-rw-r--r--src/Text/Pandoc/Writers/Textile.hs76
1 files changed, 38 insertions, 38 deletions
diff --git a/src/Text/Pandoc/Writers/Textile.hs b/src/Text/Pandoc/Writers/Textile.hs
index d2cb74c84..2e02448e3 100644
--- a/src/Text/Pandoc/Writers/Textile.hs
+++ b/src/Text/Pandoc/Writers/Textile.hs
@@ -168,44 +168,44 @@ blockToTextile opts (BlockQuote blocks) = do
contents <- blockListToTextile opts blocks
return $ "<blockquote>\n\n" <> contents <> "\n</blockquote>\n"
-blockToTextile opts (Table [] aligns widths headers rows') |
- all (==0) widths = do
- hs <- mapM (liftM (("_. " <>) . stripTrailingNewlines) . blockListToTextile opts) headers
- let cellsToRow cells = "|" <> T.intercalate "|" cells <> "|"
- let header = if all null headers then "" else cellsToRow hs <> "\n"
- let blocksToCell (align, bs) = do
- contents <- stripTrailingNewlines <$> blockListToTextile opts bs
- let alignMarker = case align of
- AlignLeft -> "<. "
- AlignRight -> ">. "
- AlignCenter -> "=. "
- AlignDefault -> ""
- return $ alignMarker <> contents
- let rowToCells = mapM blocksToCell . zip aligns
- bs <- mapM rowToCells rows'
- let body = T.unlines $ map cellsToRow bs
- return $ header <> body
-
-blockToTextile opts (Table capt aligns widths headers rows') = do
- let alignStrings = map alignmentToText aligns
- captionDoc <- if null capt
- then return ""
- else do
- c <- inlineListToTextile opts capt
- return $ "<caption>" <> c <> "</caption>\n"
- let percent w = tshow (truncate (100*w) :: Integer) <> "%"
- let coltags = if all (== 0.0) widths
- then ""
- else T.unlines $ map
- (\w -> "<col width=\"" <> percent w <> "\" />") widths
- head' <- if all null headers
- then return ""
- else do
- hs <- tableRowToTextile opts alignStrings 0 headers
- return $ "<thead>\n" <> hs <> "\n</thead>\n"
- body' <- zipWithM (tableRowToTextile opts alignStrings) [1..] rows'
- return $ "<table>\n" <> captionDoc <> coltags <> head' <>
- "<tbody>\n" <> T.unlines body' <> "</tbody>\n</table>\n"
+blockToTextile opts (Table _ blkCapt specs _ thead tbody tfoot)
+ = case toLegacyTable blkCapt specs thead tbody tfoot of
+ ([], aligns, widths, headers, rows') | all (==0) widths -> do
+ hs <- mapM (liftM (("_. " <>) . stripTrailingNewlines) . blockListToTextile opts) headers
+ let cellsToRow cells = "|" <> T.intercalate "|" cells <> "|"
+ let header = if all null headers then "" else cellsToRow hs <> "\n"
+ let blocksToCell (align, bs) = do
+ contents <- stripTrailingNewlines <$> blockListToTextile opts bs
+ let alignMarker = case align of
+ AlignLeft -> "<. "
+ AlignRight -> ">. "
+ AlignCenter -> "=. "
+ AlignDefault -> ""
+ return $ alignMarker <> contents
+ let rowToCells = mapM blocksToCell . zip aligns
+ bs <- mapM rowToCells rows'
+ let body = T.unlines $ map cellsToRow bs
+ return $ header <> body
+ (capt, aligns, widths, headers, rows') -> do
+ let alignStrings = map alignmentToText aligns
+ captionDoc <- if null capt
+ then return ""
+ else do
+ c <- inlineListToTextile opts capt
+ return $ "<caption>" <> c <> "</caption>\n"
+ let percent w = tshow (truncate (100*w) :: Integer) <> "%"
+ let coltags = if all (== 0.0) widths
+ then ""
+ else T.unlines $ map
+ (\w -> "<col width=\"" <> percent w <> "\" />") widths
+ head' <- if all null headers
+ then return ""
+ else do
+ hs <- tableRowToTextile opts alignStrings 0 headers
+ return $ "<thead>\n" <> hs <> "\n</thead>\n"
+ body' <- zipWithM (tableRowToTextile opts alignStrings) [1..] rows'
+ return $ "<table>\n" <> captionDoc <> coltags <> head' <>
+ "<tbody>\n" <> T.unlines body' <> "</tbody>\n</table>\n"
blockToTextile opts x@(BulletList items) = do
oldUseTags <- gets stUseTags