1 line
17 KiB
JSON
1 line
17 KiB
JSON
![]() |
{"ast":null,"code":"\"use strict\";\n\nvar __assign = this && this.__assign || function () {\n __assign = Object.assign || function (t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.encode = encode;\nexports.decodeEntity = decodeEntity;\nexports.decode = decode;\nvar named_references_js_1 = require(\"./named-references.js\");\nvar numeric_unicode_map_js_1 = require(\"./numeric-unicode-map.js\");\nvar surrogate_pairs_js_1 = require(\"./surrogate-pairs.js\");\nvar allNamedReferences = __assign(__assign({}, named_references_js_1.namedReferences), {\n all: named_references_js_1.namedReferences.html5\n});\nvar encodeRegExps = {\n specialChars: /[<>'\"&]/g,\n nonAscii: /[<>'\"&\\u0080-\\uD7FF\\uE000-\\uFFFF\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]?/g,\n nonAsciiPrintable: /[<>'\"&\\x01-\\x08\\x11-\\x15\\x17-\\x1F\\x7f-\\uD7FF\\uE000-\\uFFFF\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]?/g,\n nonAsciiPrintableOnly: /[\\x01-\\x08\\x11-\\x15\\x17-\\x1F\\x7f-\\uD7FF\\uE000-\\uFFFF\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]?/g,\n extensive: /[\\x01-\\x0c\\x0e-\\x1f\\x21-\\x2c\\x2e-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\x7d\\x7f-\\uD7FF\\uE000-\\uFFFF\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]?/g\n};\nvar defaultEncodeOptions = {\n mode: 'specialChars',\n level: 'all',\n numeric: 'decimal'\n};\n/** Encodes all the necessary (specified by `level`) characters in the text */\nfunction encode(text, _a) {\n var _b = _a === void 0 ? defaultEncodeOptions : _a,\n _c = _b.mode,\n mode = _c === void 0 ? 'specialChars' : _c,\n _d = _b.numeric,\n numeric = _d === void 0 ? 'decimal' : _d,\n _e = _b.level,\n level = _e === void 0 ? 'all' : _e;\n if (!text) {\n return '';\n }\n var encodeRegExp = encodeRegExps[mode];\n var references = allNamedReferences[level].characters;\n var isHex = numeric === 'hexadecimal';\n return String.prototype.replace.call(text, encodeRegExp, function (input) {\n var result = references[input];\n if (!result) {\n var code = input.length > 1 ? (0, surrogate_pairs_js_1.getCodePoint)(input, 0) : input.charCodeAt(0);\n result = (isHex ? '&#x' + code.toString(16) : '&#' + code) + ';';\n }\n return result;\n });\n}\nvar defaultDecodeOptions = {\n scope: 'body',\n level: 'all'\n};\nvar strict = /&(?:#\\d+|#[xX][\\da-fA-F]+|[0-9a-zA-Z]+);/g;\nvar attribute = /&(?:#\\d+|#[xX][\\da-fA-F]+|[0-9a-zA-Z]+)[;=]?/g;\nvar baseDecodeRegExps = {\n xml: {\n strict: strict,\n attribute: attribute,\n body: named_references_js_1.bodyRegExps.xml\n },\n html4: {\n strict: strict,\n attribute: attribute,\n body: named_references_js_1.bodyRegExps.html4\n },\n html5: {\n strict: strict,\n attribute: attribute,\n body: named_references_js_1.bodyRegExps.html5\n }\n};\nvar decodeRegExps = __assign(__assign({}, baseDecodeRegExps), {\n all: baseDecodeRegExps.html5\n});\nvar fromCharCode = String.fromCharCode;\nvar outOfBoundsChar = fromCharCode(65533);\nvar defaultDecodeEntityOptions = {\n level: 'all'\n};\nfunction getDecodedEntity(entity, references, isAttribute, isStrict) {\n var decodeResult = entity;\n var decodeEntityLastChar = entity[entity.length - 1];\n if (isAttribute && decodeEntityLastChar === '=') {\n decodeResult = entity;\n } else if (isStrict && decodeEntityLastChar !== ';') {\n decodeResult = entity;\n } else {\n var decodeResultByReference = references[entity];\n if (decodeResultByReference) {\n decodeResult = decodeResultByReference;\n } else if (entity[0] === '&' && entity[1] === '#') {\n var decodeSecondChar = entity[2];\n var decodeCode = decodeSecondChar == 'x' || decodeSecondChar == 'X' ? parseInt(entity.substr(3), 16) : parseInt(entity.substr(2));\n decodeResult = decodeCode >= 0x10ffff ?
|