rehype-class-names
Advanced tools
Comparing version 1.0.13 to 1.0.14
@@ -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; |
18
index.js
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" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3416
7
21
4
+ Addedunified@^10.1.2
+ Added@types/unist@2.0.11(transitive)
+ Addedbail@2.0.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedis-buffer@2.0.5(transitive)
+ Addedis-plain-obj@4.1.0(transitive)
+ Addedtrough@2.2.0(transitive)
+ Addedunified@10.1.2(transitive)
+ Addedunist-util-stringify-position@3.0.3(transitive)
+ Addedvfile@5.3.7(transitive)
+ Addedvfile-message@3.1.4(transitive)