parse-entities
Advanced tools
+22
-68
@@ -1,14 +0,4 @@ | ||
| /** | ||
| * @author Titus Wormer | ||
| * @copyright 2015 Titus Wormer | ||
| * @license MIT | ||
| * @module parse-entities | ||
| * @fileoverview Parse HTML character references: fast, spec-compliant, | ||
| * positional information. | ||
| */ | ||
| 'use strict'; | ||
| /* Dependencies. */ | ||
| var has = require('has'); | ||
| var characterEntities = require('character-entities'); | ||
@@ -25,2 +15,3 @@ var legacy = require('character-entities-legacy'); | ||
| /* Methods. */ | ||
| var own = {}.hasOwnProperty; | ||
| var fromCharCode = String.fromCharCode; | ||
@@ -104,10 +95,6 @@ var noop = Function.prototype; | ||
| /** | ||
| * Wrap to ensure clean parameters are given to `parse`. | ||
| * | ||
| * @param {string} value - Value with entities. | ||
| * @param {Object?} [options] - Configuration. | ||
| */ | ||
| /* Wrap to ensure clean parameters are given to `parse`. */ | ||
| function wrapper(value, options) { | ||
| var settings = {}; | ||
| var option; | ||
| var key; | ||
@@ -120,3 +107,4 @@ | ||
| for (key in defaults) { | ||
| settings[key] = options[key] == null ? defaults[key] : options[key]; | ||
| option = options[key]; | ||
| settings[key] = option === null || option === undefined ? defaults[key] : option; | ||
| } | ||
@@ -132,8 +120,3 @@ | ||
| /** | ||
| * Parse entities. | ||
| * | ||
| * @param {string} value - Value to tokenise. | ||
| * @param {Object?} [settings] - Configuration. | ||
| */ | ||
| /* Parse entities. */ | ||
| function parse(value, settings) { | ||
@@ -234,3 +217,5 @@ var additional = settings.additional; | ||
| start = begin = end = index + 1; | ||
| start = index + 1; | ||
| begin = start; | ||
| end = start; | ||
@@ -257,3 +242,5 @@ /* Numerical entity. */ | ||
| entityCharacters = entity = characters = EMPTY; | ||
| entityCharacters = EMPTY; | ||
| entity = EMPTY; | ||
| characters = EMPTY; | ||
| test = TESTS[type]; | ||
@@ -276,3 +263,3 @@ end--; | ||
| * later. */ | ||
| if (type === NAMED && has(legacy, characters)) { | ||
| if (type === NAMED && own.call(legacy, characters)) { | ||
| entityCharacters = characters; | ||
@@ -288,3 +275,3 @@ entity = legacy[characters]; | ||
| if (type === NAMED && has(characterEntities, characters)) { | ||
| if (type === NAMED && own.call(characterEntities, characters)) { | ||
| entityCharacters = characters; | ||
@@ -430,8 +417,3 @@ entity = characterEntities[characters]; | ||
| /** | ||
| * Get current position. | ||
| * | ||
| * @return {Object} - Positional information of a | ||
| * single point. | ||
| */ | ||
| /* Get current position. */ | ||
| function now() { | ||
@@ -445,11 +427,3 @@ return { | ||
| /** | ||
| * “Throw” a parse-error: a warning. | ||
| * | ||
| * @param {number} code - Identifier of reason for | ||
| * failing. | ||
| * @param {number} offset - Offset in characters from | ||
| * the current position point at which the | ||
| * parse-error ocurred, cannot point past newlines. | ||
| */ | ||
| /* “Throw” a parse-error: a warning. */ | ||
| function parseError(code, offset) { | ||
@@ -464,9 +438,3 @@ var position = now(); | ||
| /** | ||
| * Get character at position. | ||
| * | ||
| * @param {number} position - Indice of character in `value`. | ||
| * @return {string} - Character at `position` in | ||
| * `value`. | ||
| */ | ||
| /* Get character at position. */ | ||
| function at(position) { | ||
@@ -476,8 +444,5 @@ return value.charAt(position); | ||
| /** | ||
| * Flush `queue` (normal text). Macro invoked before | ||
| /* Flush `queue` (normal text). Macro invoked before | ||
| * each entity and at the end of `value`. | ||
| * | ||
| * Does nothing when `queue` is empty. | ||
| */ | ||
| * Does nothing when `queue` is empty. */ | ||
| function flush() { | ||
@@ -499,10 +464,4 @@ if (queue) { | ||
| /** | ||
| * Check whether `character` is outside the permissible | ||
| * unicode range. | ||
| * | ||
| * @param {number} code - Value. | ||
| * @return {boolean} - Whether `character` is an | ||
| * outside the permissible unicode range. | ||
| */ | ||
| /* Check if `character` is outside the permissible | ||
| * unicode range. */ | ||
| function isProhibited(code) { | ||
@@ -512,8 +471,3 @@ return (code >= 0xD800 && code <= 0xDFFF) || (code > 0x10FFFF); | ||
| /** | ||
| * Check whether `character` is disallowed. | ||
| * | ||
| * @param {number} code - Value. | ||
| * @return {boolean} - Whether `character` is disallowed. | ||
| */ | ||
| /* Check if `character` is disallowed. */ | ||
| function isWarning(code) { | ||
@@ -520,0 +474,0 @@ if ( |
+17
-37
| { | ||
| "name": "parse-entities", | ||
| "version": "1.1.0", | ||
| "version": "1.1.1", | ||
| "description": "Parse HTML character references: fast, spec-compliant, positional information", | ||
@@ -14,2 +14,8 @@ "license": "MIT", | ||
| ], | ||
| "repository": "wooorm/parse-entities", | ||
| "bugs": "https://github.com/wooorm/parse-entities/issues", | ||
| "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
| "contributors": [ | ||
| "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)" | ||
| ], | ||
| "files": [ | ||
@@ -22,3 +28,2 @@ "index.js" | ||
| "character-reference-invalid": "^1.0.0", | ||
| "has": "^1.0.1", | ||
| "is-alphanumerical": "^1.0.0", | ||
@@ -28,22 +33,13 @@ "is-decimal": "^1.0.0", | ||
| }, | ||
| "repository": "https://github.com/wooorm/parse-entities", | ||
| "bugs": "https://github.com/wooorm/parse-entities/issues", | ||
| "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
| "contributors": [ | ||
| "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)" | ||
| ], | ||
| "devDependencies": { | ||
| "browserify": "^13.0.0", | ||
| "browserify": "^14.0.0", | ||
| "esmangle": "^1.0.0", | ||
| "nyc": "^7.1.0", | ||
| "remark-cli": "^1.0.0", | ||
| "remark-comment-config": "^4.0.0", | ||
| "remark-github": "^5.0.0", | ||
| "remark-lint": "^4.0.0", | ||
| "remark-validate-links": "^4.0.0", | ||
| "nyc": "^11.0.0", | ||
| "remark-cli": "^3.0.0", | ||
| "remark-preset-wooorm": "^3.0.0", | ||
| "tape": "^4.2.0", | ||
| "xo": "^0.16.0" | ||
| "xo": "^0.18.0" | ||
| }, | ||
| "scripts": { | ||
| "build-md": "remark . --quiet --frail", | ||
| "build-md": "remark . -qfo", | ||
| "build-bundle": "browserify index.js --bare -s parseEntities > parse-entities.js", | ||
@@ -65,2 +61,3 @@ "build-mangle": "esmangle parse-entities.js > parse-entities.min.js", | ||
| "space": true, | ||
| "esnext": false, | ||
| "rules": { | ||
@@ -70,28 +67,11 @@ "guard-for-in": "off", | ||
| "max-depth": "off", | ||
| "max-lines": "off", | ||
| "complexity": "off", | ||
| "no-eq-null": "off", | ||
| "eqeqeq": "off" | ||
| "complexity": "off" | ||
| }, | ||
| "ignores": [ | ||
| "parse-entities.js", | ||
| "parse-entities.min.js" | ||
| "parse-entities.js" | ||
| ] | ||
| }, | ||
| "remarkConfig": { | ||
| "output": true, | ||
| "plugins": { | ||
| "lint": { | ||
| "heading-increment": false, | ||
| "list-item-spacing": false, | ||
| "no-duplicate-headings": false | ||
| }, | ||
| "github": null, | ||
| "comment-config": null, | ||
| "validate-links": null | ||
| }, | ||
| "settings": { | ||
| "bullet": "*" | ||
| } | ||
| "plugins": ["preset-wooorm"] | ||
| } | ||
| } |
+21
-21
@@ -20,9 +20,9 @@ # parse-entities [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] | ||
| decode('alpha & bravo'); | ||
| // alpha & bravo | ||
| //=> alpha & bravo | ||
| decode('charlie ©cat; delta'); | ||
| // charlie ©cat; delta | ||
| //=> charlie ©cat; delta | ||
| decode('echo © foxtrot ≠ golf 𝌆 hotel'); | ||
| // echo © foxtrot ≠ golf 𝌆 hotel | ||
| //=> echo © foxtrot ≠ golf 𝌆 hotel | ||
| ``` | ||
@@ -38,24 +38,24 @@ | ||
| — Additional character to accept when following an ampersand (without | ||
| error); | ||
| error) | ||
| * `attribute` (`boolean`, optional, default: `false`) | ||
| — Whether to parse `value` as an attribute value; | ||
| — Whether to parse `value` as an attribute value | ||
| * `nonTerminated` (`boolean`, default: `true`) | ||
| — Whether to allow non-terminated entities, such as `©cat` to | ||
| `©cat`. This behaviour is spec-compliant but can lead to unexpected | ||
| results; | ||
| results | ||
| * `warning` ([`Function`][warning], optional) | ||
| — Error handler; | ||
| — Error handler | ||
| * `text` ([`Function`][text], optional) | ||
| — Text handler; | ||
| — Text handler | ||
| * `reference` ([`Function`][reference], | ||
| optional) — Reference handler; | ||
| optional) — Reference handler | ||
| * `warningContext` (`'*'`, optional) | ||
| — Context used when invoking `warning`; | ||
| — Context used when invoking `warning` | ||
| * `textContext` (`'*'`, optional) | ||
| — Context used when invoking `text`; | ||
| — Context used when invoking `text` | ||
| * `referenceContext` (`'*'`, optional) | ||
| — Context used when invoking `reference`; | ||
| — Context used when invoking `reference` | ||
| * `position` (`Location` or `Position`, optional) | ||
| — Starting `position` of `value`, useful when dealing with values | ||
| nested in some sort of syntax tree. The default is: | ||
| nested in some sort of syntax tree. The default is: | ||
@@ -88,7 +88,7 @@ ```json | ||
| * `reason` (`string`) | ||
| — Reason (human-readable) for triggering a parse error; | ||
| — Reason (human-readable) for triggering a parse error | ||
| * `position` (`Position`) | ||
| — Place at which the parse error occurred; | ||
| — Place at which the parse error occurred | ||
| * `code` (`number`) | ||
| — Identifier of reason for triggering a parse error. | ||
| — Identifier of reason for triggering a parse error | ||
@@ -117,4 +117,4 @@ The following codes are used: | ||
| * `value` (`string`) — String of content; | ||
| * `location` (`Location`) — Location at which `value` starts and ends. | ||
| * `value` (`string`) — String of content | ||
| * `location` (`Location`) — Location at which `value` starts and ends | ||
@@ -131,5 +131,5 @@ ### `function reference(value, location, source)` | ||
| * `value` (`string`) — Encoded character reference; | ||
| * `location` (`Location`) — Location at which `value` starts and ends; | ||
| * `source` (`Location`) — Source of character reference. | ||
| * `value` (`string`) — Encoded character reference | ||
| * `location` (`Location`) — Location at which `value` starts and ends | ||
| * `source` (`Location`) — Source of character reference | ||
@@ -136,0 +136,0 @@ ## License |
-23
| <!--remark setext--> | ||
| <!--lint disable no-multiple-toplevel-headings --> | ||
| 1.1.0 / 2016-07-31 | ||
| ================== | ||
| * Add new `nonTerminated` setting ([`eed693c`](https://github.com/wooorm/parse-entities/commit/eed693c)) | ||
| 1.0.2 / 2015-12-29 | ||
| ================== | ||
| * Fix legacy entity support ([7bf652a](https://github.com/wooorm/parse-entities/commit/7bf652a)) | ||
| 1.0.1 / 2015-12-27 | ||
| ================== | ||
| * Update mdast to remark ([8b158ad](https://github.com/wooorm/parse-entities/commit/8b158ad)) | ||
| * Fix escaping in `readme.md` ([c743fa2](https://github.com/wooorm/parse-entities/commit/c743fa2)) | ||
| * Fix missing dependencies in `component.json` ([cbdd3da](https://github.com/wooorm/parse-entities/commit/cbdd3da)) | ||
| 1.0.0 / 2015-12-23 | ||
| ================== |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
6
-14.29%7
-30%0
-100%19580
-10.5%4
-20%403
-10.04%- Removed
- Removed