Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/haltcase/tablemark-cli

Generate markdown tables from JSON data at the command line.
https://github.com/haltcase/tablemark-cli

array cli command-line convert generate hacktoberfest json json-data markdown table

Last synced: 19 days ago
JSON representation

Generate markdown tables from JSON data at the command line.

Awesome Lists containing this project

README

        

# tablemark-cli · [![Version](https://flat.badgen.net/npm/v/tablemark-cli)](https://www.npmjs.com/package/tablemark-cli) [![License](https://flat.badgen.net/npm/license/tablemark-cli)](https://www.npmjs.com/package/tablemark-cli) [![Travis CI](https://flat.badgen.net/travis/haltcase/tablemark-cli)](https://travis-ci.org/haltcase/tablemark-cli) [![JavaScript Standard Style](https://flat.badgen.net/badge/code%20style/standard/green)](https://standardjs.com)

> Generate markdown tables from JSON data at the command line.

Render JSON input data as a markdown table from the command line,
powered by the [`tablemark`](https://github.com/haltcase/tablemark) module.

## features

This utility supports:

* JSON file input from a provided path
* data piped from `stdin`
* NDJSON formatted data ([newline delimited JSON](http://ndjson.org/))

## installation

```sh
yarn global add tablemark-cli

# or

npm install --global tablemark-cli
```

## usage

```sh
tablemark 3.0.0
> Generate markdown tables from JSON data at the command line.

ARGUMENTS:
- Path to input file containing JSON data (use - for stdin)

OPTIONS:
--column , -c= - Custom column name, can be used multiple times (default: infer from object keys)
--align , -a= - Custom alignments, can be used multiple times, applied in order to columns (default: left)
--line-ending, -e - End-of-line string (default: \n) [optional]
--wrap-width, -w - Width at which to hard wrap cell content [default: Infinity]

FLAGS:
--no-case-headers, -N - Disable automatic sentence casing of inferred column names [default: false]
--wrap-with-gutters, -G - Add '|' characters to wrapped rows [default: false]
--help, -h - show help
--version, -v - print the version
```

To apply the `align` and `column` options to multiple columns, supply the flag
multiple times, like this:

```sh
tablemark input.json > output.md -a left -a center -a right
```

... which will align the first three columns left, center, and right respectively.

## stdin

In bash-like shells:

```sh
# stdin -> stdout
echo '{ "one": 1 }' | tablemark -

# redirect input file content into stdin, then to a file
tablemark - < input.json > output.md
```

In PowerShell:

```powershell
# stdin -> stdout
'{ "one": 1 }' | tablemark -

# redirect input file content into stdin, then to a file
cat input.json | tablemark - > output.md
```

## ndjson

[NDJSON](http://ndjson.org) is a form of JSON that delimits multiple JSON objects by newlines:

```js
{"name":"trilogy","repo":"[haltcase/trilogy](https://github.com/haltcase/trilogy)","desc":"No-hassle SQLite with type-casting schema models and support for native & pure JS backends."}
{"name":"strat","repo":"[haltcase/strat](https://github.com/haltcase/strat)","desc":"Functional-ish JavaScript string formatting, with inspirations from Python."}
{"name":"tablemark-cli","repo":"[haltcase/tablemark-cli](https://github.com/haltcase/tablemark-cli)","desc":"Generate markdown tables from JSON data at the command line."}
```

This input from a file or stdin is supported just as if it were
a JSON compatible array:

```sh
tablemark input.ndjson > output.md
```

## see also

* [`tablemark`](https://github.com/haltcase/tablemark) – the module used by this utility

## contributing

Search the [issues](https://github.com/haltcase/tablemark-cli) if you come
across any trouble, open a new one if it hasn't been posted, or, if you're
able, open a [pull request](https://help.github.com/articles/about-pull-requests/).
Contributions of any kind are welcome in this project.

The following people have already contributed their time and effort:

* Thomas Jensen (**[@tjconcept](https://github.com/tjconcept)**)

Thank you!

## license

MIT © Bo Lingen / haltcase