micromark-util-decode-string
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -13,2 +13,3 @@ /** | ||
*/ | ||
export function decodeString(value: string): string | ||
export function decodeString(value: string): string; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -26,5 +26,9 @@ import {decodeNamedCharacterReference} from 'decode-named-character-reference' | ||
* @param {string} $0 | ||
* Match. | ||
* @param {string} $1 | ||
* Character escape. | ||
* @param {string} $2 | ||
* Character reference. | ||
* @returns {string} | ||
* Decoded value | ||
*/ | ||
@@ -31,0 +35,0 @@ function decode($0, $1, $2) { |
@@ -13,2 +13,3 @@ /** | ||
*/ | ||
export function decodeString(value: string): string | ||
export function decodeString(value: string): string; | ||
//# sourceMappingURL=index.d.ts.map |
27
index.js
@@ -1,5 +0,4 @@ | ||
import {decodeNamedCharacterReference} from 'decode-named-character-reference' | ||
import {decodeNumericCharacterReference} from 'micromark-util-decode-numeric-character-reference' | ||
const characterEscapeOrReference = | ||
/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi | ||
import { decodeNamedCharacterReference } from 'decode-named-character-reference'; | ||
import { decodeNumericCharacterReference } from 'micromark-util-decode-numeric-character-reference'; | ||
const characterEscapeOrReference = /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi; | ||
@@ -19,3 +18,3 @@ /** | ||
export function decodeString(value) { | ||
return value.replace(characterEscapeOrReference, decode) | ||
return value.replace(characterEscapeOrReference, decode); | ||
} | ||
@@ -25,5 +24,9 @@ | ||
* @param {string} $0 | ||
* Match. | ||
* @param {string} $1 | ||
* Character escape. | ||
* @param {string} $2 | ||
* Character reference. | ||
* @returns {string} | ||
* Decoded value | ||
*/ | ||
@@ -33,13 +36,13 @@ function decode($0, $1, $2) { | ||
// Escape. | ||
return $1 | ||
return $1; | ||
} | ||
// Reference. | ||
const head = $2.charCodeAt(0) | ||
const head = $2.charCodeAt(0); | ||
if (head === 35) { | ||
const head = $2.charCodeAt(1) | ||
const hex = head === 120 || head === 88 | ||
return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10) | ||
const head = $2.charCodeAt(1); | ||
const hex = head === 120 || head === 88; | ||
return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10); | ||
} | ||
return decodeNamedCharacterReference($2) || $0 | ||
} | ||
return decodeNamedCharacterReference($2) || $0; | ||
} |
{ | ||
"name": "micromark-util-decode-string", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "micromark utility to decode markdown strings", | ||
@@ -36,2 +36,3 @@ "license": "MIT", | ||
"dev/", | ||
"index.d.ts.map", | ||
"index.d.ts", | ||
@@ -53,3 +54,12 @@ "index.js" | ||
}, | ||
"xo": false | ||
"xo": { | ||
"envs": [ | ||
"shared-node-browser" | ||
], | ||
"prettier": true, | ||
"rules": { | ||
"unicorn/prefer-code-point": "off", | ||
"unicorn/prefer-string-replace-all": "off" | ||
} | ||
} | ||
} |
@@ -15,13 +15,13 @@ # micromark-util-decode-string | ||
* [What is this?](#what-is-this) | ||
* [When should I use this?](#when-should-i-use-this) | ||
* [Install](#install) | ||
* [Use](#use) | ||
* [API](#api) | ||
* [`decodeString(value)`](#decodestringvalue) | ||
* [Types](#types) | ||
* [Compatibility](#compatibility) | ||
* [Security](#security) | ||
* [Contribute](#contribute) | ||
* [License](#license) | ||
* [What is this?](#what-is-this) | ||
* [When should I use this?](#when-should-i-use-this) | ||
* [Install](#install) | ||
* [Use](#use) | ||
* [API](#api) | ||
* [`decodeString(value)`](#decodestringvalue) | ||
* [Types](#types) | ||
* [Compatibility](#compatibility) | ||
* [Security](#security) | ||
* [Contribute](#contribute) | ||
* [License](#license) | ||
@@ -85,4 +85,4 @@ ## What is this? | ||
* `value` (`string`) | ||
— value to decode | ||
* `value` (`string`) | ||
— value to decode | ||
@@ -106,4 +106,4 @@ ###### Returns | ||
This means we try to keep the current release line, | ||
`micromark-util-decode-string@^2`, compatible with Node.js 16. | ||
This package works with `micromark@^3`. | ||
`micromark-util-decode-string@2`, compatible with Node.js 16. | ||
This package works with `micromark@3`. | ||
@@ -110,0 +110,0 @@ ## Security |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11088
9
114