Skip to content

Commit

Permalink
Refactor to move implementation to lib/
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 26, 2023
1 parent ae5ae09 commit 79187aa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
18 changes: 1 addition & 17 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
/**
* @typedef {import('hast').Root} Root
*
* @typedef {import('hast-util-sanitize').Schema} Options
* The sanitation schema defines how and if nodes and properties should be cleaned.
* See `hast-util-sanitize`.
* The default schema is exported as `defaultSchema`.
*/

import {sanitize as hastUtilSanitize, defaultSchema} from 'hast-util-sanitize'

/**
* Plugin to sanitize HTML.
*
* @type {import('unified').Plugin<[Options?] | Array<void>, Root, Root>}
*/
export default function rehypeSanitize(options = defaultSchema) {
// @ts-expect-error: assume input `root` matches output root.
return (tree) => hastUtilSanitize(tree, options)
}

export {defaultSchema} from 'hast-util-sanitize'
export {default} from './lib/index.js'
22 changes: 22 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @typedef {import('hast').Root} Root
*
* @typedef {import('hast-util-sanitize').Schema} Options
* The sanitation schema defines how and if nodes and properties should be cleaned.
* See `hast-util-sanitize`.
* The default schema is exported as `defaultSchema`.
*/

import {sanitize as hastUtilSanitize, defaultSchema} from 'hast-util-sanitize'

/**
* Plugin to sanitize HTML.
*
* @type {import('unified').Plugin<[Options?] | Array<void>, Root, Root>}
*/
export default function rehypeSanitize(options = defaultSchema) {
// @ts-expect-error: assume input `root` matches output root.
return (tree) => hastUtilSanitize(tree, options)
}

export {defaultSchema} from 'hast-util-sanitize'
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"main": "index.js",
"types": "index.d.ts",
"files": [
"lib/",
"index.d.ts",
"index.js"
],
Expand Down

0 comments on commit 79187aa

Please sign in to comment.