gulp


gulp markdown to separate renderers and destinations


I'm attempting to take an input markdown file, run it through 2 different renderers, and save the output to different folders. My plan is to use blockquotes to keep specific content from rendering in one of the outputs. Here's my gulp file:
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);
});
Running this completes without errors, but both contents are identical, and have additional p tags wrapped around headings. If I comment out one and just return the other it works fine.
What am I doing wrong?
input file:
## This is a heading
> This is mlive only stuff
Here's some other stuff for both.
> one more for mlive
and the output (identical for both)
<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>
After a lot more digging I stumbled upon gulp-mirror and have managed to get this working. Using that I was able to move the destination calls to the lazypipes, and then mirror the sources to them. Here's the new gulpfile (with an additional tweak to remove ids from headings)
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()
));
});

Related Links

Gulp Browserify SourceMaps
What is the purpose(s) of JavaScript build tools
gulp-jshint utters errors when using browserify
Gulp “watch” is not running the sub task “sass” on file change
Proxy URL not working with BrowserSync Gulp task
the task can't be called by watch module.
I can't get the data-uri() function to work on gulp.js to base64 an image on mac
How to inject bower dependencies in karma.conf.js file with gulp?
Getting Libsass Gulp Susy to work together
Gulp compass without config.rb
gulp-webserver: Default to index.html if available, else show directories
gulp-uglify notify on failing build
Declaring optional dependencies
gulp html minification error
Can an IIFE be added to a browserify bundle?
Gulp: Error Messages and Notifications with Plumber

Categories

HOME
oop
azure-documentdb
stata
stanford-nlp
cors
x86-64
stdout
okhttp3
query-string
css-selectors
richtextbox
gnuradio
qt4
obd-ii
facebook-sharer
repeater
appsettings
accordion
django-rest-auth
summernote
connectiq
ppp
checkmarx
r-factor
wercker
voyager
google-chrome-console
jquery-ui-slider
uitextview
definition
peerjs
nshttpurlresponse
scrapinghub
amazon-fire-tv
ajv
webmatrix
dmalloc
blackberry
disassembly
android-music-player
computed-properties
strtol
qtruby
angularfire
boost-bind
database-administration
phpdesigner
archiva
alchemy
web-performance
maven-antrun-plugin
mojolicious
first-order-logic
autoscaling
firewire
radgrid
crystal-reports-7
dojox.grid
react-os
breeze-sharp
dirname
parsefloat
scjp
switchpreference
xpand
ant-contrib
sendy
nodeunit
sqldatasource
new-operator
class-library
fastcgi-mono-server
kuka-krl
flask-mongoengine
nativequery
imaplib
code-complete
myrrix
wordbreaker
ftpwebrequest
esi
motordriver
databus
socketasynceventargs
datasheet
mvcmailer
mysql-connector
capitalization
backlight
file-processing
noise-reduction
fxcopcmd
rollover
subdirectories
dongle
atmega16
software-update
memory-consumption
paperless

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App