From 613bd1067685f171b93f251dee3267393fc8c8a5 Mon Sep 17 00:00:00 2001 From: Ignatius Reza Date: Thu, 20 May 2021 09:13:05 +0200 Subject: [PATCH] re-export all and one from index.js these helper functions are useful when writting custom handlers --- index.js | 2 ++ readme.md | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 01e829a..17794f1 100644 --- a/index.js +++ b/index.js @@ -1 +1,3 @@ +export {all} from './lib/all.js' +export {one} from './lib/one.js' export {toHast} from './lib/index.js' diff --git a/readme.md b/readme.md index 1db4a47..1dd9904 100644 --- a/readme.md +++ b/readme.md @@ -54,7 +54,7 @@ Which when running with `node example` yields: ## API -This package exports the following identifiers: `toHast`. +This package exports the following identifiers: `toHast`, `all`, `one` There is no default export. ### `toHast(node[, options])` @@ -217,6 +217,18 @@ Yields, in [hast][] (**note**: the `pre` and `language-js` class are normal } ``` +### `all(h, parent)` + +Helper function for writing custom handlers passed to `options.handlers`. +Pass it `h` and a parent node (mdast) and it will turn the node’s children into +an array of transformed nodes (hast). + +### `one(h, node, parent)` + +Helper function for writing custom handlers passed to `options.handlers`. +Pass it `h`, a `node`, and its `parent` (mdast) and it will turn `node` into +hast content. + ## Security Use of `mdast-util-to-hast` can open you up to a