downmark-stream
v1.0.0
Published
Transform streaming Markdown to HTML, with `object mode` support for YAML front-matter meta streams
Downloads
4
Maintainers
Readme
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-stream
Usage
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)
markedOptions
expected in the same format as those provided to the Marked module.streamOptions
expected as the standard{ objectMode: true }
for object mode streams, orundefined
or{ objectMode: false}
for the standardstring
/buffer
mode stream.
License
MIT, see LICENSE for details.