2.1.5 • Published 1 year ago

@codesync/kses v2.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

import { kses } from '@codesync/kses'

const unsafeHtml = '<strong>Test parser</strong><script>alert("hello")</script>'
const safeHtml = kses(unsafeHtml)
// Output: <strong>Test parser</strong>

Example React

'use client'
import { kses } from '@codesync/kses'

export default function ClientPage() {
  const unsafeHtml =
    '<strong>Test parser</strong><script>alert("hello")</script>'
  const safeHtml = kses(unsafeHtml)

  // Output: <div><strong>Test parser</strong></div>
  return <div dangerouslySetInnerHTML={{ __html: safeHtml }} />
}

Example RSC

import { kses } from '@codesync/kses/server'

export default function ServerPage() {
  const unsafeHtml =
    '<strong>Test parser</strong><script>alert("hello")</script>'
  const safeHtml = kses(unsafeHtml)

  // Output: <div><strong>Test parser</strong></div>
  return <div dangerouslySetInnerHTML={{ __html: safeHtml }} />
}
2.1.2

1 year ago

2.1.1

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.5

1 year ago

2.0.12

1 year ago

2.0.11

1 year ago

2.0.10

1 year ago

2.0.9

1 year ago

2.0.8

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.0

1 year ago