ent
Encode and decode HTML entities
Last updated a year ago by ljharb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ent 
SYNC missed versions from official npm registry.

ent Version Badge

github actions coverage License Downloads

npm badge

Encode and decode HTML entities

example

var ent = require('ent');
console.log(ent.encode('<span>©moo</span>'))
console.log(ent.decode('&pi; &amp; &rho;'));
&#60;span&#62;&#169;moo&#60;/span&#62;
π & ρ

ent

methods

var ent = require('ent');
var encode = require('ent/encode');
var decode = require('ent/decode');

encode(str, opts={})

Escape unsafe characters in str with html entities.

By default, entities are encoded with numeric decimal codes.

If opts.numeric is false or opts.named is true, encoding will used named codes like &pi;.

If opts.special is set to an Object, the key names will be forced to be encoded (defaults to forcing: <>'"&). For example:

console.log(encode('hello', { special: { l: true } }));
he&#108;&#108;o

decode(str)

Convert html entities in str back to raw text.

credits

HTML entity tables are from the official entities.json file for the whatwg HTML specification.

install

With npm do:

npm install ent

license

MIT

Current Tags

  • 2.2.2                                ...           latest (a year ago)
  • 0.0.8                                ...           v0-backport (2 years ago)

16 Versions

  • 2.2.2                                ...           a year ago
  • 0.0.8                                ...           2 years ago
  • 2.2.1                                ...           2 years ago
  • 2.2.0                                ...           11 years ago
  • 2.1.1                                ...           11 years ago
  • 2.1.0                                ...           11 years ago
  • 2.0.0                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
  • 0.1.0                                ...           13 years ago
  • 0.0.7                                ...           13 years ago
  • 0.0.6                                ...           13 years ago
  • 0.0.5                                ...           13 years ago
  • 0.0.4                                ...           15 years ago
  • 0.0.3                                ...           15 years ago
  • 0.0.2                                ...           15 years ago
  • 0.0.1                                ...           15 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 15
Last Day 0
Last Week 15
Last Month 1
Dependencies (4)
Dev Dependencies (10)

Copyright 2013 - present © cnpmjs.org | Home |