1 line
18 KiB
JSON
1 line
18 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});\nvar named_references_1 = require(\"./named-references\");\nvar numeric_unicode_map_1 = require(\"./numeric-unicode-map\");\nvar surrogate_pairs_1 = require(\"./surrogate-pairs\");\nvar allNamedReferences = __assign(__assign({}, named_references_1.namedReferences), {\n all: named_references_1.namedReferences.html5\n});\nfunction replaceUsingRegExp(macroText, macroRegExp, macroReplacer) {\n macroRegExp.lastIndex = 0;\n var replaceMatch = macroRegExp.exec(macroText);\n var replaceResult;\n if (replaceMatch) {\n replaceResult = \"\";\n var replaceLastIndex = 0;\n do {\n if (replaceLastIndex !== replaceMatch.index) {\n replaceResult += macroText.substring(replaceLastIndex, replaceMatch.index);\n }\n var replaceInput = replaceMatch[0];\n replaceResult += macroReplacer(replaceInput);\n replaceLastIndex = replaceMatch.index + replaceInput.length;\n } while (replaceMatch = macroRegExp.exec(macroText));\n if (replaceLastIndex !== macroText.length) {\n replaceResult += macroText.substring(replaceLastIndex);\n }\n } else {\n replaceResult = macroText;\n }\n return replaceResult;\n}\nvar encodeRegExps = {\n specialChars: /[<>'\"&]/g,\n nonAscii: /[<>'\"&\\u0080-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]/g,\n nonAsciiPrintable: /[<>'\"&\\x01-\\x08\\x11-\\x15\\x17-\\x1F\\x7f-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]/g,\n nonAsciiPrintableOnly: /[\\x01-\\x08\\x11-\\x15\\x17-\\x1F\\x7f-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\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]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]/g\n};\nvar defaultEncodeOptions = {\n mode: \"specialChars\",\n level: \"all\",\n numeric: \"decimal\"\n};\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 replaceUsingRegExp(text, encodeRegExp, function (input) {\n var result = references[input];\n if (!result) {\n var code = input.length > 1 ? surrogate_pairs_1.getCodePoint(input, 0) : input.charCodeAt(0);\n result = (isHex ? \"&#x\" + code.toString(16) : \"&#\" + code) + \";\";\n }\n return result;\n });\n}\nexports.encode = encode;\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_1.bodyRegExps.xml\n },\n html4: {\n strict: strict,\n attribute: attribute,\n body: named_references_1.bodyRegExps.html4\n },\n html5: {\n strict: strict,\n attribute: attribute,\n body: named_references_1.bodyRegExps.html5\n }\n};\nvar decodeRegExps = __assign(__assign({}, baseDecodeRegExps), {\n all: baseDecod
|