downmark-stream

    1.0.0 • Public • Published

    downmark-stream

    npm npm version travis stable

    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, or undefined or { objectMode: false} for the standard string/buffer mode stream.

    License

    MIT, see LICENSE for details.

    Install

    npm i downmark-stream

    DownloadsWeekly Downloads

    0

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • akiva