# html-escape-tool

> 提供 HTML Escape 转义及还原功能

Latest version **1.0.1** (published 2022-12-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install html-escape-tool
pnpm add html-escape-tool
yarn add html-escape-tool
bun add html-escape-tool
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-12-11 |
| First published | 2022-12-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jerry Zhou |
| Maintainers | jerry-z-j-r |
| Keywords | html, escape |

## Links

- npm: https://www.npmjs.com/package/html-escape-tool
- npm.io page: https://npm.io/package/html-escape-tool

## 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

- 1.0.1 (latest) — 2022-12-11
- 1.0.0 — 2022-12-11

## README

## 安装

```
npm install html-escape-tool
```

## 导入

```js
const htmlEs = require('html-escape-tool')
```

## 转义 HTML 字符

- `<`：`&lt;`
- `>`：`&gt;`
- `"`：`&quot;`
- `&`：`&amp;`

方法：`htmlEscape(htmlStr)`

```js
const htmlStr = '<h1 class="main">我是HTML！<span>哈&nbsp;哈</span></h1>';
let str = htmlEs.htmlEscape(htmlStr);
// &lt;h1 class=&quot;main&quot;&gt;我是HTML！&lt;span&gt;哈&amp;nbsp;哈&lt;/span&gt;&lt;/h1&gt;
```

## 还原 HTML 字符

- `&lt;`：`<`
- `&gt;`：`>`
- `&quot;`：`"`
- `&amp;`：`&`

方法：`htmlUnEscape(str)`

```js
const str = '&lt;h1 class=&quot;main&quot;&gt;我是HTML！&lt;span&gt;哈&amp;nbsp;哈&lt;/span&gt;&lt;/h1&gt;';
let htmlStr = htmlEs.htmlUnEscape(str);
// <h1 class="main">我是HTML！<span>哈&nbsp;哈</span></h1>
```

## 开源协议

ISC

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