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.13 to 1.0.14

12

index.d.ts

@@ -1,6 +0,8 @@

import { Nodes } from 'hast';
interface IncomingProperties {
[ElementName: string]: string;
import { Plugin } from 'unified';
import { Root } from 'hast';
import { Conditional } from 'hast-util-classnames';
export interface Options {
[selector: string]: Conditional;
}
declare const _default: (additions: IncomingProperties) => (node: Nodes) => void;
export default _default;
declare const rehypeClassNames: Plugin<[(Options | null | undefined)?], Root>;
export default rehypeClassNames;
import { selectAll } from "hast-util-select";
import { classnames } from 'hast-util-classnames';
export default (additions) => {
const adders = Object.entries(additions).map((property) => adder(property));
return (node) => adders.forEach((a) => a(node));
const rehypeClassNames = (additions) => {
return (tree) => {
if (additions)
Object.entries(additions).map(([selector, cName]) => {
return (nodes) => selectAll(selector, nodes).forEach((elem) => {
classnames(elem, cName);
});
}).forEach((a) => a(tree));
};
};
const adder = ([selector, cName]) => {
return (nodes) => selectAll(selector, nodes).forEach((elem) => {
classnames(elem, cName);
});
};
export default rehypeClassNames;
{
"name": "rehype-class-names",
"version": "1.0.13",
"version": "1.0.14",
"description": "A utility plugin to use with rehype that adds class names to HAST (html tree)",

@@ -13,4 +13,3 @@ "main": "index.js",

"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"build": "./node_modules/typescript/bin/tsc",
"publish": "npm version minor && npm publish"
"build": "./node_modules/typescript/bin/tsc"
},

@@ -36,3 +35,4 @@ "type": "module",

"hast-util-classnames": "^3.0.0",
"hast-util-select": "^6.0.0"
"hast-util-select": "^6.0.0",
"unified": "^10.1.2"
},

@@ -46,5 +46,4 @@ "devDependencies": {

"remark-rehype": "^10.1.0",
"typescript": "^5.1.6",
"unified": "^10.1.2"
"typescript": "^5.1.6"
}
}
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