Socket
Book a DemoInstallSign in
Socket

remark-rehype-wrap

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-rehype-wrap

Wrap `remark` or `rehype` subtrees in a new container node

latest
Source
npmnpm
Version
0.0.5
Version published
Weekly downloads
3K
36.04%
Maintainers
1
Weekly downloads
 
Created
Source

remark-rehype-wrap

Wrap remark or rehype subtrees in a new container node.

Installation

npm install remark-rehype-wrap
import { remark } from 'remark'
import { remarkRehypeWrap } from 'remark-rehype-wrap'

await remark().use(remarkRehypeWrap).process('<p>Hello, world!</p>')

Usage

See test.js for usage examples.

Options

options.node

A new node to use as the wrapper. e.g. { type: 'element', tagName: 'div' }

options.start

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 }

    PropertyDescription
    selectorA node selector passed to unist-util-select. Nodes matching the selector create a new wrapper section.
    inclusiveWhether the start node should be included in the new wrapper section (true, default) or not (false).
    excludeA node selector passed to unist-util-select. Nodes matching the selector will not create a new wrapper section, even if they match selector

options.end (optional)

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 }

    PropertyDescription
    selectorA node selector passed to unist-util-select. Nodes matching the selector end the current wrapper section.
    inclusiveWhether the end node should be included in the current wrapper section (true) or not (false, default).
    excludeA 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.

options.transform (optional)

The transform function is passed each new wrapper node and should return a node. See test.js for an example.

Keywords

mdx

FAQs

Package last updated on 01 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts