@nacho-cs/md-table
v1.0.0
Published
a lightweight package to generate tables in markdown from matrices
Downloads
1
Readme
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
andVegetables
- the second parameter is for the data
- the data is a matrix that represents the actual table (
Bananas
,Carrots
,Oranges
, andTomatoes
are the data in this case)