# html-decoder

> The first HTML5 compliant HTML decoder based on HTML5 specification and can decode the full named character reference list based on this

Latest version **1.0.2** (published 2015-06-25) · BSD license · 0 weekly downloads

## Install

```sh
npm install html-decoder
pnpm add html-decoder
yarn add html-decoder
bun add html-decoder
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2015-06-25 |
| First published | 2015-06-25 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nera Liu |
| Maintainers | neraliu |
| Keywords | html5, escape, encode, decoder |

## Links

- npm: https://www.npmjs.com/package/html-decoder
- Repository: https://github.com/neraliu/html-decoder
- Issues: https://github.com/neraliu/html-decoder/issues
- npm.io page: https://npm.io/package/html-decoder

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads
- [datasets-fi-postalcodes](https://npm.io/package/datasets-fi-postalcodes.md) — 1.1K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2015-06-25
- 1.0.1 — 2015-06-25

## README

HTML Decoder
===============================
The first HTML5 compliant HTML decoder. This decoder is implemented based on the <a href="https://html.spec.whatwg.org/multipage/syntax.html#tokenizing-character-references">HTML5 specification</a> and can decode the full named character reference list based on this <a href="https://html.spec.whatwg.org/multipage/entities.json">json</a>.

## Quick Start

Install the npm html-decoder from the npm repo.
```sh
npm install html-decoder
```

### Server-side Use (node.js)

Decoding a string with numeric and named character reference.

```js
/* create the html decoder */
var HTMLDecoder = require("html-decoder");
decoder = new HTMLDecoder();

var htmlString = "&gt;&gt&gta ...";
/* html = '<<<a...'; */
var html = decoder.decode(htmlString);
```

## Development

### Build

```sh
grunt
```

### How to test
```sh
grunt test
```

## Maintenance

### Generate from WHATWG
```sh
grunt gen
```

## OR doing it manually

### Get the latest named character reference json.
```sh
wget https://html.spec.whatwg.org/multipage/entities.json
```

### Generate the trie.
```sh
# $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.json
```

### Test the build again.
```sh
grunt test
```

### Future works

## License

This software is free to use under the BSD license.
See the [LICENSE file](./LICENSE) for license text and copyright information.

---
_Source: https://npm.io/package/html-decoder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
