1.0.0 • Published 8 years ago

rehype-plaintext v1.0.0

Weekly downloads
6
License
BSD-3-Clause
Repository
github
Last release
8 years ago

rehype-plaintext

Output plain text from rehype.

build status

Installation

This module is installed via npm:

$ npm install rehype-plaintext

Example Usage

var rehypePlaintext = require('rehype-plaintext');

var expect = require('expect.js'),
    unified = require('unified'),
    parseHTML = require('rehype-parse'),
    inspect = require('unist-util-inspect'),
    Readable = require('stream').Readable;

var s = new Readable;
s.push('<p>Hi there <em>my friend</em> I hope you are well.</p>');
s.push(null);

var result = '';
s.pipe(unified())
.use(parseHTML)
.use(function () {
  return function (cst) {
    console.log(inspect(cst));
  }
})
.use(rehypePlaintext)
.on('data', function(s) {
  result += s;
})
.on('end', function() {
  expect(result).to.equal('Hi there my friend I hope you are well.');
  done();
})
.on('error', done);

Acknowledgements

With thanks to https://gist.github.com/blahah/bb8ee2c7695180f425f443f88fa16b79