RST writer: Fixed headerless tables.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1879 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
fiddlosopher 2010-03-11 03:01:27 +00:00
parent ea67219449
commit a34afa91ef
3 changed files with 57 additions and 2 deletions

View file

@ -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

View file

@ -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."] ] ] ] ]

View file

@ -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. |
+-------------+------------+--------------+----------------------------+