Skip to content

Commit 94f5a6a

Browse files
committed
fix rst empty column escaping
1 parent a93034a commit 94f5a6a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

tabulate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def escape_char(c):
199199

200200
def _rst_escape_first_column(rows, headers):
201201
def escape_empty(val):
202-
if isinstance(val, (_text_type, _binary_type)) and val.strip() is "":
202+
if isinstance(val, (_text_type, _binary_type)) and not val.strip():
203203
return ".."
204204
else:
205205
return val

test/test_output.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,18 @@ def test_rst():
260260
result = tabulate(_test_table, _test_table_headers, tablefmt="rst")
261261
assert_equal(expected, result)
262262

263+
def test_rst_with_empty_values_in_first_column():
264+
"Output: rst with dots in first column"
265+
test_headers = ['', 'what']
266+
test_data = [('', 'spam'), ('', 'eggs')]
267+
expected = '\n'.join(['==== ======',
268+
'.. what',
269+
'==== ======',
270+
'.. spam',
271+
'.. eggs',
272+
'==== ======'])
273+
result = tabulate(test_data, test_headers, tablefmt="rst")
274+
assert_equal(expected, result)
263275

264276
def test_rst_headerless():
265277
"Output: rst without headers"

0 commit comments

Comments
 (0)