Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 1.57 KB

README.md

File metadata and controls

59 lines (45 loc) · 1.57 KB

Tablr

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.

Markup

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.

Example

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 |
+----------------+----------+---------------+

VIM Integration

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>