aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-02-11 22:36:47 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-02-11 22:37:07 +0100
commit27599602042a43bfe1506c008dab862352bba0b1 (patch)
tree75a5fcbb9dddff3e9595a9baef04a78ea08cd763 /src/Text/Pandoc/Writers
parent510a6ee059cd99bef41102f754c0e4674493f28f (diff)
downloadpandoc-27599602042a43bfe1506c008dab862352bba0b1.tar.gz
RST reader/writer: properly handle table captions.
Currently the support for the `.. table` directive is a bit limited; we don't yet support the `widths` field. But at least you can have a proper captioned table.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/RST.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
index 6093c668b..5cce64d17 100644
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -266,9 +266,6 @@ blockToRST (BlockQuote blocks) = do
return $ (nest tabstop contents) <> blankline
blockToRST (Table caption _ widths headers rows) = do
caption' <- inlineListToRST caption
- let caption'' = if null caption
- then empty
- else blankline <> text "Table: " <> caption'
headers' <- mapM blockListToRST headers
rawRows <- mapM (mapM blockListToRST) rows
-- let isSimpleCell [Plain _] = True
@@ -299,7 +296,11 @@ blockToRST (Table caption _ widths headers rows) = do
let head'' = if all null headers
then empty
else head' $$ border '='
- return $ border '-' $$ head'' $$ body $$ border '-' $$ caption'' $$ blankline
+ let tbl = border '-' $$ head'' $$ body $$ border '-'
+ return $ if null caption
+ then tbl $$ blankline
+ else (".. table:: " <> caption') $$ blankline $$ nest 3 tbl $$
+ blankline
blockToRST (BulletList items) = do
contents <- mapM bulletListItemToRST items
-- ensure that sublists have preceding blank line