Skip to content

Instantly share code, notes, and snippets.

@ivirshup
Created April 17, 2024 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivirshup/5c76ae74673743410d601904034b8286 to your computer and use it in GitHub Desktop.
Save ivirshup/5c76ae74673743410d601904034b8286 to your computer and use it in GitHub Desktop.
scalene error
Scalene: An exception of type UnicodeDecodeError occurred. Arguments:
('ascii', b'/* PrismJS 1.26.0\nhttps://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+python&plugins=normalize-whitespace */\n/// <reference lib="WebWorker"/>\n\nvar _self =\n typeof window !== "undefined"\n ? window // if in browser\n : typeof WorkerGlobalScope !== "undefined" &&\n self instanceof WorkerGlobalScope\n ? self // if in worker\n : {}; // if in node js\n\n/**\n * Prism: Lightweight, robust, elegant syntax highlighting\n *\n * @license MIT <https://opensource.org/licenses/MIT>\n * @author Lea Verou <https://lea.verou.me>\n * @namespace\n * @public\n */\nvar Prism = (function (_self) {\n // Private helper vars\n var lang = /(?:^|\\s)lang(?:uage)?-([\\w-]+)(?=\\s|$)/i;\n var uniqueId = 0;\n\n // The grammar object for plaintext\n var plainTextGrammar = {};\n\n var _ = {\n /**\n * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the\n * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load\n * additional languages or plugins yourself.\n *\n * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.\n *\n * You obviously have to change this value before the automatic highlighting started. To do this, you can add an\n * empty Prism object into the global scope before loading the Prism script like this:\n *\n * ```js\n * window.Prism = window.Prism || {};\n * Prism.manual = true;\n * // add a new <script> to load Prism\'s script\n * ```\n *\n * @default false\n * @type {boolean}\n * @memberof Prism\n * @public\n */\n manual: _self.Prism && _self.Prism.manual,\n /**\n * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses\n * `addEventListener` to communicate with its parent instance. However, if you\'re using Prism manually in your\n * own worker, you don\'t want it to do this.\n *\n * By setting this value to `true`, Prism will not add its own listeners to the worker.\n *\n * You obviously have to change this value before Prism executes. To do this, you can add an\n * empty Prism object into the global scope before loading the Prism script like this:\n *\n * ```js\n * window.Prism = window.Prism || {};\n * Prism.disableWorkerMessageHandler = true;\n * // Load Prism\'s script\n * ```\n *\n * @default false\n * @type {boolean}\n * @memberof Prism\n * @public\n */\n disableWorkerMessageHandler:\n _self.Prism && _self.Prism.disableWorkerMessageHandler,\n\n /**\n * A namespace for utility methods.\n *\n * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may\n * change or disappear at any time.\n *\n * @namespace\n * @memberof Prism\n */\n util: {\n encode: function encode(tokens) {\n if (tokens instanceof Token) {\n return new Token(tokens.type, encode(tokens.content), tokens.alias);\n } else if (Array.isArray(tokens)) {\n return tokens.map(encode);\n } else {\n return tokens\n .replace(/&/g, "&amp;")\n .replace(/</g, "&lt;")\n .replace(/\\u00a0/g, " ");\n }\n },\n\n /**\n * Returns the name of the type of the given value.\n *\n * @param {any} o\n * @returns {string}\n * @example\n * type(null) === \'Null\'\n * type(undefined) === \'Undefined\'\n * type(123) === \'Number\'\n * type(\'foo\') === \'String\'\n * type(true) === \'Boolean\'\n * type([1, 2]) === \'Array\'\n * type({}) === \'Object\'\n * type(String) === \'Function\'\n * type(/abc+/) === \'RegExp\'\n */\n type: function (o) {\n return Object.prototype.toString.call(o).slice(8, -1);\n },\n\n /**\n * Returns a unique number for the given object. Later calls will still return the same number.\n *\n * @param {Object} obj\n * @returns {number}\n */\n objId: function (obj) {\n if (!obj["__id"]) {\n Object.defineProperty(obj, "__id", { value: ++uniqueId });\n }\n return obj["__id"];\n },\n\n /**\n * Creates a deep clone of the given object.\n *\n * The main intended use of this function is to clone language definitions.\n *\n * @param {T} o\n * @param {Record<number, any>} [visited]\n * @returns {T}\n * @template T\n */\n clone: function deepClone(o, visited) {\n visited = visited || {};\n\n var clone;\n var id;\n switch (_.util.type(o)) {\n case "Object":\n id = _.util.objId(o);\n if (visited[id]) {\n return visited[id];\n }\n clone = /** @type {Record<string, any>} */ ({});\n visited[id] = clone;\n\n for (var key in o) {\n if (o.hasOwnProperty(key)) {\n clone[key] = deepClone(o[key], visited);\n }\n }\n\n return /** @type {any} */ (clone);\n\n case "Array":\n id = _.util.objId(o);\n if (visited[id]) {\n return visited[id];\n }\n clone = [];\n visited[id] = clone;\n\n /** @type {Array} */ (/** @type {any} */ (o)).forEach(function (\n v,\n i\n ) {\n clone[i] = deepClone(v, visited);\n });\n\n return /** @type {any} */ (clone);\n\n default:\n return o;\n }\n },\n\n /**\n * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.\n *\n * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.\n *\n * @param {Element} element\n * @returns {string}\n */\n getLanguage: function (element) {\n while (element) {\n var m = lang.exec(element.className);\n if (m) {\n return m[1].toLowerCase();\n }\n element = element.parentElement;\n }\n return "none";\n },\n\n /**\n * Sets the Prism `language-xxxx` class of the given element.\n *\n * @param {Element} element\n * @param {string} language\n * @returns {void}\n */\n setLanguage: function (element, language) {\n // remove all `language-xxxx` classes\n // (this might leave behind a leading space)\n element.className = element.className.replace(RegExp(lang, "gi"), "");\n\n // add the new `language-xxxx` class\n // (using `classList` will automatically clean up spaces for us)\n element.classList.add("language-" + language);\n },\n\n /**\n * Returns the script element that is currently executing.\n *\n * This does __not__ work for line script element.\n *\n * @returns {HTMLScriptElement | null}\n */\n currentScript: function () {\n if (typeof document === "undefined") {\n return null;\n }\n if (\n "currentScript" in document &&\n 1 < 2 /* hack to trip TS\' flow analysis */\n ) {\n return /** @type {any} */ (document.currentScript);\n }\n\n // IE11 workaround\n // we\'ll get the src of the current script by parsing IE11\'s error stack trace\n // this will not work for inline scripts\n\n try {\n throw new Error();\n } catch (err) {\n // Get file src url from stack. Specifically works with the format of stack traces in IE.\n // A stack will look like this:\n //\n // Error\n // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)\n // at Global code (http://localhost/components/prism-core.js:606:1)\n\n var src = (/at [^(\\r\\n]*\\((.*):[^:]+:[^:]+\\)$/i.exec(err.stack) ||\n [])[1];\n if (src) {\n var scripts = document.getElementsByTagName("script");\n for (var i in scripts) {\n if (scripts[i].src == src) {\n return scripts[i];\n }\n }\n }\n return null;\n }\n },\n\n /**\n * Returns whether a given class is active for `element`.\n *\n * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated\n * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the\n * given class is just the given class with a `no-` prefix.\n *\n * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is\n * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its\n * ancestors have the given class or the negated version of it, then the default activation will be returned.\n *\n * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated\n * version of it, the class is considered active.\n *\n * @param {Element} element\n * @param {string} className\n * @param {boolean} [defaultActivation=false]\n * @returns {boolean}\n */\n isActive: function (element, className, defaultActivation) {\n var no = "no-" + className;\n\n while (element) {\n var classList = element.classList;\n if (classList.contains(className)) {\n return true;\n }\n if (classList.contains(no)) {\n return false;\n }\n element = element.parentElement;\n }\n return !!defaultActivation;\n },\n },\n\n /**\n * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.\n *\n * @namespace\n * @memberof Prism\n * @public\n */\n languages: {\n /**\n * The grammar for plain, unformatted text.\n */\n plain: plainTextGrammar,\n plaintext: plainTextGrammar,\n text: plainTextGrammar,\n txt: plainTextGrammar,\n\n /**\n * Creates a deep copy of the language with the given id and appends the given tokens.\n *\n * If a token in `redef` also appears in the copied language, then the existing token in the copied language\n * will be overwritten at its original position.\n *\n * ## Best practices\n *\n * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)\n * doesn\'t matter, they can technically be in any order. However, this can be confusing to others that trying to\n * understand the language definition because, normally, the order of tokens matters in Prism grammars.\n *\n * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.\n * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.\n *\n * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.\n * @param {Grammar} redef The new tokens to append.\n * @returns {Grammar} The new language created.\n * @public\n * @example\n * Prism.languages[\'css-with-colors\'] = Prism.languages.extend(\'css\', {\n * // Prism.languages.css already has a \'comment\' token, so this token will overwrite CSS\' \'comment\' token\n * // at its original position\n * \'comment\': { ... },\n * // CSS doesn\'t have a \'color\' token, so this token will be appended\n * \'color\': /\\b(?:red|green|blue)\\b/\n * });\n */\n extend: function (id, redef) {\n var lang = _.util.clone(_.languages[id]);\n\n for (var key in redef) {\n lang[key] = redef[key];\n }\n\n return lang;\n },\n\n /**\n * Inserts tokens _before_ another token in a language definition or any other grammar.\n *\n * ## Usage\n *\n * This helper method makes it easy to modify existing languages. For example, the CSS language definition\n * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded\n * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the\n * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do\n * this:\n *\n * ```js\n * Prism.languages.markup.style = {\n * // token\n * };\n * ```\n *\n * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens\n * before existing tokens. For the CSS example above, you would use it like this:\n *\n * ```js\n * Prism.languages.insertBefore(\'markup\', \'cdata\', {\n * \'style\': {\n * // token\n * }\n * });\n * ```\n *\n * ## Special cases\n *\n * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`\'s grammar\n * will be ignored.\n *\n * This behavior can be used to insert tokens after `before`:\n *\n * ```js\n * Prism.languages.insertBefore(\'markup\', \'comment\', {\n * \'comment\': Prism.languages.markup.comment,\n * // tokens after \'comment\'\n * });\n * ```\n *\n * ## Limitations\n *\n * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object\n * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave\n * differently when keys are deleted and re-inserted. So `insertBefore` can\'t be implemented by temporarily\n * deleting properties which is necessary to insert at arbitrary positions.\n *\n * To solve this problem, `insertBefore` doesn\'t actually insert the given tokens into the target object.\n * Instead, it will create a new object and replace all references to the target object with the new one. This\n * can be done without temporarily deleting properties, so the iteration order is well-defined.\n *\n * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if\n * you hold the target object in a variable, then the value of the variable will not change.\n *\n * ```js\n * var oldMarkup = Prism.languages.markup;\n * var newMarkup = Prism.languages.insertBefore(\'markup\', \'comment\', { ... });\n *\n * assert(oldMarkup !== Prism.languages.markup);\n * assert(newMarkup === Prism.languages.markup);\n * ```\n *\n * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the\n * object to be modified.\n * @param {string} before The key to insert before.\n * @param {Grammar} insert An object containing the key-value pairs to be inserted.\n * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the\n * object to be modified.\n *\n * Defaults to `Prism.languages`.\n * @returns {Grammar} The new grammar object.\n * @public\n */\n insertBefore: function (inside, before, insert, root) {\n root = root || /** @type {any} */ (_.languages);\n var grammar = root[inside];\n /** @type {Grammar} */\n var ret = {};\n\n for (var token in grammar) {\n if (grammar.hasOwnProperty(token)) {\n if (token == before) {\n for (var newToken in insert) {\n if (insert.hasOwnProperty(newToken)) {\n ret[newToken] = insert[newToken];\n }\n }\n }\n\n // Do not insert token which also occur in insert. See #1525\n if (!insert.hasOwnProperty(token)) {\n ret[token] = grammar[token];\n }\n }\n }\n\n var old = root[inside];\n root[inside] = ret;\n\n // Update references in other language definitions\n _.languages.DFS(_.languages, function (key, value) {\n if (value === old && key != inside) {\n this[key] = ret;\n }\n });\n\n return ret;\n },\n\n // Traverse a language definition with Depth First Search\n DFS: function DFS(o, callback, type, visited) {\n visited = visited || {};\n\n var objId = _.util.objId;\n\n for (var i in o) {\n if (o.hasOwnProperty(i)) {\n callback.call(o, i, o[i], type || i);\n\n var property = o[i];\n var propertyType = _.util.type(property);\n\n if (propertyType === "Object" && !visited[objId(property)]) {\n visited[objId(property)] = true;\n DFS(property, callback, null, visited);\n } else if (propertyType === "Array" && !visited[objId(property)]) {\n visited[objId(property)] = true;\n DFS(property, callback, i, visited);\n }\n }\n }\n },\n },\n\n plugins: {},\n\n /**\n * This is the most high-level function in Prism\xe2\x80\x99s API.\n * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on\n * each one of them.\n *\n * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.\n *\n * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.\n * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.\n * @memberof Prism\n * @public\n */\n highlightAll: function (async, callback) {\n _.highlightAllUnder(document, async, callback);\n },\n\n /**\n * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls\n * {@link Prism.highlightElement} on each one of them.\n *\n * The following hooks will be run:\n * 1. `before-highlightall`\n * 2. `before-all-elements-highlight`\n * 3. All hooks of {@link Prism.highlightElement} for each element.\n *\n * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.\n * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.\n * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.\n * @memberof Prism\n * @public\n */\n highlightAllUnder: function (container, async, callback) {\n var env = {\n callback: callback,\n container: container,\n selector:\n \'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code\',\n };\n\n _.hooks.run("before-highlightall", env);\n\n env.elements = Array.prototype.slice.apply(\n env.container.querySelectorAll(env.selector)\n );\n\n _.hooks.run("before-all-elements-highlight", env);\n\n for (var i = 0, element; (element = env.elements[i++]); ) {\n _.highlightElement(element, async === true, env.callback);\n }\n },\n\n /**\n * Highlights the code inside a single element.\n *\n * The following hooks will be run:\n * 1. `before-sanity-check`\n * 2. `before-highlight`\n * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.\n * 4. `before-insert`\n * 5. `after-highlight`\n * 6. `complete`\n *\n * Some the above hooks will be skipped if the element doesn\'t contain any text or there is no grammar loaded for\n * the element\'s language.\n *\n * @param {Element} element The element containing the code.\n * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.\n * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers\n * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is\n * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).\n *\n * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for\n * asynchronous highlighting to work. You can build your own bundle on the\n * [Download page](https://prismjs.com/download.html).\n * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.\n * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.\n * @memberof Prism\n * @public\n */\n highlightElement: function (element, async, callback) {\n // Find language\n var language = _.util.getLanguage(element);\n var grammar = _.languages[language];\n\n // Set language on the element, if not present\n _.util.setLanguage(element, language);\n\n // Set language on the parent, for styling\n var parent = element.parentElement;\n if (parent && parent.nodeName.toLowerCase() === "pre") {\n _.util.setLanguage(parent, language);\n }\n\n var code = element.textContent;\n\n var env = {\n element: element,\n language: language,\n grammar: grammar,\n code: code,\n };\n\n function insertHighlightedCode(highlightedCode) {\n env.highlightedCode = highlightedCode;\n\n _.hooks.run("before-insert", env);\n\n env.element.innerHTML = env.highlightedCode;\n\n _.hooks.run("after-highlight", env);\n _.hooks.run("complete", env);\n callback && callback.call(env.element);\n }\n\n _.hooks.run("before-sanity-check", env);\n\n // plugins may change/add the parent/element\n parent = env.element.parentElement;\n if (\n parent &&\n parent.nodeName.toLowerCase() === "pre" &&\n !parent.hasAttribute("tabindex")\n ) {\n parent.setAttribute("tabindex", "0");\n }\n\n if (!env.code) {\n _.hooks.run("complete", env);\n callback && callback.call(env.element);\n return;\n }\n\n _.hooks.run("before-highlight", env);\n\n if (!env.grammar) {\n insertHighlightedCode(_.util.encode(env.code));\n return;\n }\n\n if (async && _self.Worker) {\n var worker = new Worker(_.filename);\n\n worker.onmessage = function (evt) {\n insertHighlightedCode(evt.data);\n };\n\n worker.postMessage(\n JSON.stringify({\n language: env.language,\n code: env.code,\n immediateClose: true,\n })\n );\n } else {\n insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));\n }\n },\n\n /**\n * Low-level function, only use if you know what you\xe2\x80\x99re doing. It accepts a string of text as input\n * and the language definitions to use, and returns a string with the HTML produced.\n *\n * The following hooks will be run:\n * 1. `before-tokenize`\n * 2. `after-tokenize`\n * 3. `wrap`: On each {@link Token}.\n *\n * @param {string} text A string with the code to be highlighted.\n * @param {Grammar} grammar An object containing the tokens to use.\n *\n * Usually a language definition like `Prism.languages.markup`.\n * @param {string} language The name of the language definition passed to `grammar`.\n * @returns {string} The highlighted HTML.\n * @memberof Prism\n * @public\n * @example\n * Prism.highlight(\'var foo = true;\', Prism.languages.javascript, \'javascript\');\n */\n highlight: function (text, grammar, language) {\n var env = {\n code: text,\n grammar: grammar,\n language: language,\n };\n _.hooks.run("before-tokenize", env);\n env.tokens = _.tokenize(env.code, env.grammar);\n _.hooks.run("after-tokenize", env);\n return Token.stringify(_.util.encode(env.tokens), env.language);\n },\n\n /**\n * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input\n * and the language definitions to use, and returns an array with the tokenized code.\n *\n * When the language definition includes nested tokens, the function is called recursively on each of these tokens.\n *\n * This method could be useful in other contexts as well, as a very crude parser.\n *\n * @param {string} text A string with the code to be highlighted.\n * @param {Grammar} grammar An object containing the tokens to use.\n *\n * Usually a language definition like `Prism.languages.markup`.\n * @returns {TokenStream} An array of strings and tokens, a token stream.\n * @memberof Prism\n * @public\n * @example\n * let code = `var foo = 0;`;\n * let tokens = Prism.tokenize(code, Prism.languages.javascript);\n * tokens.forEach(token => {\n * if (token instanceof Prism.Token && token.type === \'number\') {\n * console.log(`Found numeric literal: ${token.content}`);\n * }\n * });\n */\n tokenize: function (text, grammar) {\n var rest = grammar.rest;\n if (rest) {\n for (var token in rest) {\n grammar[token] = rest[token];\n }\n\n delete grammar.rest;\n }\n\n var tokenList = new LinkedList();\n addAfter(tokenList, tokenList.head, text);\n\n matchGrammar(text, tokenList, grammar, tokenList.head, 0);\n\n return toArray(tokenList);\n },\n\n /**\n * @namespace\n * @memberof Prism\n * @public\n */\n hooks: {\n all: {},\n\n /**\n * Adds the given callback to the list of callbacks for the given hook.\n *\n * The callback will be invoked when the hook it is registered for is run.\n * Hooks are usually directly run by a highlight function but you can also run hooks yourself.\n *\n * One callback function can be registered to multiple hooks and the same hook multiple times.\n *\n * @param {string} name The name of the hook.\n * @param {HookCallback} callback The callback function which is given environment variables.\n * @public\n */\n add: function (name, callback) {\n var hooks = _.hooks.all;\n\n hooks[name] = hooks[name] || [];\n\n hooks[name].push(callback);\n },\n\n /**\n * Runs a hook invoking all registered callbacks with the given environment variables.\n *\n * Callbacks will be invoked synchronously and in the order in which they were registered.\n *\n * @param {string} name The name of the hook.\n * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.\n * @public\n */\n run: function (name, env) {\n var callbacks = _.hooks.all[name];\n\n if (!callbacks || !callbacks.length) {\n return;\n }\n\n for (var i = 0, callback; (callback = callbacks[i++]); ) {\n callback(env);\n }\n },\n },\n\n Token: Token,\n };\n _self.Prism = _;\n\n // Typescript note:\n // The following can be used to import the Token type in JSDoc:\n //\n // @typedef {InstanceType<import("./prism-core")["Token"]>} Token\n\n /**\n * Creates a new token.\n *\n * @param {string} type See {@link Token#type type}\n * @param {string | TokenStream} content See {@link Token#content content}\n * @param {string|string[]} [alias] The alias(es) of the token.\n * @param {string} [matchedStr=""] A copy of the full string this token was created from.\n * @class\n * @global\n * @public\n */\n function Token(type, content, alias, matchedStr) {\n /**\n * The type of the token.\n *\n * This is usually the key of a pattern in a {@link Grammar}.\n *\n * @type {string}\n * @see GrammarToken\n * @public\n */\n this.type = type;\n /**\n * The strings or tokens contained by this token.\n *\n * This will be a token stream if the pattern matched also defined an `inside` grammar.\n *\n * @type {string | TokenStream}\n * @public\n */\n this.content = content;\n /**\n * The alias(es) of the token.\n *\n * @type {string|string[]}\n * @see GrammarToken\n * @public\n */\n this.alias = alias;\n // Copy of the full string this token was created from\n this.length = (matchedStr || "").length | 0;\n }\n\n /**\n * A token stream is an array of strings and {@link Token Token} objects.\n *\n * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process\n * them.\n *\n * 1. No adjacent strings.\n * 2. No empty strings.\n *\n * The only exception here is the token stream that only contains the empty string and nothing else.\n *\n * @typedef {Array<string | Token>} TokenStream\n * @global\n * @public\n */\n\n /**\n * Converts the given token or token stream to an HTML representation.\n *\n * The following hooks will be run:\n * 1. `wrap`: On each {@link Token}.\n *\n * @param {string | Token | TokenStream} o The token or token stream to be converted.\n * @param {string} language The name of current language.\n * @returns {string} The HTML representation of the token or token stream.\n * @memberof Token\n * @static\n */\n Token.stringify = function stringify(o, language) {\n if (typeof o == "string") {\n return o;\n }\n if (Array.isArray(o)) {\n var s = "";\n o.forEach(function (e) {\n s += stringify(e, language);\n });\n return s;\n }\n\n var env = {\n type: o.type,\n content: stringify(o.content, language),\n tag: "span",\n classes: ["token", o.type],\n attributes: {},\n language: language,\n };\n\n var aliases = o.alias;\n if (aliases) {\n if (Array.isArray(aliases)) {\n Array.prototype.push.apply(env.classes, aliases);\n } else {\n env.classes.push(aliases);\n }\n }\n\n _.hooks.run("wrap", env);\n\n var attributes = "";\n for (var name in env.attributes) {\n attributes +=\n " " +\n name +\n \'="\' +\n (env.attributes[name] || "").replace(/"/g, "&quot;") +\n \'"\';\n }\n\n return (\n "<" +\n env.tag +\n \' class="\' +\n env.classes.join(" ") +\n \'"\' +\n attributes +\n ">" +\n env.content +\n "</" +\n env.tag +\n ">"\n );\n };\n\n /**\n * @param {RegExp} pattern\n * @param {number} pos\n * @param {string} text\n * @param {boolean} lookbehind\n * @returns {RegExpExecArray | null}\n */\n function matchPattern(pattern, pos, text, lookbehind) {\n pattern.lastIndex = pos;\n var match = pattern.exec(text);\n if (match && lookbehind && match[1]) {\n // change the match to remove the text matched by the Prism lookbehind group\n var lookbehindLength = match[1].length;\n match.index += lookbehindLength;\n match[0] = match[0].slice(lookbehindLength);\n }\n return match;\n }\n\n /**\n * @param {string} text\n * @param {LinkedList<string | Token>} tokenList\n * @param {any} grammar\n * @param {LinkedListNode<string | Token>} startNode\n * @param {number} startPos\n * @param {RematchOptions} [rematch]\n * @returns {void}\n * @private\n *\n * @typedef RematchOptions\n * @property {string} cause\n * @property {number} reach\n */\n function matchGrammar(\n text,\n tokenList,\n grammar,\n startNode,\n startPos,\n rematch\n ) {\n for (var token in grammar) {\n if (!grammar.hasOwnProperty(token) || !grammar[token]) {\n continue;\n }\n\n var patterns = grammar[token];\n patterns = Array.isArray(patterns) ? patterns : [patterns];\n\n for (var j = 0; j < patterns.length; ++j) {\n if (rematch && rematch.cause == token + "," + j) {\n return;\n }\n\n var patternObj = patterns[j];\n var inside = patternObj.inside;\n var lookbehind = !!patternObj.lookbehind;\n var greedy = !!patternObj.greedy;\n var alias = patternObj.alias;\n\n if (greedy && !patternObj.pattern.global) {\n // Without the global flag, lastIndex won\'t work\n var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];\n patternObj.pattern = RegExp(patternObj.pattern.source, flags + "g");\n }\n\n /** @type {RegExp} */\n var pattern = patternObj.pattern || patternObj;\n\n for (\n // iterate the token list and keep track of the current token/string position\n var currentNode = startNode.next, pos = startPos;\n currentNode !== tokenList.tail;\n pos += currentNode.value.length, currentNode = currentNode.next\n ) {\n if (rematch && pos >= rematch.reach) {\n break;\n }\n\n var str = currentNode.value;\n\n if (tokenList.length > text.length) {\n // Something went terribly wrong, ABORT, ABORT!\n return;\n }\n\n if (str instanceof Token) {\n continue;\n }\n\n var removeCount = 1; // this is the to parameter of removeBetween\n var match;\n\n if (greedy) {\n match = matchPattern(pattern, pos, text, lookbehind);\n if (!match || match.index >= text.length) {\n break;\n }\n\n var from = match.index;\n var to = match.index + match[0].length;\n var p = pos;\n\n // find the node that contains the match\n p += currentNode.value.length;\n while (from >= p) {\n currentNode = currentNode.next;\n p += currentNode.value.length;\n }\n // adjust pos (and p)\n p -= currentNode.value.length;\n pos = p;\n\n // the current node is a Token, then the match starts inside another Token, which is invalid\n if (currentNode.value instanceof Token) {\n continue;\n }\n\n // find the last node which is affected by this match\n for (\n var k = currentNode;\n k !== tokenList.tail && (p < to || typeof k.value === "string");\n k = k.next\n ) {\n removeCount++;\n p += k.value.length;\n }\n removeCount--;\n\n // replace with the new match\n str = text.slice(pos, p);\n match.index -= pos;\n } else {\n match = matchPattern(pattern, 0, str, lookbehind);\n if (!match) {\n continue;\n }\n }\n\n // eslint-disable-next-line no-redeclare\n var from = match.index;\n var matchStr = match[0];\n var before = str.slice(0, from);\n var after = str.slice(from + matchStr.length);\n\n var reach = pos + str.length;\n if (rematch && reach > rematch.reach) {\n rematch.reach = reach;\n }\n\n var removeFrom = currentNode.prev;\n\n if (before) {\n removeFrom = addAfter(tokenList, removeFrom, before);\n pos += before.length;\n }\n\n removeRange(tokenList, removeFrom, removeCount);\n\n var wrapped = new Token(\n token,\n inside ? _.tokenize(matchStr, inside) : matchStr,\n alias,\n matchStr\n );\n currentNode = addAfter(tokenList, removeFrom, wrapped);\n\n if (after) {\n addAfter(tokenList, currentNode, after);\n }\n\n if (removeCount > 1) {\n // at least one Token object was removed, so we have to do some rematching\n // this can only happen if the current pattern is greedy\n\n /** @type {RematchOptions} */\n var nestedRematch = {\n cause: token + "," + j,\n reach: reach,\n };\n matchGrammar(\n text,\n tokenList,\n grammar,\n currentNode.prev,\n pos,\n nestedRematch\n );\n\n // the reach might have been extended because of the rematching\n if (rematch && nestedRematch.reach > rematch.reach) {\n rematch.reach = nestedRematch.reach;\n }\n }\n }\n }\n }\n }\n\n /**\n * @typedef LinkedListNode\n * @property {T} value\n * @property {LinkedListNode<T> | null} prev The previous node.\n * @property {LinkedListNode<T> | null} next The next node.\n * @template T\n * @private\n */\n\n /**\n * @template T\n * @private\n */\n function LinkedList() {\n /** @type {LinkedListNode<T>} */\n var head = { value: null, prev: null, next: null };\n /** @type {LinkedListNode<T>} */\n var tail = { value: null, prev: head, next: null };\n head.next = tail;\n\n /** @type {LinkedListNode<T>} */\n this.head = head;\n /** @type {LinkedListNode<T>} */\n this.tail = tail;\n this.length = 0;\n }\n\n /**\n * Adds a new node with the given value to the list.\n *\n * @param {LinkedList<T>} list\n * @param {LinkedListNode<T>} node\n * @param {T} value\n * @returns {LinkedListNode<T>} The added node.\n * @template T\n */\n function addAfter(list, node, value) {\n // assumes that node != list.tail && values.length >= 0\n var next = node.next;\n\n var newNode = { value: value, prev: node, next: next };\n node.next = newNode;\n next.prev = newNode;\n list.length++;\n\n return newNode;\n }\n /**\n * Removes `count` nodes after the given node. The given node will not be removed.\n *\n * @param {LinkedList<T>} list\n * @param {LinkedListNode<T>} node\n * @param {number} count\n * @template T\n */\n function removeRange(list, node, count) {\n var next = node.next;\n for (var i = 0; i < count && next !== list.tail; i++) {\n next = next.next;\n }\n node.next = next;\n next.prev = node;\n list.length -= i;\n }\n /**\n * @param {LinkedList<T>} list\n * @returns {T[]}\n * @template T\n */\n function toArray(list) {\n var array = [];\n var node = list.head.next;\n while (node !== list.tail) {\n array.push(node.value);\n node = node.next;\n }\n return array;\n }\n\n if (!_self.document) {\n if (!_self.addEventListener) {\n // in Node.js\n return _;\n }\n\n if (!_.disableWorkerMessageHandler) {\n // In worker\n _self.addEventListener(\n "message",\n function (evt) {\n var message = JSON.parse(evt.data);\n var lang = message.language;\n var code = message.code;\n var immediateClose = message.immediateClose;\n\n _self.postMessage(_.highlight(code, _.languages[lang], lang));\n if (immediateClose) {\n _self.close();\n }\n },\n false\n );\n }\n\n return _;\n }\n\n // Get current script and highlight\n var script = _.util.currentScript();\n\n if (script) {\n _.filename = script.src;\n\n if (script.hasAttribute("data-manual")) {\n _.manual = true;\n }\n }\n\n function highlightAutomaticallyCallback() {\n if (!_.manual) {\n _.highlightAll();\n }\n }\n\n if (!_.manual) {\n // If the document state is "loading", then we\'ll use DOMContentLoaded.\n // If the document state is "interactive" and the prism.js script is deferred, then we\'ll also use the\n // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they\n // might take longer one animation frame to execute which can create a race condition where only some plugins have\n // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.\n // See https://github.com/PrismJS/prism/issues/2102\n var readyState = document.readyState;\n if (\n readyState === "loading" ||\n (readyState === "interactive" && script && script.defer)\n ) {\n document.addEventListener(\n "DOMContentLoaded",\n highlightAutomaticallyCallback\n );\n } else {\n if (window.requestAnimationFrame) {\n window.requestAnimationFrame(highlightAutomaticallyCallback);\n } else {\n window.setTimeout(highlightAutomaticallyCallback, 16);\n }\n }\n }\n\n return _;\n})(_self);\n\nif (typeof module !== "undefined" && module.exports) {\n module.exports = Prism;\n}\n\n// hack for components to work correctly in node.js\nif (typeof global !== "undefined") {\n global.Prism = Prism;\n}\n\n// some additional documentation/types\n\n/**\n * The expansion of a simple `RegExp` literal to support additional properties.\n *\n * @typedef GrammarToken\n * @property {RegExp} pattern The regular expression of the token.\n * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)\n * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.\n * @property {boolean} [greedy=false] Whether the token is greedy.\n * @property {string|string[]} [alias] An optional alias or list of aliases.\n * @property {Grammar} [inside] The nested grammar of this token.\n *\n * The `inside` grammar will be used to tokenize the text value of each token of this kind.\n *\n * This can be used to make nested and even recursive language definitions.\n *\n * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into\n * each another.\n * @global\n * @public\n */\n\n/**\n * @typedef Grammar\n * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}\n * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.\n * @global\n * @public\n */\n\n/**\n * A function which will invoked after an element was successfully highlighted.\n *\n * @callback HighlightCallback\n * @param {Element} element The element successfully highlighted.\n * @returns {void}\n * @global\n * @public\n */\n\n/**\n * @callback HookCallback\n * @param {Object<string, any>} env The environment variables of the hook.\n * @returns {void}\n * @global\n * @public\n */\nPrism.languages.markup = {\n comment: {\n pattern: /<!--(?:(?!<!--)[\\s\\S])*?-->/,\n greedy: true,\n },\n prolog: {\n pattern: /<\\?[\\s\\S]+?\\?>/,\n greedy: true,\n },\n doctype: {\n // https://www.w3.org/TR/xml/#NT-doctypedecl\n pattern:\n /<!DOCTYPE(?:[^>"\'[\\]]|"[^"]*"|\'[^\']*\')+(?:\\[(?:[^<"\'\\]]|"[^"]*"|\'[^\']*\'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\\]\\s*)?>/i,\n greedy: true,\n inside: {\n "internal-subset": {\n pattern: /(^[^\\[]*\\[)[\\s\\S]+(?=\\]>$)/,\n lookbehind: true,\n greedy: true,\n inside: null, // see below\n },\n string: {\n pattern: /"[^"]*"|\'[^\']*\'/,\n greedy: true,\n },\n punctuation: /^<!|>$|[[\\]]/,\n "doctype-tag": /^DOCTYPE/i,\n name: /[^\\s<>\'"]+/,\n },\n },\n cdata: {\n pattern: /<!\\[CDATA\\[[\\s\\S]*?\\]\\]>/i,\n greedy: true,\n },\n tag: {\n pattern:\n /<\\/?(?!\\d)[^\\s>\\/=$<%]+(?:\\s(?:\\s*[^\\s>\\/=]+(?:\\s*=\\s*(?:"[^"]*"|\'[^\']*\'|[^\\s\'">=]+(?=[\\s>]))|(?=[\\s/>])))+)?\\s*\\/?>/,\n greedy: true,\n inside: {\n tag: {\n pattern: /^<\\/?[^\\s>\\/]+/,\n inside: {\n punctuation: /^<\\/?/,\n namespace: /^[^\\s>\\/:]+:/,\n },\n },\n "special-attr": [],\n "attr-value": {\n pattern: /=\\s*(?:"[^"]*"|\'[^\']*\'|[^\\s\'">=]+)/,\n inside: {\n punctuation: [\n {\n pattern: /^=/,\n alias: "attr-equals",\n },\n /"|\'/,\n ],\n },\n },\n punctuation: /\\/?>/,\n "attr-name": {\n pattern: /[^\\s>\\/]+/,\n inside: {\n namespace: /^[^\\s>\\/:]+:/,\n },\n },\n },\n },\n entity: [\n {\n pattern: /&[\\da-z]{1,8};/i,\n alias: "named-entity",\n },\n /&#x?[\\da-f]{1,8};/i,\n ],\n};\n\nPrism.languages.markup["tag"].inside["attr-value"].inside["entity"] =\n Prism.languages.markup["entity"];\nPrism.languages.markup["doctype"].inside["internal-subset"].inside =\n Prism.languages.markup;\n\n// Plugin to make entity title show the real entity, idea by Roman Komarov\nPrism.hooks.add("wrap", function (env) {\n if (env.type === "entity") {\n env.attributes["title"] = env.content.replace(/&amp;/, "&");\n }\n});\n\nObject.defineProperty(Prism.languages.markup.tag, "addInlined", {\n /**\n * Adds an inlined language to markup.\n *\n * An example of an inlined language is CSS with `<style>` tags.\n *\n * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as\n * case insensitive.\n * @param {string} lang The language key.\n * @example\n * addInlined(\'style\', \'css\');\n */\n value: function addInlined(tagName, lang) {\n var includedCdataInside = {};\n includedCdataInside["language-" + lang] = {\n pattern: /(^<!\\[CDATA\\[)[\\s\\S]+?(?=\\]\\]>$)/i,\n lookbehind: true,\n inside: Prism.languages[lang],\n };\n includedCdataInside["cdata"] = /^<!\\[CDATA\\[|\\]\\]>$/i;\n\n var inside = {\n "included-cdata": {\n pattern: /<!\\[CDATA\\[[\\s\\S]*?\\]\\]>/i,\n inside: includedCdataInside,\n },\n };\n inside["language-" + lang] = {\n pattern: /[\\s\\S]+/,\n inside: Prism.languages[lang],\n };\n\n var def = {};\n def[tagName] = {\n pattern: RegExp(\n /(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[\\s\\S])*?(?=<\\/__>)/.source.replace(\n /__/g,\n function () {\n return tagName;\n }\n ),\n "i"\n ),\n lookbehind: true,\n greedy: true,\n inside: inside,\n };\n\n Prism.languages.insertBefore("markup", "cdata", def);\n },\n});\nObject.defineProperty(Prism.languages.markup.tag, "addAttribute", {\n /**\n * Adds an pattern to highlight languages embedded in HTML attributes.\n *\n * An example of an inlined language is CSS with `style` attributes.\n *\n * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as\n * case insensitive.\n * @param {string} lang The language key.\n * @example\n * addAttribute(\'style\', \'css\');\n */\n value: function (attrName, lang) {\n Prism.languages.markup.tag.inside["special-attr"].push({\n pattern: RegExp(\n /(^|["\'\\s])/.source +\n "(?:" +\n attrName +\n ")" +\n /\\s*=\\s*(?:"[^"]*"|\'[^\']*\'|[^\\s\'">=]+(?=[\\s>]))/.source,\n "i"\n ),\n lookbehind: true,\n inside: {\n "attr-name": /^[^\\s=]+/,\n "attr-value": {\n pattern: /=[\\s\\S]+/,\n inside: {\n value: {\n pattern: /(^=\\s*(["\']|(?!["\'])))\\S[\\s\\S]*(?=\\2$)/,\n lookbehind: true,\n alias: [lang, "language-" + lang],\n inside: Prism.languages[lang],\n },\n punctuation: [\n {\n pattern: /^=/,\n alias: "attr-equals",\n },\n /"|\'/,\n ],\n },\n },\n },\n });\n },\n});\n\nPrism.languages.html = Prism.languages.markup;\nPrism.languages.mathml = Prism.languages.markup;\nPrism.languages.svg = Prism.languages.markup;\n\nPrism.languages.xml = Prism.languages.extend("markup", {});\nPrism.languages.ssml = Prism.languages.xml;\nPrism.languages.atom = Prism.languages.xml;\nPrism.languages.rss = Prism.languages.xml;\n\n(function (Prism) {\n var string =\n /(?:"(?:\\\\(?:\\r\\n|[\\s\\S])|[^"\\\\\\r\\n])*"|\'(?:\\\\(?:\\r\\n|[\\s\\S])|[^\'\\\\\\r\\n])*\')/;\n\n Prism.languages.css = {\n comment: /\\/\\*[\\s\\S]*?\\*\\//,\n atrule: {\n pattern: /@[\\w-](?:[^;{\\s]|\\s+(?![\\s{]))*(?:;|(?=\\s*\\{))/,\n inside: {\n rule: /^@[\\w-]+/,\n "selector-function-argument": {\n pattern:\n /(\\bselector\\s*\\(\\s*(?![\\s)]))(?:[^()\\s]|\\s+(?![\\s)])|\\((?:[^()]|\\([^()]*\\))*\\))+(?=\\s*\\))/,\n lookbehind: true,\n alias: "selector",\n },\n keyword: {\n pattern: /(^|[^\\w-])(?:and|not|only|or)(?![\\w-])/,\n lookbehind: true,\n },\n // See rest below\n },\n },\n url: {\n // https://drafts.csswg.org/css-values-3/#urls\n pattern: RegExp(\n "\\\\burl\\\\((?:" +\n string.source +\n "|" +\n /(?:[^\\\\\\r\\n()"\']|\\\\[\\s\\S])*/.source +\n ")\\\\)",\n "i"\n ),\n greedy: true,\n inside: {\n function: /^url/i,\n punctuation: /^\\(|\\)$/,\n string: {\n pattern: RegExp("^" + string.source + "$"),\n alias: "url",\n },\n },\n },\n selector: {\n pattern: RegExp(\n "(^|[{}\\\\s])[^{}\\\\s](?:[^{};\\"\'\\\\s]|\\\\s+(?![\\\\s{])|" +\n string.source +\n ")*(?=\\\\s*\\\\{)"\n ),\n lookbehind: true,\n },\n string: {\n pattern: string,\n greedy: true,\n },\n property: {\n pattern:\n /(^|[^-\\w\\xA0-\\uFFFF])(?!\\s)[-_a-z\\xA0-\\uFFFF](?:(?!\\s)[-\\w\\xA0-\\uFFFF])*(?=\\s*:)/i,\n lookbehind: true,\n },\n important: /!important\\b/i,\n function: {\n pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\\()/i,\n lookbehind: true,\n },\n punctuation: /[(){};:,]/,\n };\n\n Prism.languages.css["atrule"].inside.rest = Prism.languages.css;\n\n var markup = Prism.languages.markup;\n if (markup) {\n markup.tag.addInlined("style", "css");\n markup.tag.addAttribute("style", "css");\n }\n})(Prism);\n\nPrism.languages.clike = {\n comment: [\n {\n pattern: /(^|[^\\\\])\\/\\*[\\s\\S]*?(?:\\*\\/|$)/,\n lookbehind: true,\n greedy: true,\n },\n {\n pattern: /(^|[^\\\\:])\\/\\/.*/,\n lookbehind: true,\n greedy: true,\n },\n ],\n string: {\n pattern: /(["\'])(?:\\\\(?:\\r\\n|[\\s\\S])|(?!\\1)[^\\\\\\r\\n])*\\1/,\n greedy: true,\n },\n "class-name": {\n pattern:\n /(\\b(?:class|extends|implements|instanceof|interface|new|trait)\\s+|\\bcatch\\s+\\()[\\w.\\\\]+/i,\n lookbehind: true,\n inside: {\n punctuation: /[.\\\\]/,\n },\n },\n keyword:\n /\\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\\b/,\n boolean: /\\b(?:false|true)\\b/,\n function: /\\b\\w+(?=\\()/,\n number: /\\b0x[\\da-f]+\\b|(?:\\b\\d+(?:\\.\\d*)?|\\B\\.\\d+)(?:e[+-]?\\d+)?/i,\n operator: /[<>]=?|[!=]=?=?|--?|\\+\\+?|&&?|\\|\\|?|[?*/~^%]/,\n punctuation: /[{}[\\];(),.:]/,\n};\n\nPrism.languages.javascript = Prism.languages.extend("clike", {\n "class-name": [\n Prism.languages.clike["class-name"],\n {\n pattern:\n /(^|[^$\\w\\xA0-\\uFFFF])(?!\\s)[_$A-Z\\xA0-\\uFFFF](?:(?!\\s)[$\\w\\xA0-\\uFFFF])*(?=\\.(?:constructor|prototype))/,\n lookbehind: true,\n },\n ],\n keyword: [\n {\n pattern: /((?:^|\\})\\s*)catch\\b/,\n lookbehind: true,\n },\n {\n pattern:\n /(^|[^.]|\\.\\.\\.\\s*)\\b(?:as|assert(?=\\s*\\{)|async(?=\\s*(?:function\\b|\\(|[$\\w\\xA0-\\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\\s*(?:\\{|$))|for|from(?=\\s*(?:[\'"]|$))|function|(?:get|set)(?=\\s*(?:[#\\[$\\w\\xA0-\\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\\b/,\n lookbehind: true,\n },\n ],\n // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)\n function:\n /#?(?!\\s)[_$a-zA-Z\\xA0-\\uFFFF](?:(?!\\s)[$\\w\\xA0-\\uFFFF])*(?=\\s*(?:\\.\\s*(?:apply|bind|call)\\s*)?\\()/,\n number: {\n pattern: RegExp(\n /(^|[^\\w$])/.source +\n "(?:" +\n // constant\n (/NaN|Infinity/.source +\n "|" +\n // binary integer\n /0[bB][01]+(?:_[01]+)*n?/.source +\n "|" +\n // octal integer\n /0[oO][0-7]+(?:_[0-7]+)*n?/.source +\n "|" +\n // hexadecimal integer\n /0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?/.source +\n "|" +\n // decimal bigint\n /\\d+(?:_\\d+)*n/.source +\n "|" +\n // decimal number (integer or float) but no bigint\n /(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?/\n .source) +\n ")" +\n /(?![\\w$])/.source\n ),\n lookbehind: true,\n },\n operator:\n /--|\\+\\+|\\*\\*=?|=>|&&=?|\\|\\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\\.{3}|\\?\\?=?|\\?\\.?|[~:]/,\n});\n\nPrism.languages.javascript["class-name"][0].pattern =\n /(\\b(?:class|extends|implements|instanceof|interface|new)\\s+)[\\w.\\\\]+/;\n\nPrism.languages.insertBefore("javascript", "keyword", {\n regex: {\n // eslint-disable-next-line regexp/no-dupe-characters-character-class\n pattern:\n /((?:^|[^$\\w\\xA0-\\uFFFF."\'\\])\\s]|\\b(?:return|yield))\\s*)\\/(?:\\[(?:[^\\]\\\\\\r\\n]|\\\\.)*\\]|\\\\.|[^/\\\\\\[\\r\\n])+\\/[dgimyus]{0,7}(?=(?:\\s|\\/\\*(?:[^*]|\\*(?!\\/))*\\*\\/)*(?:$|[\\r\\n,.;:})\\]]|\\/\\/))/,\n lookbehind: true,\n greedy: true,\n inside: {\n "regex-source": {\n pattern: /^(\\/)[\\s\\S]+(?=\\/[a-z]*$)/,\n lookbehind: true,\n alias: "language-regex",\n inside: Prism.languages.regex,\n },\n "regex-delimiter": /^\\/|\\/$/,\n "regex-flags": /^[a-z]+$/,\n },\n },\n // This must be declared before keyword because we use "function" inside the look-forward\n "function-variable": {\n pattern:\n /#?(?!\\s)[_$a-zA-Z\\xA0-\\uFFFF](?:(?!\\s)[$\\w\\xA0-\\uFFFF])*(?=\\s*[=:]\\s*(?:async\\s*)?(?:\\bfunction\\b|(?:\\((?:[^()]|\\([^()]*\\))*\\)|(?!\\s)[_$a-zA-Z\\xA0-\\uFFFF](?:(?!\\s)[$\\w\\xA0-\\uFFFF])*)\\s*=>))/,\n alias: "function",\n },\n parameter: [\n {\n pattern:\n /(function(?:\\s+(?!\\s)[_$a-zA-Z\\xA0-\\uFFFF](?:(?!\\s)[$\\w\\xA0-\\uFFFF])*)?\\s*\\(\\s*)(?!\\s)(?:[^()\\s]|\\s+(?![\\s)])|\\([^()]*\\))+(?=\\s*\\))/,\n lookbehind: true,\n inside: Prism.languages.javascript,\n },\n {\n pattern:\n /(^|[^$\\w\\xA0-\\uFFFF])(?!\\s)[_$a-z\\xA0-\\uFFFF](?:(?!\\s)[$\\w\\xA0-\\uFFFF])*(?=\\s*=>)/i,\n lookbehind: true,\n inside: Prism.languages.javascript,\n },\n {\n pattern:\n /(\\(\\s*)(?!\\s)(?:[^()\\s]|\\s+(?![\\s)])|\\([^()]*\\))+(?=\\s*\\)\\s*=>)/,\n lookbehind: true,\n inside: Prism.languages.javascript,\n },\n {\n pattern:\n /((?:\\b|\\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\\w\\xA0-\\uFFFF]))(?:(?!\\s)[_$a-zA-Z\\xA0-\\uFFFF](?:(?!\\s)[$\\w\\xA0-\\uFFFF])*\\s*)\\(\\s*|\\]\\s*\\(\\s*)(?!\\s)(?:[^()\\s]|\\s+(?![\\s)])|\\([^()]*\\))+(?=\\s*\\)\\s*\\{)/,\n lookbehind: true,\n inside: Prism.languages.javascript,\n },\n ],\n constant: /\\b[A-Z](?:[A-Z_]|\\dx?)*\\b/,\n});\n\nPrism.languages.insertBefore("javascript", "string", {\n hashbang: {\n pattern: /^#!.*/,\n greedy: true,\n alias: "comment",\n },\n "template-string": {\n pattern:\n /`(?:\\\\[\\s\\S]|\\$\\{(?:[^{}]|\\{(?:[^{}]|\\{[^}]*\\})*\\})+\\}|(?!\\$\\{)[^\\\\`])*`/,\n greedy: true,\n inside: {\n "template-punctuation": {\n pattern: /^`|`$/,\n alias: "string",\n },\n interpolation: {\n pattern:\n /((?:^|[^\\\\])(?:\\\\{2})*)\\$\\{(?:[^{}]|\\{(?:[^{}]|\\{[^}]*\\})*\\})+\\}/,\n lookbehind: true,\n inside: {\n "interpolation-punctuation": {\n pattern: /^\\$\\{|\\}$/,\n alias: "punctuation",\n },\n rest: Prism.languages.javascript,\n },\n },\n string: /[\\s\\S]+/,\n },\n },\n "string-property": {\n pattern:\n /((?:^|[,{])[ \\t]*)(["\'])(?:\\\\(?:\\r\\n|[\\s\\S])|(?!\\2)[^\\\\\\r\\n])*\\2(?=\\s*:)/m,\n lookbehind: true,\n greedy: true,\n alias: "property",\n },\n});\n\nPrism.languages.insertBefore("javascript", "operator", {\n "literal-property": {\n pattern:\n /((?:^|[,{])[ \\t]*)(?!\\s)[_$a-zA-Z\\xA0-\\uFFFF](?:(?!\\s)[$\\w\\xA0-\\uFFFF])*(?=\\s*:)/m,\n lookbehind: true,\n alias: "property",\n },\n});\n\nif (Prism.languages.markup) {\n Prism.languages.markup.tag.addInlined("script", "javascript");\n\n // add attribute support for all DOM events.\n // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events\n Prism.languages.markup.tag.addAttribute(\n /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/\n .source,\n "javascript"\n );\n}\n\nPrism.languages.js = Prism.languages.javascript;\n\nPrism.languages.python = {\n comment: {\n pattern: /(^|[^\\\\])#.*/,\n lookbehind: true,\n greedy: true,\n },\n "string-interpolation": {\n pattern:\n /(?:f|fr|rf)(?:("""|\'\'\')[\\s\\S]*?\\1|("|\')(?:\\\\.|(?!\\2)[^\\\\\\r\\n])*\\2)/i,\n greedy: true,\n inside: {\n interpolation: {\n // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"\n pattern:\n /((?:^|[^{])(?:\\{\\{)*)\\{(?!\\{)(?:[^{}]|\\{(?!\\{)(?:[^{}]|\\{(?!\\{)(?:[^{}])+\\})+\\})+\\}/,\n lookbehind: true,\n inside: {\n "format-spec": {\n pattern: /(:)[^:(){}]+(?=\\}$)/,\n lookbehind: true,\n },\n "conversion-option": {\n pattern: /![sra](?=[:}]$)/,\n alias: "punctuation",\n },\n rest: null,\n },\n },\n string: /[\\s\\S]+/,\n },\n },\n "triple-quoted-string": {\n pattern: /(?:[rub]|br|rb)?("""|\'\'\')[\\s\\S]*?\\1/i,\n greedy: true,\n alias: "string",\n },\n string: {\n pattern: /(?:[rub]|br|rb)?("|\')(?:\\\\.|(?!\\1)[^\\\\\\r\\n])*\\1/i,\n greedy: true,\n },\n function: {\n pattern: /((?:^|\\s)def[ \\t]+)[a-zA-Z_]\\w*(?=\\s*\\()/g,\n lookbehind: true,\n },\n "class-name": {\n pattern: /(\\bclass\\s+)\\w+/i,\n lookbehind: true,\n },\n decorator: {\n pattern: /(^[\\t ]*)@\\w+(?:\\.\\w+)*/m,\n lookbehind: true,\n alias: ["annotation", "punctuation"],\n inside: {\n punctuation: /\\./,\n },\n },\n keyword:\n /\\b(?:_(?=\\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\\b/,\n builtin:\n /\\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\\b/,\n boolean: /\\b(?:False|None|True)\\b/,\n number:\n /\\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\\b|(?:\\b\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\B\\.\\d+(?:_\\d+)*)(?:e[+-]?\\d+(?:_\\d+)*)?j?(?!\\w)/i,\n operator: /[-+%=]=?|!=|:=|\\*\\*?=?|\\/\\/?=?|<[<=>]?|>[=>]?|[&|^~]/,\n punctuation: /[{}[\\];(),.:]/,\n};\n\nPrism.languages.python["string-interpolation"].inside[\n "interpolation"\n].inside.rest = Prism.languages.python;\n\nPrism.languages.py = Prism.languages.python;\n\n(function () {\n if (typeof Prism === "undefined") {\n return;\n }\n\n var assign =\n Object.assign ||\n function (obj1, obj2) {\n for (var name in obj2) {\n if (obj2.hasOwnProperty(name)) {\n obj1[name] = obj2[name];\n }\n }\n return obj1;\n };\n\n function NormalizeWhitespace(defaults) {\n this.defaults = assign({}, defaults);\n }\n\n function toCamelCase(value) {\n return value.replace(/-(\\w)/g, function (match, firstChar) {\n return firstChar.toUpperCase();\n });\n }\n\n function tabLen(str) {\n var res = 0;\n for (var i = 0; i < str.length; ++i) {\n if (str.charCodeAt(i) == "\\t".charCodeAt(0)) {\n res += 3;\n }\n }\n return str.length + res;\n }\n\n NormalizeWhitespace.prototype = {\n setDefaults: function (defaults) {\n this.defaults = assign(this.defaults, defaults);\n },\n normalize: function (input, settings) {\n settings = assign(this.defaults, settings);\n\n for (var name in settings) {\n var methodName = toCamelCase(name);\n if (\n name !== "normalize" &&\n methodName !== "setDefaults" &&\n settings[name] &&\n this[methodName]\n ) {\n input = this[methodName].call(this, input, settings[name]);\n }\n }\n\n return input;\n },\n\n /*\n * Normalization methods\n */\n leftTrim: function (input) {\n return input.replace(/^\\s+/, "");\n },\n rightTrim: function (input) {\n return input.replace(/\\s+$/, "");\n },\n tabsToSpaces: function (input, spaces) {\n spaces = spaces | 0 || 4;\n return input.replace(/\\t/g, new Array(++spaces).join(" "));\n },\n spacesToTabs: function (input, spaces) {\n spaces = spaces | 0 || 4;\n return input.replace(RegExp(" {" + spaces + "}", "g"), "\\t");\n },\n removeTrailing: function (input) {\n return input.replace(/\\s*?$/gm, "");\n },\n // Support for deprecated plugin remove-initial-line-feed\n removeInitialLineFeed: function (input) {\n return input.replace(/^(?:\\r?\\n|\\r)/, "");\n },\n removeIndent: function (input) {\n var indents = input.match(/^[^\\S\\n\\r]*(?=\\S)/gm);\n\n if (!indents || !indents[0].length) {\n return input;\n }\n\n indents.sort(function (a, b) {\n return a.length - b.length;\n });\n\n if (!indents[0].length) {\n return input;\n }\n\n return input.replace(RegExp("^" + indents[0], "gm"), "");\n },\n indent: function (input, tabs) {\n return input.replace(\n /^[^\\S\\n\\r]*(?=\\S)/gm,\n new Array(++tabs).join("\\t") + "$&"\n );\n },\n breakLines: function (input, characters) {\n characters = characters === true ? 80 : characters | 0 || 80;\n\n var lines = input.split("\\n");\n for (var i = 0; i < lines.length; ++i) {\n if (tabLen(lines[i]) <= characters) {\n continue;\n }\n\n var line = lines[i].split(/(\\s+)/g);\n var len = 0;\n\n for (var j = 0; j < line.length; ++j) {\n var tl = tabLen(line[j]);\n len += tl;\n if (len > characters) {\n line[j] = "\\n" + line[j];\n len = tl;\n }\n }\n lines[i] = line.join("");\n }\n return lines.join("\\n");\n },\n };\n\n // Support node modules\n if (typeof module !== "undefined" && module.exports) {\n module.exports = NormalizeWhitespace;\n }\n\n Prism.plugins.NormalizeWhitespace = new NormalizeWhitespace({\n "remove-trailing": true,\n "remove-indent": false,\n "left-trim": false,\n "right-trim": true,\n /*\'break-lines\': 80,\n\t\t\'indent\': 2,\n\t\t\'remove-initial-line-feed\': false,\n\t\t\'tabs-to-spaces\': 4,\n\t\t\'spaces-to-tabs\': 4*/\n });\n\n Prism.hooks.add("before-sanity-check", function (env) {\n var Normalizer = Prism.plugins.NormalizeWhitespace;\n\n // Check settings\n if (env.settings && env.settings["whitespace-normalization"] === false) {\n return;\n }\n\n // Check classes\n if (!Prism.util.isActive(env.element, "whitespace-normalization", true)) {\n return;\n }\n\n // Simple mode if there is no env.element\n if ((!env.element || !env.element.parentNode) && env.code) {\n env.code = Normalizer.normalize(env.code, env.settings);\n return;\n }\n\n // Normal mode\n var pre = env.element.parentNode;\n if (!env.code || !pre || pre.nodeName.toLowerCase() !== "pre") {\n return;\n }\n\n var children = pre.childNodes;\n var before = "";\n var after = "";\n var codeFound = false;\n\n // Move surrounding whitespace from the <pre> tag into the <code> tag\n for (var i = 0; i < children.length; ++i) {\n var node = children[i];\n\n if (node == env.element) {\n codeFound = true;\n } else if (node.nodeName === "#text") {\n if (codeFound) {\n after += node.nodeValue;\n } else {\n before += node.nodeValue;\n }\n\n pre.removeChild(node);\n --i;\n }\n }\n\n if (!env.element.children.length || !Prism.plugins.KeepMarkup) {\n env.code = before + env.code + after;\n env.code = Normalizer.normalize(env.code, env.settings);\n } else {\n // Preserve markup for keep-markup plugin\n var html = before + env.element.innerHTML + after;\n env.element.innerHTML = Normalizer.normalize(html, env.settings);\n env.code = env.element.textContent;\n }\n });\n})();\n', 17456, 17457, 'ordinal not in range(128)')
Traceback (most recent call last):
File "/p/home/jusers/virshup1/jureca/scverse_project/virshup1/miniconda3/envs/anndata-dev/lib/python3.11/site-packages/scalene/scalene_profiler.py", line 2054, in run_profiler
exit_status = profiler.profile_code(
^^^^^^^^^^^^^^^^^^^^^^
File "/p/home/jusers/virshup1/jureca/scverse_project/virshup1/miniconda3/envs/anndata-dev/lib/python3.11/site-packages/scalene/scalene_profiler.py", line 1802, in profile_code
generate_html(
File "/p/home/jusers/virshup1/jureca/scverse_project/virshup1/miniconda3/envs/anndata-dev/lib/python3.11/site-packages/scalene/scalene_utility.py", line 146, in generate_html
'prism_js_text': read_file_content(scalene_dir, "scalene-gui", "prism.js"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/p/home/jusers/virshup1/jureca/scverse_project/virshup1/miniconda3/envs/anndata-dev/lib/python3.11/site-packages/scalene/scalene_utility.py", line 126, in read_file_content
return pathlib.Path(file_path).read_text()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/p/home/jusers/virshup1/jureca/scverse_project/virshup1/miniconda3/envs/anndata-dev/lib/python3.11/pathlib.py", line 1059, in read_text
return f.read()
^^^^^^^^
File "/p/home/jusers/virshup1/jureca/scverse_project/virshup1/miniconda3/envs/anndata-dev/lib/python3.11/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 17456: ordinal not in range(128)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment