From 78043a12ca1abcb8050f572c9d861df181c14671 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Fri, 20 Aug 2010 14:50:27 +0200 Subject: Bugfix for table output. Apparently, RST requires the first line of tables to be drawn with minuses, not equal signs. --- ftplugin/rst_tables.vim | 2 +- src/rst_tables.py | 2 +- tests/test_rst_tables.py | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ftplugin/rst_tables.vim b/ftplugin/rst_tables.vim index ae0979a..e042157 100644 --- a/ftplugin/rst_tables.vim +++ b/ftplugin/rst_tables.vim @@ -248,7 +248,7 @@ def draw_table(table, manual_widths=None): header_line = table_line(sep_col_widths, header=True) normal_line = table_line(sep_col_widths, header=False) - output = [header_line] + output = [normal_line] first = True for row in table: diff --git a/src/rst_tables.py b/src/rst_tables.py index 1d4b04b..1cae9a9 100644 --- a/src/rst_tables.py +++ b/src/rst_tables.py @@ -229,7 +229,7 @@ def draw_table(table, manual_widths=None): header_line = table_line(sep_col_widths, header=True) normal_line = table_line(sep_col_widths, header=False) - output = [header_line] + output = [normal_line] first = True for row in table: diff --git a/tests/test_rst_tables.py b/tests/test_rst_tables.py index a86e401..9e88917 100644 --- a/tests/test_rst_tables.py +++ b/tests/test_rst_tables.py @@ -118,7 +118,7 @@ class TestRSTTableFormatter(unittest.TestCase): self.assertEquals(expected, parse_table(input)) def testParseValidTable(self): - input = ['+=====+====+', + input = ['+-----+----+', '| Foo | Mu |', '+=====+====+', '| x | y |', @@ -127,7 +127,7 @@ class TestRSTTableFormatter(unittest.TestCase): self.assertEquals(expect, parse_table(input)) def testParseCorruptedTable(self): - input = ['+===+-----====+', + input = ['+---+---------+', '| Foo | Mu |', '+=====+====+', '| x | This became somewhat larger |', @@ -137,7 +137,7 @@ class TestRSTTableFormatter(unittest.TestCase): ['x\nblah', 'This became somewhat larger\nA new line']] self.assertEquals(expect, parse_table(input)) - input = ['+===+-----====+', + input - ['+---+---------+', '| Foo | Mu |', '+=====+====+', '| x | This became somewhat larger |', @@ -149,7 +149,7 @@ class TestRSTTableFormatter(unittest.TestCase): def testParseMultiLineFields(self): input = """\ -+=====+=====================+ ++-----+---------------------+ | Foo | Bar | +=====+=====================+ | x | This is a long line | @@ -175,7 +175,7 @@ class TestRSTTableFormatter(unittest.TestCase): input = [['Foo', 'Bar'], ['x', 'This is a long line\nthat is spread out\nover multiple lines']] expect = """\ -+=====+=====================+ ++-----+---------------------+ | Foo | Bar | +=====+=====================+ | x | This is a long line | @@ -212,7 +212,7 @@ class TestRSTTableFormatter(unittest.TestCase): 'This\nis\nreally\nneat!']])) def testGetColumnWidthsFromBorderSpec(self): - input = ['+====+=====+==+=======+', + input = ['+----+-----+--+-------+', '| xx | xxx | | xxxxx |', '+====+=====+==+=======+'] self.assertEquals([2, 3, 0, 5], @@ -250,11 +250,11 @@ class TestRSTTableFormatter(unittest.TestCase): def testDrawTable(self): self.assertEquals([], draw_table([])) - self.assertEquals(['+==+', '| |', '+==+'], draw_table([['']])) - self.assertEquals(['+=====+', '| Foo |', '+=====+'], + self.assertEquals(['+--+', '| |', '+==+'], draw_table([['']])) + self.assertEquals(['+-----+', '| Foo |', '+=====+'], draw_table([['Foo']])) self.assertEquals( - ['+=====+====+', + ['+-----+----+', '| Foo | Mu |', '+=====+====+', '| x | y |', @@ -267,7 +267,7 @@ class TestRSTTableFormatter(unittest.TestCase): expect = """\ This is paragraph text *before* the table. -+==========+================================================================================================+ ++----------+------------------------------------------------------------------------------------------------+ | Column 1 | Column 2 | +==========+================================================================================================+ | Foo | Put two (or more) spaces as a field separator. | @@ -289,7 +289,7 @@ a line ending. # not belong to the table del raw_lines[-1] expect = """\ -+================+===============================================================+ ++----------------+---------------------------------------------------------------+ | Feature | Description | +================+===============================================================+ | Ease of use | Drop dead simple! | @@ -310,7 +310,7 @@ a line ending. expect = """\ This is paragraph text *before* the table. -+==========+==========================+ ++----------+--------------------------+ | Column 1 | Column 2 | +==========+==========================+ | Foo | Put two (or more) spaces | -- cgit v1.2.3