
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
rehype-decorate
Advanced tools

Add CSS classes to Markdown using Rehype
rehype-decorate lets you add CSS classnames to Markdown.
# This is markdown
<!-- {.large-heading} -->
The `h1` above will have a CSS class name `large-heading` applied to it. We do
this without extending Markdown syntax. The HTML comment will be invisible
where regular Markdown parsers can't see it, making your Markdown render just
as normal Markdown.
Cool, isn't it?
yarn add rehype-decorate@next
rehype-decorate works with Rehype syntax trees. These can be generated by many tools, including the Remark Markdown parser. It exposes a function, decorate(), which takes in a HAST tree, and exports a HAST tree as well:
import decorate from 'rehype-decorate'
htmlAst = decorate(htmlAst)
Here's an example using unified, which parses Markdown via Remark, converts it to Rehype format via remark2rehype, uses rehype-decorate, then converts it to a string via rehype-stringify:
import decorate from 'rehype-decorate'
import unified from 'unified'
import stream from 'unified-stream'
import markdown from 'remark-parse'
import remark2rehype from 'remark-rehype'
import html from 'rehype-stringify'
processor = unified()
.use(markdown)
.use(remark2rehype)
.use(decorate)
.use(html)
const input = '# hello world\n\n<!-- {.heading} -->'
processor.process(input, (err, file) => {
console.log(String(file))
})
rehype-decorate © 2018+, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors (list).
Thanks to Chaparra for the icon.
ricostacruz.com · GitHub @rstacruz · Twitter @rstacruz
FAQs
Add CSS classes to Markdown using Rehype
We found that rehype-decorate demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.