Reputation: 111
i want to convert a readme file to json using "gulp-markdown-to-json". When i run gulp from the command line i get 'TypeError: md2json.parse is not a function'.
here are my dependencies
"devDependencies": {
"browserify": "^14.1.0",
"gulp-install": "^0.6.0",
"gulp-markdown-to-json": "^1.0.3",
"watchify": "^3.9.0"
},
"dependencies": {
"gulp": "^3.9.1",
"jquery": "^3.1.1",
"watchify": "^3.9.0"
}
gulp.js
var gulp = require('gulp');
var md2json = require('gulp-markdown-to-json');
gulp.task('default', function() {
return gulp.src('test.md')
.pipe(md2json.parse())
.pipe(gulp.dest('.'));
})
Upvotes: 0
Views: 753
Reputation: 1599
I think you are mixing two things up here:
According to the #usage of gulp-markdown-to-json:
const gulp = require('gulp');
const markdownToJSON = require('gulp-markdown-to-json');
const marked = require('marked');
marked.setOptions({
pedantic: true,
smartypants: true
});
gulp.task('markdown', () => {
gulp.src('./content/**/*.md')
.pipe(markdownToJSON(marked))
.pipe(gulp.dest('.'))
});
There's no md2json.parse()
in the above example.
There are a few markdown parsers available, but you have to try them to see which one (with proper configs) fits your needs best.
The output from the document indicates the marked
parser outputs html in body
, and this may not be your desired result:
{
"slug": "bushwick-artisan",
"title": "Wes Anderson pop-up Bushwick artisan",
"layout": "centered",
"body": "<h2 id="yolo">YOLO</h2>\n<p>Chia quinoa meh, you probably haven't heard of them sartorial Holowaychuk pickled post-ironic. Plaid ugh vegan, Sixpoint 8-bit sartorial artisan semiotics put a bird on it Mission bicycle rights Club-Mate vinyl.</p>",
"updatedAt": "1970-01-01T00:00:00Z"
}
Upvotes: 1