Skip to content

Commit 77ef216

Browse files
authored
Add exports of one, all helpers
These helper functions are useful when writing custom handlers. Closes GH-54. Reviewed-by: Titus Wormer <[email protected]>
1 parent 2e1b967 commit 77ef216

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
export {all} from './lib/all.js'
2+
export {one} from './lib/one.js'
13
export {toHast} from './lib/index.js'

readme.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Which when running with `node example` yields:
5454

5555
## API
5656

57-
This package exports the following identifiers: `toHast`.
57+
This package exports the following identifiers: `toHast`, `all`, `one`
5858
There is no default export.
5959

6060
### `toHast(node[, options])`
@@ -217,6 +217,18 @@ Yields, in [hast][] (**note**: the `pre` and `language-js` class are normal
217217
}
218218
```
219219

220+
### `all(h, parent)`
221+
222+
Helper function for writing custom handlers passed to `options.handlers`.
223+
Pass it `h` and a parent node (mdast) and it will turn the node’s children into
224+
an array of transformed nodes (hast).
225+
226+
### `one(h, node, parent)`
227+
228+
Helper function for writing custom handlers passed to `options.handlers`.
229+
Pass it `h`, a `node`, and its `parent` (mdast) and it will turn `node` into
230+
hast content.
231+
220232
## Security
221233

222234
Use of `mdast-util-to-hast` can open you up to a

0 commit comments

Comments
 (0)