Tablr is a simple command line utility for converting back and forth between a simple table markup language and pretty ASCII tables. It reads markup on standard in and writes the corresponding ASCII table to standard out.
The -r
flag may be given to convert from an ASCII table to markup also reading
and writing on standard in and out.
The tables generated by Tablr are currently very simple. A table is composed of a list of rows, each row may either by a divider or a list of cells. All rows in a table have the same number of cells.
A row of cells is specified on a single line with a |
character between each
cell.
A divider row is specified by a single line containing one or more -
characters and nothing else.
For example, the given markup:
Header 1 | Header 2 | Header 3
-
foo | bar | baz
just the first
||just the last
Will produce the following table when piped through tablr
:
+----------------+----------+---------------+
| Header 1 | Header 2 | Header 3 |
+----------------+----------+---------------+
| foo | bar | baz |
| just the first | | |
| | | just the last |
+----------------+----------+---------------+
Tablr was originally created with VIM integration in mind. You can add the
following to your ~/.vimrc
file to automatically convert the paragraph under
your cursor back and forth between tables and markup.
nnoremap <leader>at vip:!tablr<cr>
nnoremap <leader>ut vip:!tablr -r<cr>