The high-level goal of @openinf/util-md-table
is to serve as a Node.js package
containing utilities for common operations on Markdown tables allowing users
to make use of them in new ways. We are constantly working to improve this
repository, so please feel free to contribute if you notice any
omissions or errors.
Thanks!
Supported Node.js Environments
- v4:Argon (Ar)
- v6:Boron (B)
- v8:Carbon (C)
- v10:Dubnium (Db)
- v12:Erbium (Er)
- v14:Fermium (Fm)
- v16:Gallium (Ga)
- v18:Hydrogen (H)
@openinf/util-md-table
runs on
supported versions of Node.js and is available via
npm
, pnpm
, or yarn
.
Using the npm CLI
See the official documentation for this command for more information.
npm i @openinf/util-md-table
Using the pnpm CLI
See the official documentation for this command for more information.
pnpm add @openinf/util-md-table
Using the Yarn 1 CLI (Classic)
See the official documentation for this command for more information.
yarn add @openinf/util-md-table
import { mdTbl2json } from '@openinf/util-md-table';
const sampleTable = [
'| Col1 | Col2 | Col3 | Col4 |',
'|:-----:|:-----:|:-----:|:-----:|',
'| one | two | three | four |',
'| Fee | Fie | Foe | Fum |',
].join('\n');
const sampleTblObject = mdTbl2json(sampleTable, (v) => v.toLowerCase());
console.log(sampleTblObject);
[
{ col1: 'one', col2: 'two', col3: 'three', col4: 'four' },
{ col1: 'fee', col2: 'fie', col3: 'foe', col4: 'fum' }
]
This API will be deprecated in the next release in favor of one that follows Web Platform Design Principles.
Kind: global function
Param | Type | Description |
---|---|---|
mdTbl | string |
A markdown table as a string. |
cellTransform | function | undefined |
A function run on contents of each cell. |
attribCellTransform | function | undefined |
A transform only for attribute cells. |
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. If for whatever reason you spot something to fix but cannot patch it yourself, please open an issue.
This project is licensed under either of
at your option.
The SPDX license identifier for this project is
MIT OR Apache-2.0
.
If you like the project (or want to bookmark it) —
— give it a star ⭐️ — it will greatly encourage
us.