mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
update: (types/he): version 1.1.1 updates, include decimal in EncodeOptions interface (#25484)
This commit is contained in:
committed by
Sheetal Nandi
parent
4b589138d2
commit
a718acac7d
@@ -2,18 +2,18 @@ import he = require('he');
|
||||
|
||||
function main() {
|
||||
var result: string;
|
||||
|
||||
|
||||
result = he.encode('foo \xa9 bar \u2260 baz qux');
|
||||
// 'foo © bar ≠ baz qux'
|
||||
|
||||
|
||||
he.encode('foo \0 bar');
|
||||
// 'foo \0 bar'
|
||||
|
||||
|
||||
// Passing an `options` object to `encode`, to explicitly disallow named references:
|
||||
he.encode('foo \xa9 bar \u2260 baz qux', {
|
||||
'useNamedReferences': false
|
||||
});
|
||||
|
||||
|
||||
he.encode('foo \xa9 bar \u2260 baz qux', {
|
||||
'encodeEverything': true
|
||||
});
|
||||
@@ -22,21 +22,43 @@ function main() {
|
||||
'encodeEverything': true,
|
||||
'useNamedReferences': true
|
||||
});
|
||||
|
||||
|
||||
he.encode('\x01', {
|
||||
'strict': false
|
||||
});
|
||||
// ''
|
||||
|
||||
// ''
|
||||
|
||||
he.encode('foo © and & ampersand', {
|
||||
'allowUnsafeSymbols': true
|
||||
});
|
||||
|
||||
|
||||
// Using the global default setting (defaults to `false`):
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux');
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
|
||||
// Passing an `options` object to `encode`, to explicitly disable decimal escapes:
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux', {
|
||||
'decimal': false
|
||||
});
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
|
||||
// Passing an `options` object to `encode`, to explicitly enable decimal escapes:
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux', {
|
||||
'decimal': true
|
||||
});
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
|
||||
// Passing an `options` object to `encode`, to explicitly allow named references and decimal escapes:
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux', {
|
||||
'useNamedReferences': true,
|
||||
'decimal': true
|
||||
});
|
||||
|
||||
// Override the global default setting:
|
||||
he.encode.options.useNamedReferences = true;
|
||||
|
||||
|
||||
he.decode('foo © bar ≠ baz 𝌆 qux');
|
||||
|
||||
|
||||
he.decode('foo&bar', {
|
||||
'isAttributeValue': false
|
||||
});
|
||||
|
||||
15
types/he/index.d.ts
vendored
15
types/he/index.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
// Type definitions for he v0.5.0
|
||||
// Type definitions for he v1.1.1
|
||||
// Project: https://github.com/mathiasbynens/he
|
||||
// Definitions by: Simon Edwards <https://github.com/sedwards2009>
|
||||
// Robin Tregaskis <https://github.com/lokidokicoki>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// he - "HTML Entities" - A high quality pair of HTML encode and decode functions.
|
||||
@@ -18,6 +19,18 @@ export interface EncodeOptions {
|
||||
*/
|
||||
useNamedReferences?: boolean;
|
||||
|
||||
/**
|
||||
* The default value for the decimal option is false. If the option is
|
||||
* enabled, encode will generally use decimal escapes (e.g. ©)
|
||||
* rather than hexadecimal escapes (e.g. ©). Beside of this
|
||||
* replacement, the basic behavior remains the same when combined with
|
||||
* other options. For example: if both options useNamedReferences and
|
||||
* decimal are enabled, named references (e.g. ©) are used over
|
||||
* decimal escapes. HTML entities without a named reference are encoded
|
||||
* using decimal escapes.
|
||||
*/
|
||||
decimal?: boolean;
|
||||
|
||||
/**
|
||||
* The default value for the encodeEverything option is false. This means
|
||||
* that encode() will not use any character references for printable ASCII
|
||||
|
||||
Reference in New Issue
Block a user