Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rehype-class-names

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rehype-class-names

A utility plugin to use with rehype that adds class names to HAST (html tree)

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
51K
increased by15.2%
Maintainers
1
Weekly downloads
 
Created
Source

Rehype Class Names

Adding classes to elements with rehype. Includes typescript support

Installation

npm install rehype-class-names

API

rehype().use(addClasses, additions])

Add to rehype or unified pipeline with .use, where additions is an object with keys that are the css selectors and the values are the classes you want to add.

For more information on what keys you can pass, see the hast-util-select documentation. For more information on what values you can pass, see the hast-util-classnames documentation.

Example:

.use(addClasses, {
    'h1,h2,h3': 'title',
    h1: 'is-1',
    h2: 'is-2',
    h3: { 'hello': false, 32: true },
    h4: 10,
    h5: [],
    p: 'one two',
    a: "test",
    ol: "list-decimal",
    li: ['test', 'mega'],
})

This will output

<h1 class="title is-1">header</h1>
<h2 class="title is-2">sub 2</h2>
<h3 class="title 32">sub 3</h3>
<h4 class="10">sub 4</h4>
<h5 class="">Sub 5</h5>
<p class="one two">
  Profile pictures are important.
  <a href="riderjensen.com" class="test">Rider Jensen</a>
</p>
<ol class="list-decimal">
  <li class="test mega">Create a Github repository</li>
  <li class="test mega">Pushed up code</li>
  <li class="test mega">Connect account to Github</li>
</ol>

Keywords

FAQs

Package last updated on 25 Mar 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc