https://github.com/jozefini/codesync-kses
Equivalent helper `wp_kses` written in JavaScript
https://github.com/jozefini/codesync-kses
html sanitizer xss
Last synced: 7 months ago
JSON representation
Equivalent helper `wp_kses` written in JavaScript
- Host: GitHub
- URL: https://github.com/jozefini/codesync-kses
- Owner: jozefini
- Created: 2024-03-07T19:22:47.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-08T14:36:53.000Z (over 1 year ago)
- Last Synced: 2025-03-08T16:36:37.947Z (7 months ago)
- Topics: html, sanitizer, xss
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@codesync/kses
- Size: 143 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
### Equivalent of `wp_kses` / `wp_kses_post` in JavaScript/Node.js
Safely render HTML in React or any other JavaScript environment.
Works in both Node.js and the browser.#### Example JavaScript
```typescript
import { kses } from '@codesync/kses'const unsafeHtml = 'Test parseralert("hello")'
const safeHtml = kses(unsafeHtml)
// Output: Test parser
```#### Example React
```typescript
'use client'
import { kses } from '@codesync/kses'export default function ClientPage() {
const unsafeHtml =
'Test parseralert("hello")'
const safeHtml = kses(unsafeHtml)// Output:
Test parser
return
}
```#### Example RSC
```typescript
import { kses } from '@codesync/kses/server'export default function ServerPage() {
const unsafeHtml =
'Test parseralert("hello")'
const safeHtml = kses(unsafeHtml)// Output:
Test parser
return
}
```