
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
rehype-wrapper
Advanced tools
A simple rehype plugin that wraps the entire Markdown HTML output in a new container element. This is useful when you need to add custom styling, JavaScript functionality, or other attributes to the entire Markdown content as a unit.
npm install rehype-wrapper
# or
yarn add rehype-wrapper
# or
pnpm add rehype-wrapper
import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkRehype from 'remark-rehype';
import rehypeStringify from 'rehype-stringify';
import rehypeWrapper from 'rehype-wrapper';
const processor = unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeWrapper, {
className: 'my-content',
tagName: 'article',
attributes: {
id: 'content-wrapper',
'data-generated': 'true'
}
})
.use(rehypeStringify);
const markdown = '# Hello\n\nThis is a paragraph.';
processor.process(markdown)
.then((file) => {
console.log(file.toString());
// <article class="my-content" id="content-wrapper" data-generated="true">
// <h1>Hello</h1>
// <p>This is a paragraph.</p>
// </article>
});
classNameType: string
Default: 'markdown'
The CSS class name to apply to the wrapper element.
tagNameType: string
Default: 'div'
The HTML tag to use for the wrapper element. Can be any valid HTML element like 'div', 'section', 'article', 'main', etc.
attributesType: Record<string, string | number | boolean>
Default: {}
Additional HTML attributes to add to the wrapper element.
.use(rehypeWrapper)
Output:
<div class="markdown">
<!-- Markdown content -->
</div>
.use(rehypeWrapper, { tagName: 'section' })
Output:
<section class="markdown">
<!-- Markdown content -->
</section>
.use(rehypeWrapper, {
tagName: 'article',
className: 'blog-post',
attributes: {
'itemscope': true,
'itemtype': 'http://schema.org/BlogPosting'
}
})
Output:
<article class="blog-post" itemscope itemtype="http://schema.org/BlogPosting">
<!-- Markdown content -->
</article>
// next.config.js
import rehypeWrapper from 'rehype-wrapper';
const nextConfig = {
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'],
experimental: {
mdxRs: true,
},
};
const withMDX = createMDX({
options: {
remarkPlugins: [],
rehypePlugins: [
[rehypeWrapper, {
tagName: 'article',
className: 'prose lg:prose-xl dark:prose-invert'
}]
],
},
});
export default withMDX(nextConfig);
// gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-mdx`,
options: {
rehypePlugins: [
[require('rehype-wrapper'), {
tagName: 'main',
className: 'article-content'
}]
],
},
},
],
};
MIT
FAQs
A rehype plugin that wraps the entire markdown HTML in a new div
We found that rehype-wrapper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.