diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-04-17 10:04:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-17 10:04:39 -0700 |
commit | 906305de789c83f9fdcc2c7d30044acf97e89582 (patch) | |
tree | f359e991e60e7324f11e73a40259ed9dc3e4b91b /src/Text/Pandoc/Writers/Native.hs | |
parent | f0f3cc14beeea51f703f7cfc8b40ebf3de2d0a05 (diff) | |
parent | d1521af8fb0d3e8ee4104224e4d5e0b6e6bfad8c (diff) | |
download | pandoc-906305de789c83f9fdcc2c7d30044acf97e89582.tar.gz |
Merge pull request #6224 from despresc/better-tables
Diffstat (limited to 'src/Text/Pandoc/Writers/Native.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/Native.hs | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/Native.hs b/src/Text/Pandoc/Writers/Native.hs index 1c4719fe9..4d4dfca15 100644 --- a/src/Text/Pandoc/Writers/Native.hs +++ b/src/Text/Pandoc/Writers/Native.hs @@ -40,12 +40,42 @@ prettyBlock (DefinitionList items) = "DefinitionList" $$ prettyList (map deflistitem items) where deflistitem (term, defs) = "(" <> text (show term) <> "," <> cr <> nest 1 (prettyList $ map (prettyList . map prettyBlock) defs) <> ")" -prettyBlock (Table caption aligns widths header rows) = - "Table " <> text (show caption) <> " " <> text (show aligns) <> " " <> - text (show widths) $$ - prettyRow header $$ - prettyList (map prettyRow rows) - where prettyRow cols = prettyList (map (prettyList . map prettyBlock) cols) +prettyBlock (Table attr blkCapt specs thead tbody tfoot) = + mconcat [ "Table " + , text (show attr) + , " " + , prettyCaption blkCapt ] $$ + prettyList (map (text . show) specs) $$ + prettyHead thead $$ + prettyBodies tbody $$ + prettyFoot tfoot + where prettyRows = prettyList . map prettyRow + prettyRow (Row a body) = + text ("Row " <> show a) $$ prettyList (map prettyCell body) + prettyCell (Cell a ma h w b) = + mconcat [ "Cell " + , text (show a) + , " " + , text (show ma) + , " (" + , text (show h) + , ") (" + , text (show w) + , ")" ] $$ + prettyList (map prettyBlock b) + prettyCaption (Caption mshort body) = + "(Caption " <> text (showsPrec 11 mshort "") $$ prettyList (map prettyBlock body) <> ")" + prettyHead (TableHead thattr body) + = "(TableHead " <> text (show thattr) $$ prettyRows body <> ")" + prettyBody (TableBody tbattr rhc hd bd) + = mconcat [ "(TableBody " + , text (show tbattr) + , " (" + , text (show rhc) + , ")" ] $$ prettyRows hd $$ prettyRows bd <> ")" + prettyBodies = prettyList . map prettyBody + prettyFoot (TableFoot tfattr body) + = "(TableFoot " <> text (show tfattr) $$ prettyRows body <> ")" prettyBlock (Div attr blocks) = text ("Div " <> show attr) $$ prettyList (map prettyBlock blocks) prettyBlock block = text $ show block |