我试图获取一个输入标记文件,通过两个不同的呈现器运行它,并将输出保存到不同的文件夹中。我的计划是使用区块引号来防止特定内容在其中一个输出中呈现。这是我的吞咽文件:
var gulp = require('gulp'),
marked = require('marked'),
markdown = require('gulp-markdown'),
cache = require('gulp-cached'),
lazypipe = require('lazypipe'),
merge = require('merge-stream');
gulp.task('markdown', function () {
// setup mlive
var mlive_renderer = new marked.Renderer();
mlive_renderer.blockquote = function (quote) {
return quote;
};
var mliveTasks = lazypipe()
.pipe(markdown, {
renderer: mlive_renderer
});
// setup hudsonvilleathletics
var hudsonvilleathleics_renderer = new marked.Renderer();
hudsonvilleathleics_renderer.blockquote = function(){ return ''; };
var hudsonvilleathleticsTasks = lazypipe()
.pipe(markdown, {
renderer: hudsonvilleathleics_renderer
});
// create out pipe of src content
var sources = gulp.src('src/**/*.md')
.pipe(cache('markdown'));
var mlive = sources
.pipe(mliveTasks())
.pipe(gulp.dest('mlive'));
var hudsonvilleathletics = sources
.pipe(hudsonvilleathleticsTasks())
.pipe(gulp.dest('hudsonvilleathletics'));
return merge(mlive, hudsonvilleathletics);
});运行此操作时不会出现错误,但这两个内容都是相同的,并且附加的p标记被包装在标题周围。如果我将其中一个注释掉,然后返回另一个,它就能正常工作。
我做错了什么?
输入文件:
## This is a heading
> This is mlive only stuff
Here's some other stuff for both.
> one more for mlive和输出(两者相同)
<p><h2 id="this-is-a-heading">This is a heading</h2></p>
<p>This is mlive only stuff</p>
<p>Here's some other stuff for both.</p>
<p>one more for mlive</p>发布于 2015-10-04 19:38:47
经过更多的挖掘,我无意中发现了gulp-mirror,并设法做到了这一点。使用它,我能够将目标调用移动到延迟类型,然后将源映射到它们。下面是新的gulpfile (通过额外的调整从标题中删除ids )
var gulp = require('gulp'),
marked = require('marked'),
markdown = require('gulp-markdown'),
cache = require('gulp-cached'),
lazypipe = require('lazypipe'),
mirror = require('gulp-mirror');
gulp.task('markdown', function () {
// start of by removing the id's for headings
var heading = function (text, level) {
return '<h' + level + '>' + text + '</h' + level + '>\n';
};
/*
* mLive Setup
*
* convert any block quotes back to regular old p tags and save in the mlive folder
*/
var mliveRenderer = new marked.Renderer();
mliveRenderer.heading = heading;
mliveRenderer.blockquote = function(quote){
return quote;
};
var mliveTasks = lazypipe()
.pipe(markdown, {
renderer: mliveRenderer
})
.pipe(gulp.dest, 'mlive/');
/*
* HudsonvilleAthletics Setup
*
* completely remove anything in block quotes and save to the other folder
*/
var hudsonvilleathleticsRenderer = new marked.Renderer();
hudsonvilleathleticsRenderer.heading = heading;
hudsonvilleathleticsRenderer.blockquote = function(){
return '';
};
var hudsonvilleathleticsTasks = lazypipe()
.pipe(markdown, {
renderer: hudsonvilleathleticsRenderer
})
.pipe(gulp.dest, 'hudsonvilleathletics/');
/*
* Finally run everything
*/
return sources = gulp.src('src/**/*.md')
.pipe(cache('markdown'))
.pipe(mirror(
mliveTasks(),
hudsonvilleathleticsTasks()
));
});https://stackoverflow.com/questions/32931486
复制相似问题