git.iko.soy/typeable/pandoc
on master help sign in
RST writer: Fixed headerless tables.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1879 788f1e2b-df1e-0410-8736-df70ead52e1b

commita34afa91efd1ba313d0a2b4a52a878d6e2453730 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 11 Mar 2010, 03:01 (17 years ago) parentea67219
3 files changed+57−2
src/Text/Pandoc/Writers/RST.hs+4−2 tests/tables-rstsubset.native+32 tests/tables.rst+21
src/Text/Pandoc/Writers/RST.hs+4−2
@@ -204,8 +204,10 @@ blockToRST (Table caption _ widths headers rows) = do
204204 map (\l -> text $ replicate l ch) widthsInChars) <>
205205 char ch <> char '+'
206206 let body = vcat $ intersperse (border '-') $ map blockToDoc rows'
207− return $ border '-' $+$ blockToDoc head' $+$ border '=' $+$ body $+$
208− border '-' $$ caption'' $$ text ""
207+ let head'' = if all null headers
208+ then empty
209+ else blockToDoc head' $+$ border '='
210+ return $ border '-' $+$ head'' $+$ body $+$ border '-' $$ caption'' $$ text ""
209211blockToRST (BulletList items) = do
210212 contents <- mapM bulletListItemToRST items
211213 -- ensure that sublists have preceding blank line
tests/tables-rstsubset.native+32
@@ -83,5 +83,37 @@ Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
8383 [ [ Plain [Str "Second"] ]
8484 , [ Plain [Str "row"] ]
8585 , [ Plain [Str "5.0"] ]
86+ , [ 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."] ] ] ]
87+, Para [Str "Table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"]
88+, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.1,0.1,0.1,0.1]
89+ [ []
90+ , []
91+ , []
92+ , [] ] [
93+ [ [ Plain [Str "12"] ]
94+ , [ Plain [Str "12"] ]
95+ , [ Plain [Str "12"] ]
96+ , [ Plain [Str "12"] ] ],
97+ [ [ Plain [Str "123"] ]
98+ , [ Plain [Str "123"] ]
99+ , [ Plain [Str "123"] ]
100+ , [ Plain [Str "123"] ] ],
101+ [ [ Plain [Str "1"] ]
102+ , [ Plain [Str "1"] ]
103+ , [ Plain [Str "1"] ]
104+ , [ Plain [Str "1"] ] ] ]
105+, Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"]
106+, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625]
107+ [ []
108+ , []
109+ , []
110+ , [] ] [
111+ [ [ Plain [Str "First"] ]
112+ , [ Plain [Str "row"] ]
113+ , [ Plain [Str "12.0"] ]
114+ , [ Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."] ] ],
115+ [ [ Plain [Str "Second"] ]
116+ , [ Plain [Str "row"] ]
117+ , [ Plain [Str "5.0"] ]
86118 , [ 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."] ] ] ] ]
87119
tests/tables.rst+21
@@ -68,4 +68,25 @@ Multiline table without caption:
6868| | | | rows. |
6969+-------------+------------+--------------+----------------------------+
7070
71+Table without column headers:
72+
73++-------+-------+-------+-------+
74+| 12 | 12 | 12 | 12 |
75++-------+-------+-------+-------+
76+| 123 | 123 | 123 | 123 |
77++-------+-------+-------+-------+
78+| 1 | 1 | 1 | 1 |
79++-------+-------+-------+-------+
80+
81+Multiline table without column headers:
82+
83++-------------+------------+--------------+----------------------------+
84+| First | row | 12.0 | Example of a row that |
85+| | | | spans multiple lines. |
86++-------------+------------+--------------+----------------------------+
87+| Second | row | 5.0 | Here's another one. Note |
88+| | | | the blank line between |
89+| | | | rows. |
90++-------------+------------+--------------+----------------------------+
91+
7192