Wrap `remark` or `rehype` subtrees in a new container node
npm install remark-rehype-wrap> Wrap remark or rehype subtrees in a new container node.
```
npm install remark-rehype-wrap
`js
import { remark } from 'remark'
import { remarkRehypeWrap } from 'remark-rehype-wrap'
await remark().use(remarkRehypeWrap).process('
Hello, world!
')Usage
test.js for usage examples.Options
$3
A new node to use as the wrapper. e.g.
{ type: 'element', tagName: 'div' }$3
Either:
-
string: A node selector passed to unist-util-select. Nodes matching the selector create a new wrapper section.
- { selector: string, inclusive?: boolean, exclude?: string } | Property | Description |
| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
selector | A node selector passed to unist-util-select. Nodes matching the selector create a new wrapper section. |
| inclusive | Whether the start node should be included in the new wrapper section (true, default) or not (false). |
| exclude | A node selector passed to unist-util-select. Nodes matching the selector will not create a new wrapper section, even if they match selector |$3
Either:
-
string: A node selector passed to unist-util-select. Nodes matching the selector end the current wrapper section.
- { selector: string, inclusive?: boolean, exclude?: string } | Property | Description |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
selector | A node selector passed to unist-util-select. Nodes matching the selector end the current wrapper section. |
| inclusive | Whether the end node should be included in the current wrapper section (true) or not (false, default). |
| exclude | A node selector passed to unist-util-select. Nodes matching the selector will not end the current wrapper section, even if they match selector |If
end is not defined then it is set to the same as start.$3
The
transform function is passed each new wrapper node and should return a node. See test.js` for an example.