1.0.0 • Published 10 years ago
downmark-stream v1.0.0
downmark-stream
Transform streaming Markdown to HTML, with object mode support for
YAML front-matter object (meta and data) streams.
This module uses the Marked module for processing Markdown files and expects the front-matter object returned by the front-matter module.
Installation
npm install downmark-streamUsage
Markdown processed without front-matter:
var fs = require('fs');
var DownmarkStream = require('downmark-stream');
fs.createReadStream(__dirname + '/foo.md')
.pipe(DownmarkStream())
.pipe(process.stdout);Markdown processed with front-matter:
var fs = require('fs');
var DownmarkStream = require('downmark-stream');
var fm = require('front-matter');
var through = require('through2');
fs.createReadStream(__dirname + '/foo')
.pipe(through.obj(function (chunk, enc, callback) {
var content = fm(chunk.toString());
this.push(content);
callback();
}))
.pipe(DownmarkStream(opts, { objectMode: true }))
.pipe(through.obj(function (chunk, enc, callback) {
this.push(JSON.stringify(chunk, null, 2));
callback();
}))
.pipe(process.stdout);For more examples, view the contents of the example directory.
Options
DownmarkStream(markedOptions, streamOptions)markedOptionsexpected in the same format as those provided to the Marked module.streamOptionsexpected as the standard{ objectMode: true }for object mode streams, orundefinedor{ objectMode: false}for the standardstring/buffermode stream.
License
MIT, see LICENSE for details.
1.0.0
10 years ago


