xw-package
v1.0.0
Published
提供了HTMLlEscape关的功能
Downloads
10
Readme
安装
npm install xw-package
导入
const xw = require("xw-package");
转义 HTML 中的特殊字符
// 待转换的 HTML 字符串
const htmlStr = '<h1 style="height:500px;">工藤新一&毛利兰</h1>';
// 调用 htmlEscape 方法进行转换
var str = xw.htmlEscape(htmlStr);
// 转换的结果:<h1 style="height:500px;">工藤新一&毛利兰</h1>
console.log(str);
还原 HTML 中的特殊字符
// 待还原的 HTML 字符串:<h1 style="height:500px;">工藤新一&毛利兰</h1>
const str2 = xw.htmlUnEscape(str);
// 还原的结果:'<h1 style="height:500px;">工藤新一&毛利兰</h1>
console.log(str2);
开源协议
ISC