Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@sika7/silver-html-plugin-sanitize

sika713MIT1.0.2TypeScript support: included

silver-html plugin for sanitize.

html-sanitize, silver-html-plugin, silver-html

readme

License: MIT Test

@sika7/silver-html-plugin-sanitize

this package is silver-html plugin

Usage

Step 1: Install plugin:

npm install --save @sika7/silver-html
npm install --save @sika7/silver-html-plugin-sanitize

Step 2: add a functions or plugin.

import { silverHtml } from '@sika7/silver-html'
import { silverHtmlSanitize } from "@sika7/silver-html-plugin-sanitize";

const result = silverHtml("<div><p>test</p><div>test</div></div>", {}, [
silverHtmlSanitize({
  allowTags: [
    {
      tag: "div",
      allowAttrs: ["class", "style"],
      allowStyle: ["color"],
    },
  ],
})]);
console.log(result)
// # <div><div>test</div></div>

config

const plugin = {
  allowTags: [
    {
      tag: "div", // require
      allowAttrs: ["class", "style"], // options
      allowStyle: ["color"],          // options
    },
  ]
}
setting description example
tag allow tag name. div
allowAttrs allow attributes. ['class','style']
allowStyle allow styles. require style in allowAttrs. ['color','text-align']

changelog

Change Log

[Unreleased]

1.0.2 - 2021-12-09

Fixed

  • Fix type mis for arrow -> allow

1.0.1 - 2021-12-09

Fixed

  • Fix package.json index.js path

1.0.0 - 2021-12-08

Added

  • Delete function for unauthorized tags
  • Delete function for unauthorized attributes
  • Delete function of styles that are not allowed
  • Add README.md

This project adheres to Semantic Versioning.