diff --git a/index.js b/index.js index 937f713..cc769de 100644 --- a/index.js +++ b/index.js @@ -9,29 +9,29 @@ module.exports = remark2retext; * with the new NLCST tree (bridge-mode). * If a parser is given, returns the NLCST tree: further * plug-ins run on that tree (mutate-mode). */ -function remark2retext(destination) { +function remark2retext(destination, options) { var fn = destination && destination.run ? bridge : mutate; - return fn(destination); + return fn(destination, options); } /* Mutate-mode. Further transformers run on the NLCST tree. */ -function mutate(parser) { +function mutate(parser, options) { return transformer; function transformer(node, file) { - return mdast2nlcst(node, file, parser); + return mdast2nlcst(node, file, parser, options); } } /* Bridge-mode. Runs the destination with the new NLCST * tree. */ -function bridge(destination) { +function bridge(destination, options) { return transformer; function transformer(node, file, next) { var Parser = destination.freeze().Parser; - var tree = mdast2nlcst(node, file, Parser); - - destination.run(tree, file, function (err) { + var tree = mdast2nlcst(node, file, Parser, options); + destination.run(tree, file, done); + function done(err) { next(err); - }); + } } } diff --git a/package.json b/package.json index 92487cc..e14c48a 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "index.js" ], "dependencies": { - "mdast-util-to-nlcst": "^3.0.0" + "mdast-util-to-nlcst": "^3.2.0" }, "devDependencies": { "browserify": "^14.0.0", diff --git a/readme.md b/readme.md index e619e37..b0271a2 100644 --- a/readme.md +++ b/readme.md @@ -50,7 +50,7 @@ example.md ## API -### `origin.use(remark2retext, destination)` +### `origin.use(remark2retext, destination[, options])` Either bridge or mutate from [**remark**][remark] ([MDAST][]) to [**retext**][retext] ([NLCST][]). @@ -68,6 +68,10 @@ If a parser (such as [**parse-latin**][latin], [**parse-english**][english], or [**parse-dutch**][dutch]) is given, passes the tree to further plug-ins (mutate-mode). +###### `options` + +Passed to [`mdast-util-to-nlcst`][to-nlcst]. + ## Related * [`rehype-retext`](https://github.com/wooorm/rehype-retext) @@ -76,6 +80,8 @@ plug-ins (mutate-mode). — Transform markdown to HTML * [`rehype-remark`](https://github.com/wooorm/rehype-remark) — Transform HTML to markdown +* [`mdast-util-to-nlcst`][to-nlcst] + — Underlying algorithm ## License @@ -114,3 +120,5 @@ plug-ins (mutate-mode). [english]: https://github.com/wooorm/parse-english [dutch]: https://github.com/wooorm/parse-dutch + +[to-nlcst]: https://github.com/syntax-tree/mdast-util-to-nlcst