2.1.5 • Published 2 years ago

@codesync/kses v2.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years 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

2 years ago

2.1.1

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.5

2 years ago

2.0.12

2 years ago

2.0.11

2 years ago

2.0.10

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago