This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

heroglyph

1.0.4 • Public • Published

Heroglyph

GitHub release npm npm bundle size (minified)

Library providing utility methods to escape special characters to their HTML entities, decimal or hexadecimal as well as unescape their corresponding character references back to chars.

1. How it work

escape function will convert '#' to '#' or '#' or '#' depending on passed parameters.

unescape function will convert '#' or '#' or '#' to '#' this module supports 1029 characters the entities covered HTML5 and html 4.1

Installation

  npm install heroglyph --save
  yarn add --dev heroglyph

Usage

  var entity = require('heroglyph');

  var unescapeStr = 'item is under © ';
  var escapeStr = 'say $';

  var escapedString = entity.escape(escapeStr, 'entity');
  var unescapedString = entity.unescape(unescapeStr);

  console.log('Escaped: ' + escapedString);
  console.log('Unescaped: ' + unescapedString);

Parameter for escape()

entity will return & format
hex will return ( format
decimal will return % format

for a character witch have more than one entity

ex: for '↑' it has ↑ ↑ ↑ ↑ entities

use 1, 2, 3, 4, as parameter instead of entity and get alternative entity

var entity = require('heroglyph');

entity.escape('& here we are', 1); // will return ↑

/* the paramter must be a number not a string */

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Published

Version History

  • Version
    Downloads (Last 7 Days)
    • Published

Package Sidebar

Install

npm i heroglyph

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

62.6 kB

Total Files

6

Last publish

Collaborators

  • yecodeo