mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
/// <reference path="he.d.ts" />
|
|
|
|
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
|
|
});
|
|
|
|
// 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)">');
|
|
}
|