@openinf/util-md-table
Common Markdown table-related utilities
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. As is the case with any
software project in continuous development, omissions and errors may exist, for
which contributions are welcome.
Installation
@openinf/util-md-table
runs on Node.js and is available via npm
.
npm install @openinf/util-md-table
Usage
import { mdTable2json } from '@openinf/util-md-table';
const sampleTable = [
'| Col1 | Col2 | Col3 | Col4 |',
'|:-----:|:-----:|:-----:|:-----:|',
'| one | two | three | four |',
'| Fee | Fie | Foe | Fum |',
].join('\n');
const sampleTableObject = mdTbl2json(sampleTable, (v) => v.toLowerCase());
console.log(sampleTableObject);
[
{ col1: 'one', col2: 'two', col3: 'three', col4: 'four' },
{ col1: 'fee', col2: 'fie', col3: 'foe', col4: 'fum' }
]
Array.<Object>
mdTbl2json(mdTbl, cellTransform, attribCellTransform) ⇒ 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. |
© The OpenINF Authors