Created
November 2, 2017 13:29
-
-
Save davidhund/fdd825bdd63b7d33ce91ffbd5fc5af62 to your computer and use it in GitHub Desktop.
retext example does not work as expected w.r.t. remark example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var unified = require('unified'); | |
var createStream = require('unified-stream'); | |
var parse = require('rehype-parse'); | |
var rehype2retext = require('rehype-retext'); | |
var rehype2remark = require('rehype-remark'); | |
var remarkStringify = require('remark-stringify'); | |
var retextStringify = require('retext-stringify'); | |
var english = require('retext-english'); | |
// Why does the following (2remark) work (output MD) | |
// | |
// var processor = unified() | |
// .use(parse) | |
// .use(rehype2remark) | |
// .use(remarkStringify); | |
// | |
// .. but this (2retext) does NOT work (not outputting text) | |
var processor = unified() | |
.use(parse) | |
.use(rehype2retext, unified() | |
.use(english) | |
) | |
.use(retextStringify); | |
process.stdin.pipe(createStream(processor)).pipe(process.stdout); | |
// `TypeError: Cannot read property 'length' of undefined at nlcstToString..` | |
// Ran as | |
// curl https://example.com 2>/dev/null | node retext-stream-example.js | |
// Also: why is the additional `unified().use(english)` needed for retext? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment