escape-js
v1.0.0
Published
提供了格式化时间,HTMLEscape的功能
Downloads
11
Readme
转换说明
| html | str | | ---- | ----- | | < | < | | > | > | | & | & | | " | " |
安装
npm install escape-js -D导入
const escape = require('escape-js')转义 html 中的特殊字符
const htmlStr = '<h1 title="escape">Hello <span>HTMLEscape </span></h1>'
const str = escape.htmlEscape(htmlStr)
console.log(str)
// <h1 title="escape">Hello <span>HTMLEscape </span></h1>还原 html 中的特殊字符
const str = '<h1 title="escape">Hello <span>HTMLEscape </span></h1>'
const htmlStr = escape.htmlUnescape(str)
console.log(htmlStr)
// <h1 title="escape">Hello <span>HTMLEscape </span></h1>开源协议
遵循 ISC 开源协议
