Skip to content

Commit eb212e4

Browse files
author
Amjith Ramanujam
committed
Add a new table format that resembles postgres psql.
1 parent afa243b commit eb212e4

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,17 @@ extensions::
181181
│ bacon │ 0 │
182182
╘════════╧═══════╛
183183

184+
``psql`` is like tables formatted by Postgres' psql cli::
185+
186+
>>> print tabulate.tabulate()
187+
+--------+-------+
188+
| item | qty |
189+
|--------+-------|
190+
| spam | 42 |
191+
| eggs | 451 |
192+
| bacon | 0 |
193+
+--------+-------+
194+
184195
``pipe`` follows the conventions of `PHP Markdown Extra`_ extension. It
185196
corresponds to ``pipe_tables`` in Pandoc. This format uses colons to
186197
indicate column alignment::

tabulate.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,14 @@ def escape_char(c):
197197
headerrow=DataRow("|", "|", "|"),
198198
datarow=DataRow("|", "|", "|"),
199199
padding=1, with_header_hide=None),
200+
"psql":
201+
TableFormat(lineabove=Line("+", "-", "+", "+"),
202+
linebelowheader=Line("|", "-", "+", "|"),
203+
linebetweenrows=None,
204+
linebelow=Line("+", "-", "+", "+"),
205+
headerrow=DataRow("|", "|", "|"),
206+
datarow=DataRow("|", "|", "|"),
207+
padding=1, with_header_hide=None),
200208
"rst":
201209
TableFormat(lineabove=Line("", "=", " ", ""),
202210
linebelowheader=Line("", "=", " ", ""),

0 commit comments

Comments
 (0)