diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2010-03-11 03:01:27 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2010-03-11 03:01:27 +0000 |
commit | a34afa91efd1ba313d0a2b4a52a878d6e2453730 (patch) | |
tree | ae98fdc323ed31f9478904ee31328451dcfe2f1d | |
parent | ea6721944903122b53c657b4901dbf687a1e416a (diff) | |
download | pandoc-a34afa91efd1ba313d0a2b4a52a878d6e2453730.tar.gz |
RST writer: Fixed headerless tables.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1879 788f1e2b-df1e-0410-8736-df70ead52e1b
-rw-r--r-- | src/Text/Pandoc/Writers/RST.hs | 6 | ||||
-rw-r--r-- | tests/tables-rstsubset.native | 32 | ||||
-rw-r--r-- | tests/tables.rst | 21 |
3 files changed, 57 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 04f5e0ca4..e046c5a81 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -204,8 +204,10 @@ blockToRST (Table caption _ widths headers rows) = do map (\l -> text $ replicate l ch) widthsInChars) <> char ch <> char '+' let body = vcat $ intersperse (border '-') $ map blockToDoc rows' - return $ border '-' $+$ blockToDoc head' $+$ border '=' $+$ body $+$ - border '-' $$ caption'' $$ text "" + let head'' = if all null headers + then empty + else blockToDoc head' $+$ border '=' + return $ border '-' $+$ head'' $+$ body $+$ border '-' $$ caption'' $$ text "" blockToRST (BulletList items) = do contents <- mapM bulletListItemToRST items -- ensure that sublists have preceding blank line diff --git a/tests/tables-rstsubset.native b/tests/tables-rstsubset.native index fb01230c7..f26e46e90 100644 --- a/tests/tables-rstsubset.native +++ b/tests/tables-rstsubset.native @@ -83,5 +83,37 @@ Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []}) [ [ Plain [Str "Second"] ] , [ Plain [Str "row"] ] , [ Plain [Str "5.0"] ] + , [ Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."] ] ] ] +, Para [Str "Table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"] +, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.1,0.1,0.1,0.1] + [ [] + , [] + , [] + , [] ] [ + [ [ Plain [Str "12"] ] + , [ Plain [Str "12"] ] + , [ Plain [Str "12"] ] + , [ Plain [Str "12"] ] ], + [ [ Plain [Str "123"] ] + , [ Plain [Str "123"] ] + , [ Plain [Str "123"] ] + , [ Plain [Str "123"] ] ], + [ [ Plain [Str "1"] ] + , [ Plain [Str "1"] ] + , [ Plain [Str "1"] ] + , [ Plain [Str "1"] ] ] ] +, Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"] +, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625] + [ [] + , [] + , [] + , [] ] [ + [ [ Plain [Str "First"] ] + , [ Plain [Str "row"] ] + , [ Plain [Str "12.0"] ] + , [ Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."] ] ], + [ [ Plain [Str "Second"] ] + , [ Plain [Str "row"] ] + , [ Plain [Str "5.0"] ] , [ Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."] ] ] ] ] diff --git a/tests/tables.rst b/tests/tables.rst index 0db3efcc5..c7c0c954d 100644 --- a/tests/tables.rst +++ b/tests/tables.rst @@ -68,4 +68,25 @@ Multiline table without caption: | | | | rows. | +-------------+------------+--------------+----------------------------+ +Table without column headers: + ++-------+-------+-------+-------+ +| 12 | 12 | 12 | 12 | ++-------+-------+-------+-------+ +| 123 | 123 | 123 | 123 | ++-------+-------+-------+-------+ +| 1 | 1 | 1 | 1 | ++-------+-------+-------+-------+ + +Multiline table without column headers: + ++-------------+------------+--------------+----------------------------+ +| First | row | 12.0 | Example of a row that | +| | | | spans multiple lines. | ++-------------+------------+--------------+----------------------------+ +| Second | row | 5.0 | Here's another one. Note | +| | | | the blank line between | +| | | | rows. | ++-------------+------------+--------------+----------------------------+ + |