node-html-encoder

2018-12-06 admin

node-html-encoder是什么

什么是node-html-encoder,Package for encoding and decoding html string

node-html-encoder使用教程帮助文档

node-html-encoder

NodeJS wrapper for JavaScript HTML Encoder library http://www.strictly-software.com/htmlencode

Install

npm install node-html-encoder

Examples

var Encoder = require('node-html-encoder').Encoder;

// entity type encoder
var encoder = new Encoder('entity');

console.log(encoder.htmlEncode('<foo /> "bar"'))
// prints &lt;foo /&gt; &quot;bar&quot;

console.log(encoder.htmlDecode('&lt;foo /&gt; &quot;bar&quot;'))
// prints <foo /> "bar"

// numerical type encoder
encoder = new Encoder('numerical');

console.log(encoder.htmlEncode('<foo /> "bar"'))
// prints &#60;foo /&#62; &#34;bar&#34;

console.log(encoder.htmlDecode('&#60;foo /&#62; &#34;bar&#34;'))
// prints <foo /> "bar"

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-47444.html

文章标题:node-html-encoder

回到顶部