html-tag-format

1.0.0 • Public • Published

1. 安装

npm install html-tag-format

2. 导入

const htmlTagGormat = require('html-tag-format')

3. 格式化时间

//调用dateFormat对世界进行格式化
const date = tools.dateFormat(new Date());
console.log(date) //2022-05-24 16:50:40

4. 转义html中的特殊字符

const htmlStr1 = '<h1 title="标题"> 这是H1标签<span>123&nbsp ;</span></h1>'
const str1 = tools.htmlEscape(htmlStr1)
console.log(str1)
//结果 &lt;h1 title=&quot;标题&quot;&gt; 这是H1标签&lt;span&gt;123&amp;nbsp ;&lt;/span&gt;&lt;/h1&gt;

5. 还原HTML特殊字符

const htmlStr2 = '&lt;h1 title=&quot;标题&quot;&gt; 这是H1标签&lt;span&gt;123&amp;nbsp ;&lt;/span&gt;&lt;/h1&gt;'
const str2 = tools.htmlUnEscape(htmlStr2)
console.log(str2)

6. 开源协议

ISC

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i html-tag-format

      Weekly Downloads

      2

      Version

      1.0.0

      License

      ISC

      Unpacked Size

      3.02 kB

      Total Files

      6

      Last publish

      Collaborators

      • yanggaina