gulp-markdown-table-to-json
A github-style-markdown table parse plugin for gulp 3/4
Special thanks to noraj
Usage
First, install gulp-markdown-table-to-json
as a development dependency:
npm install --save-dev gulp-markdown-table-to-json
Then, add it to your gulpfile.js
:
Write Some Tables in Markdown File
Boys Table
name | age | grade |
---|---|---|
John | 11 | 3 |
Bob | 13 | 4 |
Girls Table
name | age | grade |
---|---|---|
Petra | 15 | 8 |
Olivia | 14 | 7 |
source code
### Boys Table<!-- table2json:boys -->name | age| grade -----|----|-----John|11|3Bob|13|4 ### Girls Table<!-- table2json:girls -->name | age| grade | -----|----|-----Petra|15|8Olivia|14|7
Get Json
Gulp 3:
const md2json = ; gulp;
Gulp 4:
const src dest task = ;const md2json = ; ;m2jdescription = 'Markdown table to JSON'; { return ;};
Then you will get a json file named README.json with the following content:
You can also use "gulp-beautify" to beautify it:
API
md2json(tableMarker)
tableMarker
Type: RegExp
The RegExp to search for table title. Default is /<!-- *table2json:([^ -]+) *-->/
.