Skip to content

Savage-mdtable

A library for generate markdown tables.

Installtion

npm i savage-mdtable
pnpm add savage-mdtable
yarn add savage-mdtable

Feature

  • support CJS & ESM
  • support typescript type definition
  • generate a markdown (GFM) table.

How to use

ts
import { mdtable } from 'savage-mdtable'
import type { TableOptions } from 'savage-mdtable'

const options: TableOptions = {
  header: ['A', 'B', 'C'],
  alignment: ['L', 'C', 'R'],
  rows: [
    ['1', '2', '3'],
    ['4', '5', '6'],
    ['7', '8', '9']
  ]
}

console.log(mdtable(options))

// it will be

| A | B | C |
|:--|:-:|--:|
| 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 8 |
`

Issues

Please let me know if there are any issues, click this link.

Released under the MIT License.