@nacho-cs/md-table

1.0.0 • Public • Published

md-table

a lightweight package to generate tables in markdown from matrices

to add

  • first install the package using npm, the add it using the ESM syntax (import)
  • commonJS syntax is not supported (require)
import mdTable from "@nacho-cs/md-table";

to use

import mdTable from "@nacho-cs/md-table";
const labels = ["Fruits", "Vegetables"];
const data = [
  ["Bananas", "Carrots"],
  ["Oranges", "Tomatoes"],
];
const table = mdTable(labels, data);
console.log(table);
// | Fruits  | Vegetables |
// |---------|------------|
// | Bananas | Carrots    |
// | Oranges | Tomatoes   |
  • the first parameter for mdTable is the label for the table
  • in this case, the labels are Fruits and Vegetables
  • the second parameter is for the data
  • the data is a matrix that represents the actual table (Bananas, Carrots, Oranges, and Tomatoes are the data in this case)

Package Sidebar

Install

npm i @nacho-cs/md-table

Weekly Downloads

3

Version

1.0.0

License

ISC

Unpacked Size

2.42 kB

Total Files

3

Last publish

Collaborators

  • nacho-cs