mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
73 lines
1.9 KiB
TypeScript
73 lines
1.9 KiB
TypeScript
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
|
|
});
|
|
|
|
he.encode('foo \xa9 bar \u2260 baz qux', {
|
|
'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
|
|
});
|
|
|
|
he.decode('foo&bar', {
|
|
'strict': false
|
|
});
|
|
|
|
he.decode.options.isAttributeValue = true;
|
|
he.escape('<img src=\'x\' onerror="prompt(1)">');
|
|
}
|