0.0.4 • Published 10 years ago

htmlencode v0.0.4

Weekly downloads
96,144
License
MIT
Repository
github
Last release
10 years ago

node-htmlencode

A wrapped version of http://www.strictly-software.com/htmlencode library -- only two changes to the original:

  1. Renamed global Encoder object to module.exports so it can be used as a Node module.
  2. Fixed leaking global variable arr in htmlDecode method

Usage

In addition to the very minor changes described above, the library is wrapped in a function to allow you to require just the individual method(s) you want.

var htmlencode = require('htmlencode');
htmlencode.htmlEncode('<h1>Welcome</h1>');
// &lt;h1&gt;Welcome&lt;/h1&gt;

works the same as

var htmlEncode = require('htmlencode').htmlEncode;
htmlEncode('<h1>Welcome</h1>');
// &lt;h1&gt;Welcome&lt;/h1&gt;

If you want to change to using numeric HTML entities, you'll still want to do something like this:

var htmlencode = require('htmlencode');
htmlencode.EncodeType = 'numerical'; // Don't blame me. I didn't name it.
htmlencode.htmlEncode('<h1>Welcome</h1>');
// &#60;h1&#62;Welcome&#60;/h1&#62;

Also provided is module.exports.Encoder, the wrapper class, so you can do something like this if you so choose:

var htmlencode = require('htmlencode');
var widget = new htmlencode.Encoder('numerical');
widget.htmlEncode('<h1>Welcome</h1>');
// &#60;h1&#62;Welcome&#60;/h1&#62;
@homeboxio/dredd@instructure/quiz-interactionsvirtuellesburgerburofpg-ui-server@jkoenig134/matrix-bot-sdk@infinitebrahmanuniverse/nolb-htmle@everything-registry/sub-chunk-1870provision-parse@koding/bongo-client@liswood-tache/browsbox-admin-frontend@liswood-tache/browsbox-staticquiz-interactionssendingnetwork-bot-sdk@rocket.chat/forked-matrix-bot-sdk@midgar/controller@midgar/routepomelopay-connect-node-ts@kevingimbel/eleventy-plugin-mermaidprofoundjs@nordeck/matrix-bot-sdktipa2unicode@pidong/matrix-bot-sdk@sorunome/matrix-bot-sdk@mgcm/matrix-bot-sdkentoj-systemedw_epad_portaldt-intercom-clientdredddredd-benchdredd-extendeddredd-proxy-enableddredd-using-gavel-and-chai-assertionsexpress-sanitize-escapeexpress-sanitized-escapedfk-web-uifk-cp-utilsgitbook-plugin-demoshowgitbook-plugin-code-editorgitbook-plugin-include-display-rungitbook-plugin-listingmatrix-bot-sdkmobileprovision-parsedmg-dreddgulp-csslint-reportdgeni-packagesdave-dreddlocustjs-logginghackmd-to-html-cliintercom-clientintercom-client-testinghtml-email-obfuscatorgrunt-java2htmlgitter-markdown-processoripa-jfkkd.js@heurtematte/matrix-bot-sdkpeditor@fischerpascal/html-email-obfuscatornomad-service-timernomad-service-timer-rebootadsk-dreddvelitquoauthbox.sanitizationaxe_html_reportaidan-matrix-bot-sdkalice-model@wavemaker/wm-cordova-cli@wavemaker/wm-reactnative-clitwitch-twilight1totamnumquam@vector-im/matrix-bot-sdk@zalastax/nolb-htmleacos-aplusacos-serverbipiocirruswavecmis-env-spacmis-package-jsx@chrisdotcode/spirityargs-reference@fpg-modules/fk-cp-utils@fpg-sample-modules/fk-cp-utils@groovehq/matrix-bot-sdk@groovehq/matrix-js-bot-sdk
0.0.4

10 years ago

0.0.3

11 years ago