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 - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

index.ts

28

index.js

@@ -1,18 +0,16 @@

import { selectAll } from "hast-util-select";
export default (additions) => {
const adders = Object.entries(additions).map(adder);
return (node) => adders.forEach((a) => a(node));
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const hast_util_select_1 = require("hast-util-select");
exports.default = (additions) => {
const adders = Object.entries(additions).map((property) => adder(property));
return (node) => adders.forEach((a) => a(node));
};
const adder = ([selector, className]) => {
const writer = write(className);
return (node) => selectAll(selector, node).forEach(writer);
return (node) => (0, hast_util_select_1.selectAll)(selector, node).forEach((elem) => {
var _a;
if (!((_a = elem === null || elem === void 0 ? void 0 : elem.properties) === null || _a === void 0 ? void 0 : _a.className))
elem.properties = { className };
else
elem.properties.className += ` ${className}`;
});
};
const write =
(className) =>
({ properties }) => {
if (!properties.className) properties.className = className;
else properties.className += ` ${className}`;
};
{
"name": "rehype-class-names",
"version": "1.0.1",
"version": "1.0.2",
"description": "A utility plugin to use with rehype that adds class names to HAST (html tree)",

@@ -27,3 +27,6 @@ "main": "index.js",

"hast-util-select": "^5.0.5"
},
"devDependencies": {
"typescript": "^4.9.4"
}
}
# Rehype Class Names
Adding classes to elements with rehype. All credit goes to [rehype-add-classes](https://github.com/martypdx/rehype-add-classes) but with fixed dependencies plus I wanted to make an npm package :shrug:.
Adding classes to elements with rehype. All credit goes to [rehype-add-classes](https://github.com/martypdx/rehype-add-classes) but with fixed dependencies, added typescript support, plus I wanted to make an npm package :shrug:.

@@ -5,0 +5,0 @@ ## Installation

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