# @sika7/sanitize-html

> this package is html sanitize Provide.

Latest version **0.0.0** (published 2021-12-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sika7/sanitize-html
pnpm add @sika7/sanitize-html
yarn add @sika7/sanitize-html
bun add @sika7/sanitize-html
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.0 |
| Published | 2021-12-09 |
| First published | 2021-12-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 3 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | sika7 |
| Maintainers | sika7 |
| Keywords | html-sanitize, sanitize, html, whitelist, allow for each tag |

## Links

- npm: https://www.npmjs.com/package/@sika7/sanitize-html
- Repository: https://github.com/sika7/sanitize-html
- Homepage: https://github.com/sika7/sanitize-html#readme
- Issues: https://github.com/sika7/sanitize-html/issues
- npm.io page: https://npm.io/package/@sika7/sanitize-html

## Dependencies (3)

- [typescript](https://npm.io/package/typescript.md) ^4.5.2
- [@sika7/silver-html](https://npm.io/package/@sika7/silver-html.md) ^1.0.1
- [@sika7/silver-html-plugin-sanitize](https://npm.io/package/@sika7/silver-html-plugin-sanitize.md) ^1.0.2

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.0.0 (latest) — 2021-12-09

## README

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

# @sika7/sanitize-html

this package is html sanitize. You can allow the attributes of each tag.

## Usage

**Step 1:** Install plugin:

```sh
npm install --save @sika7/sanitize-html
```

**Step 2:** add a functions or plugin.

```typescript
import { sanitizeHtml } from "@sika7/sanitize-html";

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

## config

```typescript
import { allowTag } from "@sika7/sanitize-html";
const allowTags: allowTag[] = {
  {
    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'] |

---
_Source: https://npm.io/package/@sika7/sanitize-html · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
