0.1.0 • Published 7 years ago

gulp-markrun v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
7 years ago

gulp-markrun

建议自己封装 gulp 插件 ,这样能更加灵活的使用 markrun

var gutil = require('gulp-util')
var markrun = require('markrun')
var through = require('through2')
function markrunCompile () {
    return through.obj(function (file, enc, cb) {
        if (file.isNull()) {
            this.push(file)
            return cb()
        }
        if (file.isStream()) {
            this.emit('error', new gutil.PluginError('markrun', 'Streaming not supported'))
            return cb()
        }
        var content = file.contents.toString()
        content = markrun(content)
        file.path = gutil.replaceExtension(file.path, '.html');
        file.contents = new Buffer(content);
        this.push(file)
        cb()
    })
}

gulp.src(src)
        .pipe(markrunCompile())
        .pipe(gulp.dest(dest))