1.0.2 • Published 10 years ago
html-decoder v1.0.2
HTML Decoder
The first HTML5 compliant HTML decoder. This decoder is implemented based on the HTML5 specification and can decode the full named character reference list based on this json.
Quick Start
Install the npm html-decoder from the npm repo.
npm install html-decoderServer-side Use (node.js)
Decoding a string with numeric and named character reference.
/* create the html decoder */
var HTMLDecoder = require("html-decoder");
decoder = new HTMLDecoder();
var htmlString = ">>>a ...";
/* html = '<<<a...'; */
var html = decoder.decode(htmlString);Development
Build
gruntHow to test
grunt testMaintenance
Generate from WHATWG
grunt genOR doing it manually
Get the latest named character reference json.
wget https://html.spec.whatwg.org/multipage/entities.jsonGenerate the trie.
# $REPO_HOME is the home directory of this repo.
cp entities.json $REPO_HOME/data
# the output is saved @ src/gen/trie.js
./bin/genhtmlentities data/entities.jsonTest the build again.
grunt testFuture works
License
This software is free to use under the BSD license. See the LICENSE file for license text and copyright information.