lightweight-markdown-table
v1.0.0
Published
Convert JSON/arrays to markdown tables with alignment options
Downloads
16
Maintainers
Readme
Lightweight Markdown Table Generator
Convert JSON data and arrays to markdown tables with flexible alignment options.
Installation
npm install lightweight-markdown-tableUsage
JavaScript API
const generateTable = require('lightweight-markdown-table');
const data = [
{ name: 'Item', price: '$10' },
{ name: 'Another Item', price: '$20' }
];
console.log(generateTable(data, {
headers: ['Product', 'Price'],
align: ['left', 'right']
}));CLI
md-table -i data.json -H "Name,Age" -a "left,center"Output
| Product | Price | |:-------------|------:| | Item | $10 | | Another Item | $20 |
## API Documentation
### `generateTable(data, options)`
- `data`: Array of objects or 2D array
- `options`:
- `headers`: Array of header strings
- `align`: Array of alignment options ('left', 'center', 'right')
## License
MIT