summaryrefslogtreecommitdiff
path: root/src/Text
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
parent510a6ee059cd99bef41102f754c0e4674493f28f (diff)
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')
-rw-r--r--src/Text/Pandoc/Readers/RST.hs2
-rw-r--r--src/Text/Pandoc/Writers/RST.hs9
2 files changed, 6 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index bc0fc042c..024c56685 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -709,7 +709,7 @@ tableDirective top _fields body = do
-- align is not applicable since we can't represent whole table align
return $ B.singleton $ Table (B.toList title)
aligns' widths' header' rows'
- bs -> return mempty
+ _ -> return mempty
-- TODO:
-- - Only supports :format: fields with a single format for :raw: roles,
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