@rcarls/rc-markdown-editor 0.4.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"rc-editor-toolbar-QnCEnJ2R.js","sources":["../../../node_modules/decode-named-character-reference/index.dom.js","../../../node_modules/micromark-util-chunked/index.js","../../../node_modules/micromark-util-combine-extensions/index.js","../../../node_modules/micromark-util-decode-numeric-character-reference/index.js","../../../node_modules/micromark-util-encode/index.js","../../../node_modules/micromark-util-normalize-identifier/index.js","../../../node_modules/micromark-util-character/index.js","../../../node_modules/micromark-util-sanitize-uri/index.js","../../../node_modules/micromark/lib/compile.js","../../../node_modules/micromark-factory-space/index.js","../../../node_modules/micromark/lib/initialize/content.js","../../../node_modules/micromark/lib/initialize/document.js","../../../node_modules/micromark-util-classify-character/index.js","../../../node_modules/micromark-util-resolve-all/index.js","../../../node_modules/micromark-core-commonmark/lib/attention.js","../../../node_modules/micromark-core-commonmark/lib/autolink.js","../../../node_modules/micromark-core-commonmark/lib/blank-line.js","../../../node_modules/micromark-core-commonmark/lib/block-quote.js","../../../node_modules/micromark-core-commonmark/lib/character-escape.js","../../../node_modules/micromark-core-commonmark/lib/character-reference.js","../../../node_modules/micromark-core-commonmark/lib/code-fenced.js","../../../node_modules/micromark-core-commonmark/lib/code-indented.js","../../../node_modules/micromark-core-commonmark/lib/code-text.js","../../../node_modules/micromark-util-subtokenize/lib/splice-buffer.js","../../../node_modules/micromark-util-subtokenize/index.js","../../../node_modules/micromark-core-commonmark/lib/content.js","../../../node_modules/micromark-factory-destination/index.js","../../../node_modules/micromark-factory-label/index.js","../../../node_modules/micromark-factory-title/index.js","../../../node_modules/micromark-factory-whitespace/index.js","../../../node_modules/micromark-core-commonmark/lib/definition.js","../../../node_modules/micromark-core-commonmark/lib/hard-break-escape.js","../../../node_modules/micromark-core-commonmark/lib/heading-atx.js","../../../node_modules/micromark-util-html-tag-name/index.js","../../../node_modules/micromark-core-commonmark/lib/html-flow.js","../../../node_modules/micromark-core-commonmark/lib/html-text.js","../../../node_modules/micromark-core-commonmark/lib/label-end.js","../../../node_modules/micromark-core-commonmark/lib/label-start-image.js","../../../node_modules/micromark-core-commonmark/lib/label-start-link.js","../../../node_modules/micromark-core-commonmark/lib/line-ending.js","../../../node_modules/micromark-core-commonmark/lib/thematic-break.js","../../../node_modules/micromark-core-commonmark/lib/list.js","../../../node_modules/micromark-core-commonmark/lib/setext-underline.js","../../../node_modules/micromark/lib/initialize/flow.js","../../../node_modules/micromark/lib/initialize/text.js","../../../node_modules/micromark/lib/constructs.js","../../../node_modules/micromark/lib/create-tokenizer.js","../../../node_modules/micromark/lib/parse.js","../../../node_modules/micromark/lib/postprocess.js","../../../node_modules/micromark/lib/preprocess.js","../../../node_modules/micromark/index.js","../../../node_modules/micromark-extension-gfm-strikethrough/lib/syntax.js","../../../node_modules/turndown/lib/turndown.browser.es.js","../../../node_modules/mdast-util-to-string/lib/index.js","../../../node_modules/micromark-util-decode-string/index.js","../../../node_modules/unist-util-stringify-position/lib/index.js","../../../node_modules/mdast-util-from-markdown/lib/index.js","../../../node_modules/mdast-util-gfm-strikethrough/lib/index.js","../../../node_modules/unist-util-is/lib/index.js","../../../node_modules/unist-util-visit-parents/lib/index.js","../../../node_modules/unist-util-visit/lib/index.js","../src/formatting.ts","../src/rc-markdown-editor.styles.ts","../src/rc-markdown-editor.ts","../src/icons.ts","../src/rc-editor-toolbar.ts"],"sourcesContent":["/// <reference lib=\"dom\" />\n\n/* global document */\n\nconst element = document.createElement('i')\n\n/**\n * @param {string} value\n * @returns {string | false}\n */\nexport function decodeNamedCharacterReference(value) {\n const characterReference = '&' + value + ';'\n element.innerHTML = characterReference\n const character = element.textContent\n\n // Some named character references do not require the closing semicolon\n // (`&not`, for instance), which leads to situations where parsing the assumed\n // named reference of `&notit;` will result in the string `¬it;`.\n // When we encounter a trailing semicolon after parsing, and the character\n // reference to decode was not a semicolon (`&semi;`), we can assume that the\n // matching was not complete.\n if (\n character.charCodeAt(character.length - 1) === 59 /* `;` */ &&\n value !== 'semi'\n ) {\n return false\n }\n\n // If the decoded string is equal to the input, the character reference was\n // not valid.\n return character === characterReference ? false : character\n}\n","/**\n * Like `Array#splice`, but smarter for giant arrays.\n *\n * `Array#splice` takes all items to be inserted as individual argument which\n * causes a stack overflow in V8 when trying to insert 100k items for instance.\n *\n * Otherwise, this does not return the removed items, and takes `items` as an\n * array instead of rest parameters.\n *\n * @template {unknown} T\n * Item type.\n * @param {Array<T>} list\n * List to operate on.\n * @param {number} start\n * Index to remove/insert at (can be negative).\n * @param {number} remove\n * Number of items to remove.\n * @param {Array<T>} items\n * Items to inject into `list`.\n * @returns {undefined}\n * Nothing.\n */\nexport function splice(list, start, remove, items) {\n const end = list.length;\n let chunkStart = 0;\n /** @type {Array<unknown>} */\n let parameters;\n\n // Make start between zero and `end` (included).\n if (start < 0) {\n start = -start > end ? 0 : end + start;\n } else {\n start = start > end ? end : start;\n }\n remove = remove > 0 ? remove : 0;\n\n // No need to chunk the items if there’s only a couple (10k) items.\n if (items.length < 10000) {\n parameters = Array.from(items);\n parameters.unshift(start, remove);\n // @ts-expect-error Hush, it’s fine.\n list.splice(...parameters);\n } else {\n // Delete `remove` items starting from `start`\n if (remove) list.splice(start, remove);\n\n // Insert the items in chunks to not cause stack overflows.\n while (chunkStart < items.length) {\n parameters = items.slice(chunkStart, chunkStart + 10000);\n parameters.unshift(start, 0);\n // @ts-expect-error Hush, it’s fine.\n list.splice(...parameters);\n chunkStart += 10000;\n start += 10000;\n }\n }\n}\n\n/**\n * Append `items` (an array) at the end of `list` (another array).\n * When `list` was empty, returns `items` instead.\n *\n * This prevents a potentially expensive operation when `list` is empty,\n * and adds items in batches to prevent V8 from hanging.\n *\n * @template {unknown} T\n * Item type.\n * @param {Array<T>} list\n * List to operate on.\n * @param {Array<T>} items\n * Items to add to `list`.\n * @returns {Array<T>}\n * Either `list` or `items`.\n */\nexport function push(list, items) {\n if (list.length > 0) {\n splice(list, list.length, 0, items);\n return list;\n }\n return items;\n}","/**\n * @import {\n * Extension,\n * Handles,\n * HtmlExtension,\n * NormalizedExtension\n * } from 'micromark-util-types'\n */\n\nimport {splice} from 'micromark-util-chunked'\n\nconst hasOwnProperty = {}.hasOwnProperty\n\n/**\n * Combine multiple syntax extensions into one.\n *\n * @param {ReadonlyArray<Extension>} extensions\n * List of syntax extensions.\n * @returns {NormalizedExtension}\n * A single combined extension.\n */\nexport function combineExtensions(extensions) {\n /** @type {NormalizedExtension} */\n const all = {}\n let index = -1\n\n while (++index < extensions.length) {\n syntaxExtension(all, extensions[index])\n }\n\n return all\n}\n\n/**\n * Merge `extension` into `all`.\n *\n * @param {NormalizedExtension} all\n * Extension to merge into.\n * @param {Extension} extension\n * Extension to merge.\n * @returns {undefined}\n * Nothing.\n */\nfunction syntaxExtension(all, extension) {\n /** @type {keyof Extension} */\n let hook\n\n for (hook in extension) {\n const maybe = hasOwnProperty.call(all, hook) ? all[hook] : undefined\n /** @type {Record<string, unknown>} */\n const left = maybe || (all[hook] = {})\n /** @type {Record<string, unknown> | undefined} */\n const right = extension[hook]\n /** @type {string} */\n let code\n\n if (right) {\n for (code in right) {\n if (!hasOwnProperty.call(left, code)) left[code] = []\n const value = right[code]\n constructs(\n // @ts-expect-error Looks like a list.\n left[code],\n Array.isArray(value) ? value : value ? [value] : []\n )\n }\n }\n }\n}\n\n/**\n * Merge `list` into `existing` (both lists of constructs).\n * Mutates `existing`.\n *\n * @param {Array<unknown>} existing\n * List of constructs to merge into.\n * @param {Array<unknown>} list\n * List of constructs to merge.\n * @returns {undefined}\n * Nothing.\n */\nfunction constructs(existing, list) {\n let index = -1\n /** @type {Array<unknown>} */\n const before = []\n\n while (++index < list.length) {\n // @ts-expect-error Looks like an object.\n ;(list[index].add === 'after' ? existing : before).push(list[index])\n }\n\n splice(existing, 0, 0, before)\n}\n\n/**\n * Combine multiple HTML extensions into one.\n *\n * @param {ReadonlyArray<HtmlExtension>} htmlExtensions\n * List of HTML extensions.\n * @returns {HtmlExtension}\n * Single combined HTML extension.\n */\nexport function combineHtmlExtensions(htmlExtensions) {\n /** @type {HtmlExtension} */\n const handlers = {}\n let index = -1\n\n while (++index < htmlExtensions.length) {\n htmlExtension(handlers, htmlExtensions[index])\n }\n\n return handlers\n}\n\n/**\n * Merge `extension` into `all`.\n *\n * @param {HtmlExtension} all\n * Extension to merge into.\n * @param {HtmlExtension} extension\n * Extension to merge.\n * @returns {undefined}\n * Nothing.\n */\nfunction htmlExtension(all, extension) {\n /** @type {keyof HtmlExtension} */\n let hook\n\n for (hook in extension) {\n const maybe = hasOwnProperty.call(all, hook) ? all[hook] : undefined\n const left = maybe || (all[hook] = {})\n const right = extension[hook]\n /** @type {keyof Handles} */\n let type\n\n if (right) {\n for (type in right) {\n // @ts-expect-error assume document vs regular handler are managed correctly.\n left[type] = right[type]\n }\n }\n }\n}\n","/**\n * Turn the number (in string form as either hexa- or plain decimal) coming from\n * a numeric character reference into a character.\n *\n * Sort of like `String.fromCodePoint(Number.parseInt(value, base))`, but makes\n * non-characters and control characters safe.\n *\n * @param {string} value\n * Value to decode.\n * @param {number} base\n * Numeric base.\n * @returns {string}\n * Character.\n */\nexport function decodeNumericCharacterReference(value, base) {\n const code = Number.parseInt(value, base);\n if (\n // C0 except for HT, LF, FF, CR, space.\n code < 9 || code === 11 || code > 13 && code < 32 ||\n // Control character (DEL) of C0, and C1 controls.\n code > 126 && code < 160 ||\n // Lone high surrogates and low surrogates.\n code > 55_295 && code < 57_344 ||\n // Noncharacters.\n code > 64_975 && code < 65_008 || /* eslint-disable no-bitwise */\n (code & 65_535) === 65_535 || (code & 65_535) === 65_534 || /* eslint-enable no-bitwise */\n // Out of range\n code > 1_114_111) {\n return \"\\uFFFD\";\n }\n return String.fromCodePoint(code);\n}","const characterReferences = {'\"': 'quot', '&': 'amp', '<': 'lt', '>': 'gt'}\n\n/**\n * Encode only the dangerous HTML characters.\n *\n * This ensures that certain characters which have special meaning in HTML are\n * dealt with.\n * Technically, we can skip `>` and `\"` in many cases, but CM includes them.\n *\n * @param {string} value\n * Value to encode.\n * @returns {string}\n * Encoded value.\n */\nexport function encode(value) {\n return value.replace(/[\"&<>]/g, replace)\n\n /**\n * @param {string} value\n * Value to replace.\n * @returns {string}\n * Encoded value.\n */\n function replace(value) {\n return (\n '&' +\n characterReferences[\n /** @type {keyof typeof characterReferences} */ (value)\n ] +\n ';'\n )\n }\n}\n","/**\n * Normalize an identifier (as found in references, definitions).\n *\n * Collapses markdown whitespace, trim, and then lower- and uppercase.\n *\n * Some characters are considered “uppercase”, such as U+03F4 (`ϴ`), but if their\n * lowercase counterpart (U+03B8 (`θ`)) is uppercased will result in a different\n * uppercase character (U+0398 (`Θ`)).\n * So, to get a canonical form, we perform both lower- and uppercase.\n *\n * Using uppercase last makes sure keys will never interact with default\n * prototypal values (such as `constructor`): nothing in the prototype of\n * `Object` is uppercase.\n *\n * @param {string} value\n * Identifier to normalize.\n * @returns {string}\n * Normalized identifier.\n */\nexport function normalizeIdentifier(value) {\n return value\n // Collapse markdown whitespace.\n .replace(/[\\t\\n\\r ]+/g, \" \")\n // Trim.\n .replace(/^ | $/g, '')\n // Some characters are considered “uppercase”, but if their lowercase\n // counterpart is uppercased will result in a different uppercase\n // character.\n // Hence, to get that form, we perform both lower- and uppercase.\n // Upper case makes sure keys will not interact with default prototypal\n // methods: no method is uppercase.\n .toLowerCase().toUpperCase();\n}","/**\n * @import {Code} from 'micromark-util-types'\n */\n\n/**\n * Check whether the character code represents an ASCII alpha (`a` through `z`,\n * case insensitive).\n *\n * An **ASCII alpha** is an ASCII upper alpha or ASCII lower alpha.\n *\n * An **ASCII upper alpha** is a character in the inclusive range U+0041 (`A`)\n * to U+005A (`Z`).\n *\n * An **ASCII lower alpha** is a character in the inclusive range U+0061 (`a`)\n * to U+007A (`z`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiAlpha = regexCheck(/[A-Za-z]/);\n\n/**\n * Check whether the character code represents an ASCII alphanumeric (`a`\n * through `z`, case insensitive, or `0` through `9`).\n *\n * An **ASCII alphanumeric** is an ASCII digit (see `asciiDigit`) or ASCII alpha\n * (see `asciiAlpha`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiAlphanumeric = regexCheck(/[\\dA-Za-z]/);\n\n/**\n * Check whether the character code represents an ASCII atext.\n *\n * atext is an ASCII alphanumeric (see `asciiAlphanumeric`), or a character in\n * the inclusive ranges U+0023 NUMBER SIGN (`#`) to U+0027 APOSTROPHE (`'`),\n * U+002A ASTERISK (`*`), U+002B PLUS SIGN (`+`), U+002D DASH (`-`), U+002F\n * SLASH (`/`), U+003D EQUALS TO (`=`), U+003F QUESTION MARK (`?`), U+005E\n * CARET (`^`) to U+0060 GRAVE ACCENT (`` ` ``), or U+007B LEFT CURLY BRACE\n * (`{`) to U+007E TILDE (`~`).\n *\n * See:\n * **\\[RFC5322]**:\n * [Internet Message Format](https://tools.ietf.org/html/rfc5322).\n * P. Resnick.\n * IETF.\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiAtext = regexCheck(/[#-'*+\\--9=?A-Z^-~]/);\n\n/**\n * Check whether a character code is an ASCII control character.\n *\n * An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL)\n * to U+001F (US), or U+007F (DEL).\n *\n * @param {Code} code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport function asciiControl(code) {\n return (\n // Special whitespace codes (which have negative values), C0 and Control\n // character DEL\n code !== null && (code < 32 || code === 127)\n );\n}\n\n/**\n * Check whether the character code represents an ASCII digit (`0` through `9`).\n *\n * An **ASCII digit** is a character in the inclusive range U+0030 (`0`) to\n * U+0039 (`9`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiDigit = regexCheck(/\\d/);\n\n/**\n * Check whether the character code represents an ASCII hex digit (`a` through\n * `f`, case insensitive, or `0` through `9`).\n *\n * An **ASCII hex digit** is an ASCII digit (see `asciiDigit`), ASCII upper hex\n * digit, or an ASCII lower hex digit.\n *\n * An **ASCII upper hex digit** is a character in the inclusive range U+0041\n * (`A`) to U+0046 (`F`).\n *\n * An **ASCII lower hex digit** is a character in the inclusive range U+0061\n * (`a`) to U+0066 (`f`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiHexDigit = regexCheck(/[\\dA-Fa-f]/);\n\n/**\n * Check whether the character code represents ASCII punctuation.\n *\n * An **ASCII punctuation** is a character in the inclusive ranges U+0021\n * EXCLAMATION MARK (`!`) to U+002F SLASH (`/`), U+003A COLON (`:`) to U+0040 AT\n * SIGN (`@`), U+005B LEFT SQUARE BRACKET (`[`) to U+0060 GRAVE ACCENT\n * (`` ` ``), or U+007B LEFT CURLY BRACE (`{`) to U+007E TILDE (`~`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/);\n\n/**\n * Check whether a character code is a markdown line ending.\n *\n * A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN\n * LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR).\n *\n * In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE\n * RETURN (CR) are replaced by these virtual characters depending on whether\n * they occurred together.\n *\n * @param {Code} code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport function markdownLineEnding(code) {\n return code !== null && code < -2;\n}\n\n/**\n * Check whether a character code is a markdown line ending (see\n * `markdownLineEnding`) or markdown space (see `markdownSpace`).\n *\n * @param {Code} code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport function markdownLineEndingOrSpace(code) {\n return code !== null && (code < 0 || code === 32);\n}\n\n/**\n * Check whether a character code is a markdown space.\n *\n * A **markdown space** is the concrete character U+0020 SPACE (SP) and the\n * virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT).\n *\n * In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is\n * replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL\n * SPACE (VS) characters, depending on the column at which the tab occurred.\n *\n * @param {Code} code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport function markdownSpace(code) {\n return code === -2 || code === -1 || code === 32;\n}\n\n// Size note: removing ASCII from the regex and using `asciiPunctuation` here\n// In fact adds to the bundle size.\n/**\n * Check whether the character code represents Unicode punctuation.\n *\n * A **Unicode punctuation** is a character in the Unicode `Pc` (Punctuation,\n * Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf`\n * (Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po`\n * (Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an ASCII\n * punctuation (see `asciiPunctuation`).\n *\n * See:\n * **\\[UNICODE]**:\n * [The Unicode Standard](https://www.unicode.org/versions/).\n * Unicode Consortium.\n *\n * @param code\n * Code.\n * @returns\n * Whether it matches.\n */\nexport const unicodePunctuation = regexCheck(/\\p{P}|\\p{S}/u);\n\n/**\n * Check whether the character code represents Unicode whitespace.\n *\n * Note that this does handle micromark specific markdown whitespace characters.\n * See `markdownLineEndingOrSpace` to check that.\n *\n * A **Unicode whitespace** is a character in the Unicode `Zs` (Separator,\n * Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF),\n * U+000C (FF), or U+000D CARRIAGE RETURN (CR) (**\\[UNICODE]**).\n *\n * See:\n * **\\[UNICODE]**:\n * [The Unicode Standard](https://www.unicode.org/versions/).\n * Unicode Consortium.\n *\n * @param code\n * Code.\n * @returns\n * Whether it matches.\n */\nexport const unicodeWhitespace = regexCheck(/\\s/);\n\n/**\n * Create a code check from a regex.\n *\n * @param {RegExp} regex\n * Expression.\n * @returns {(code: Code) => boolean}\n * Check.\n */\nfunction regexCheck(regex) {\n return check;\n\n /**\n * Check whether a code matches the bound regex.\n *\n * @param {Code} code\n * Character code.\n * @returns {boolean}\n * Whether the character code matches the bound regex.\n */\n function check(code) {\n return code !== null && code > -1 && regex.test(String.fromCharCode(code));\n }\n}","import { asciiAlphanumeric } from 'micromark-util-character';\nimport { encode } from 'micromark-util-encode';\n/**\n * Make a value safe for injection as a URL.\n *\n * This encodes unsafe characters with percent-encoding and skips already\n * encoded sequences (see `normalizeUri`).\n * Further unsafe characters are encoded as character references (see\n * `micromark-util-encode`).\n *\n * A regex of allowed protocols can be given, in which case the URL is\n * sanitized.\n * For example, `/^(https?|ircs?|mailto|xmpp)$/i` can be used for `a[href]`, or\n * `/^https?$/i` for `img[src]` (this is what `github.com` allows).\n * If the URL includes an unknown protocol (one not matched by `protocol`, such\n * as a dangerous example, `javascript:`), the value is ignored.\n *\n * @param {string | null | undefined} url\n * URI to sanitize.\n * @param {RegExp | null | undefined} [protocol]\n * Allowed protocols.\n * @returns {string}\n * Sanitized URI.\n */\nexport function sanitizeUri(url, protocol) {\n const value = encode(normalizeUri(url || ''));\n if (!protocol) {\n return value;\n }\n const colon = value.indexOf(':');\n const questionMark = value.indexOf('?');\n const numberSign = value.indexOf('#');\n const slash = value.indexOf('/');\n if (\n // If there is no protocol, it’s relative.\n colon < 0 ||\n // If the first colon is after a `?`, `#`, or `/`, it’s not a protocol.\n slash > -1 && colon > slash || questionMark > -1 && colon > questionMark || numberSign > -1 && colon > numberSign ||\n // It is a protocol, it should be allowed.\n protocol.test(value.slice(0, colon))) {\n return value;\n }\n return '';\n}\n\n/**\n * Normalize a URL.\n *\n * Encode unsafe characters with percent-encoding, skipping already encoded\n * sequences.\n *\n * @param {string} value\n * URI to normalize.\n * @returns {string}\n * Normalized URI.\n */\nexport function normalizeUri(value) {\n /** @type {Array<string>} */\n const result = [];\n let index = -1;\n let start = 0;\n let skip = 0;\n while (++index < value.length) {\n const code = value.charCodeAt(index);\n /** @type {string} */\n let replace = '';\n\n // A correct percent encoded value.\n if (code === 37 && asciiAlphanumeric(value.charCodeAt(index + 1)) && asciiAlphanumeric(value.charCodeAt(index + 2))) {\n skip = 2;\n }\n // ASCII.\n else if (code < 128) {\n if (!/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code))) {\n replace = String.fromCharCode(code);\n }\n }\n // Astral.\n else if (code > 55_295 && code < 57_344) {\n const next = value.charCodeAt(index + 1);\n\n // A correct surrogate pair.\n if (code < 56_320 && next > 56_319 && next < 57_344) {\n replace = String.fromCharCode(code, next);\n skip = 1;\n }\n // Lone surrogate.\n else {\n replace = \"\\uFFFD\";\n }\n }\n // Unicode.\n else {\n replace = String.fromCharCode(code);\n }\n if (replace) {\n result.push(value.slice(start, index), encodeURIComponent(replace));\n start = index + skip + 1;\n replace = '';\n }\n if (skip) {\n index += skip;\n skip = 0;\n }\n }\n return result.join('') + value.slice(start);\n}","/**\n * While micromark is a lexer/tokenizer, the common case of going from markdown\n * to html is currently built in as this module, even though the parts can be\n * used separately to build ASTs, CSTs, or many other output formats.\n *\n * Having an HTML compiler built in is useful because it allows us to check for\n * compliancy to CommonMark, the de facto norm of markdown, specified in roughly\n * 600 input/output cases.\n *\n * This module has an interface that accepts lists of events instead of the\n * whole at once, however, because markdown can’t be truly streaming, we buffer\n * events before processing and outputting the final result.\n */\n\n/**\n * @import {\n * CompileContext,\n * CompileData,\n * CompileOptions,\n * Compile,\n * Definition,\n * Event,\n * Handle,\n * HtmlExtension,\n * LineEnding,\n * NormalizedHtmlExtension,\n * Token\n * } from 'micromark-util-types'\n */\n\n/**\n * @typedef Media\n * @property {boolean | undefined} [image]\n * @property {string | undefined} [labelId]\n * @property {string | undefined} [label]\n * @property {string | undefined} [referenceId]\n * @property {string | undefined} [destination]\n * @property {string | undefined} [title]\n */\n\nimport { decodeNamedCharacterReference } from 'decode-named-character-reference';\nimport { push } from 'micromark-util-chunked';\nimport { combineHtmlExtensions } from 'micromark-util-combine-extensions';\nimport { decodeNumericCharacterReference } from 'micromark-util-decode-numeric-character-reference';\nimport { encode as _encode } from 'micromark-util-encode';\nimport { normalizeIdentifier } from 'micromark-util-normalize-identifier';\nimport { sanitizeUri } from 'micromark-util-sanitize-uri';\nconst hasOwnProperty = {}.hasOwnProperty;\n\n/**\n * These two are allowlists of safe protocols for full URLs in respectively the\n * `href` (on `<a>`) and `src` (on `<img>`) attributes.\n * They are based on what is allowed on GitHub,\n * <https://github.com/syntax-tree/hast-util-sanitize/blob/9275b21/lib/github.json#L31>\n */\nconst protocolHref = /^(https?|ircs?|mailto|xmpp)$/i;\nconst protocolSource = /^https?$/i;\n\n/**\n * @param {CompileOptions | null | undefined} [options]\n * @returns {Compile}\n */\nexport function compile(options) {\n const settings = options || {};\n\n /**\n * Tags is needed because according to markdown, links and emphasis and\n * whatnot can exist in images, however, as HTML doesn’t allow content in\n * images, the tags are ignored in the `alt` attribute, but the content\n * remains.\n *\n * @type {boolean | undefined}\n */\n let tags = true;\n\n /**\n * An object to track identifiers to media (URLs and titles) defined with\n * definitions.\n *\n * @type {Record<string, Definition>}\n */\n const definitions = {};\n\n /**\n * A lot of the handlers need to capture some of the output data, modify it\n * somehow, and then deal with it.\n * We do that by tracking a stack of buffers, that can be opened (with\n * `buffer`) and closed (with `resume`) to access them.\n *\n * @type {Array<Array<string>>}\n */\n const buffers = [[]];\n\n /**\n * As we can have links in images and the other way around, where the deepest\n * ones are closed first, we need to track which one we’re in.\n *\n * @type {Array<Media>}\n */\n const mediaStack = [];\n\n /**\n * Same as `mediaStack` for tightness, which is specific to lists.\n * We need to track if we’re currently in a tight or loose container.\n *\n * @type {Array<boolean>}\n */\n const tightStack = [];\n\n /** @type {HtmlExtension} */\n const defaultHandlers = {\n enter: {\n blockQuote: onenterblockquote,\n codeFenced: onentercodefenced,\n codeFencedFenceInfo: buffer,\n codeFencedFenceMeta: buffer,\n codeIndented: onentercodeindented,\n codeText: onentercodetext,\n content: onentercontent,\n definition: onenterdefinition,\n definitionDestinationString: onenterdefinitiondestinationstring,\n definitionLabelString: buffer,\n definitionTitleString: buffer,\n emphasis: onenteremphasis,\n htmlFlow: onenterhtmlflow,\n htmlText: onenterhtml,\n image: onenterimage,\n label: buffer,\n link: onenterlink,\n listItemMarker: onenterlistitemmarker,\n listItemValue: onenterlistitemvalue,\n listOrdered: onenterlistordered,\n listUnordered: onenterlistunordered,\n paragraph: onenterparagraph,\n reference: buffer,\n resource: onenterresource,\n resourceDestinationString: onenterresourcedestinationstring,\n resourceTitleString: buffer,\n setextHeading: onentersetextheading,\n strong: onenterstrong\n },\n exit: {\n atxHeading: onexitatxheading,\n atxHeadingSequence: onexitatxheadingsequence,\n autolinkEmail: onexitautolinkemail,\n autolinkProtocol: onexitautolinkprotocol,\n blockQuote: onexitblockquote,\n characterEscapeValue: onexitdata,\n characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker,\n characterReferenceMarkerNumeric: onexitcharacterreferencemarker,\n characterReferenceValue: onexitcharacterreferencevalue,\n codeFenced: onexitflowcode,\n codeFencedFence: onexitcodefencedfence,\n codeFencedFenceInfo: onexitcodefencedfenceinfo,\n codeFencedFenceMeta: onresumedrop,\n codeFlowValue: onexitcodeflowvalue,\n codeIndented: onexitflowcode,\n codeText: onexitcodetext,\n codeTextData: onexitdata,\n data: onexitdata,\n definition: onexitdefinition,\n definitionDestinationString: onexitdefinitiondestinationstring,\n definitionLabelString: onexitdefinitionlabelstring,\n definitionTitleString: onexitdefinitiontitlestring,\n emphasis: onexitemphasis,\n hardBreakEscape: onexithardbreak,\n hardBreakTrailing: onexithardbreak,\n htmlFlow: onexithtml,\n htmlFlowData: onexitdata,\n htmlText: onexithtml,\n htmlTextData: onexitdata,\n image: onexitmedia,\n label: onexitlabel,\n labelText: onexitlabeltext,\n lineEnding: onexitlineending,\n link: onexitmedia,\n listOrdered: onexitlistordered,\n listUnordered: onexitlistunordered,\n paragraph: onexitparagraph,\n reference: onresumedrop,\n referenceString: onexitreferencestring,\n resource: onresumedrop,\n resourceDestinationString: onexitresourcedestinationstring,\n resourceTitleString: onexitresourcetitlestring,\n setextHeading: onexitsetextheading,\n setextHeadingLineSequence: onexitsetextheadinglinesequence,\n setextHeadingText: onexitsetextheadingtext,\n strong: onexitstrong,\n thematicBreak: onexitthematicbreak\n }\n };\n\n /**\n * Combine the HTML extensions with the default handlers.\n * An HTML extension is an object whose fields are either `enter` or `exit`\n * (reflecting whether a token is entered or exited).\n * The values at such objects are names of tokens mapping to handlers.\n * Handlers are called, respectively when a token is opener or closed, with\n * that token, and a context as `this`.\n */\n const handlers = /** @type {NormalizedHtmlExtension} */\n combineHtmlExtensions([defaultHandlers, ...(settings.htmlExtensions || [])]);\n\n /**\n * Handlers do often need to keep track of some state.\n * That state is provided here as a key-value store (an object).\n *\n * @type {CompileData}\n */\n const data = {\n definitions,\n tightStack\n };\n\n /**\n * The context for handlers references a couple of useful functions.\n * In handlers from extensions, those can be accessed at `this`.\n * For the handlers here, they can be accessed directly.\n *\n * @type {Omit<CompileContext, 'sliceSerialize'>}\n */\n const context = {\n buffer,\n encode,\n getData,\n lineEndingIfNeeded,\n options: settings,\n raw,\n resume,\n setData,\n tag\n };\n\n /**\n * Generally, micromark copies line endings (`'\\r'`, `'\\n'`, `'\\r\\n'`) in the\n * markdown document over to the compiled HTML.\n * In some cases, such as `> a`, CommonMark requires that extra line endings\n * are added: `<blockquote>\\n<p>a</p>\\n</blockquote>`.\n * This variable hold the default line ending when given (or `undefined`),\n * and in the latter case will be updated to the first found line ending if\n * there is one.\n */\n let lineEndingStyle = settings.defaultLineEnding;\n\n // Return the function that handles a slice of events.\n return compile;\n\n /**\n * Deal w/ a slice of events.\n * Return either the empty string if there’s nothing of note to return, or the\n * result when done.\n *\n * @param {ReadonlyArray<Event>} events\n * @returns {string}\n */\n function compile(events) {\n let index = -1;\n let start = 0;\n /** @type {Array<number>} */\n const listStack = [];\n // As definitions can come after references, we need to figure out the media\n // (urls and titles) defined by them before handling the references.\n // So, we do sort of what HTML does: put metadata at the start (in head), and\n // then put content after (`body`).\n /** @type {Array<Event>} */\n let head = [];\n /** @type {Array<Event>} */\n let body = [];\n while (++index < events.length) {\n // Figure out the line ending style used in the document.\n if (!lineEndingStyle && (events[index][1].type === \"lineEnding\" || events[index][1].type === \"lineEndingBlank\")) {\n lineEndingStyle = /** @type {LineEnding} */\n events[index][2].sliceSerialize(events[index][1]);\n }\n\n // Preprocess lists to infer whether the list is loose or not.\n if (events[index][1].type === \"listOrdered\" || events[index][1].type === \"listUnordered\") {\n if (events[index][0] === 'enter') {\n listStack.push(index);\n } else {\n prepareList(events.slice(listStack.pop(), index));\n }\n }\n\n // Move definitions to the front.\n if (events[index][1].type === \"definition\") {\n if (events[index][0] === 'enter') {\n body = push(body, events.slice(start, index));\n start = index;\n } else {\n head = push(head, events.slice(start, index + 1));\n start = index + 1;\n }\n }\n }\n head = push(head, body);\n head = push(head, events.slice(start));\n index = -1;\n const result = head;\n\n // Handle the start of the document, if defined.\n if (handlers.enter.null) {\n handlers.enter.null.call(context);\n }\n\n // Handle all events.\n while (++index < events.length) {\n const handles = handlers[result[index][0]];\n const kind = result[index][1].type;\n const handle = handles[kind];\n if (hasOwnProperty.call(handles, kind) && handle) {\n handle.call({\n sliceSerialize: result[index][2].sliceSerialize,\n ...context\n }, result[index][1]);\n }\n }\n\n // Handle the end of the document, if defined.\n if (handlers.exit.null) {\n handlers.exit.null.call(context);\n }\n return buffers[0].join('');\n }\n\n /**\n * Figure out whether lists are loose or not.\n *\n * @param {ReadonlyArray<Event>} slice\n * @returns {undefined}\n */\n function prepareList(slice) {\n const length = slice.length;\n let index = 0; // Skip open.\n let containerBalance = 0;\n let loose = false;\n /** @type {boolean | undefined} */\n let atMarker;\n while (++index < length) {\n const event = slice[index];\n if (event[1]._container) {\n atMarker = undefined;\n if (event[0] === 'enter') {\n containerBalance++;\n } else {\n containerBalance--;\n }\n } else switch (event[1].type) {\n case \"listItemPrefix\":\n {\n if (event[0] === 'exit') {\n atMarker = true;\n }\n break;\n }\n case \"linePrefix\":\n {\n // Ignore\n\n break;\n }\n case \"lineEndingBlank\":\n {\n if (event[0] === 'enter' && !containerBalance) {\n if (atMarker) {\n atMarker = undefined;\n } else {\n loose = true;\n }\n }\n break;\n }\n default:\n {\n atMarker = undefined;\n }\n }\n }\n slice[0][1]._loose = loose;\n }\n\n /**\n * @type {CompileContext['setData']}\n */\n function setData(key, value) {\n // @ts-expect-error: assume `value` is omitted (`undefined` is passed) only\n // if allowed.\n data[key] = value;\n }\n\n /**\n * @type {CompileContext['getData']}\n */\n function getData(key) {\n return data[key];\n }\n\n /** @type {CompileContext['buffer']} */\n function buffer() {\n buffers.push([]);\n }\n\n /** @type {CompileContext['resume']} */\n function resume() {\n const buf = buffers.pop();\n return buf.join('');\n }\n\n /** @type {CompileContext['tag']} */\n function tag(value) {\n if (!tags) return;\n setData('lastWasTag', true);\n buffers[buffers.length - 1].push(value);\n }\n\n /** @type {CompileContext['raw']} */\n function raw(value) {\n setData('lastWasTag');\n buffers[buffers.length - 1].push(value);\n }\n\n /**\n * Output an extra line ending.\n *\n * @returns {undefined}\n */\n function lineEnding() {\n raw(lineEndingStyle || '\\n');\n }\n\n /** @type {CompileContext['lineEndingIfNeeded']} */\n function lineEndingIfNeeded() {\n const buffer = buffers[buffers.length - 1];\n const slice = buffer[buffer.length - 1];\n const previous = slice ? slice.charCodeAt(slice.length - 1) : null;\n if (previous === 10 || previous === 13 || previous === null) {\n return;\n }\n lineEnding();\n }\n\n /** @type {CompileContext['encode']} */\n function encode(value) {\n return getData('ignoreEncode') ? value : _encode(value);\n }\n\n //\n // Handlers.\n //\n\n /**\n * @returns {undefined}\n */\n function onresumedrop() {\n resume();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterlistordered(token) {\n tightStack.push(!token._loose);\n lineEndingIfNeeded();\n tag('<ol');\n setData('expectFirstItem', true);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterlistunordered(token) {\n tightStack.push(!token._loose);\n lineEndingIfNeeded();\n tag('<ul');\n setData('expectFirstItem', true);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterlistitemvalue(token) {\n if (getData('expectFirstItem')) {\n const value = Number.parseInt(this.sliceSerialize(token), 10);\n if (value !== 1) {\n tag(' start=\"' + encode(String(value)) + '\"');\n }\n }\n }\n\n /**\n * @returns {undefined}\n */\n function onenterlistitemmarker() {\n if (getData('expectFirstItem')) {\n tag('>');\n } else {\n onexitlistitem();\n }\n lineEndingIfNeeded();\n tag('<li>');\n setData('expectFirstItem');\n // “Hack” to prevent a line ending from showing up if the item is empty.\n setData('lastWasTag');\n }\n\n /**\n * @returns {undefined}\n */\n function onexitlistordered() {\n onexitlistitem();\n tightStack.pop();\n lineEnding();\n tag('</ol>');\n }\n\n /**\n * @returns {undefined}\n */\n function onexitlistunordered() {\n onexitlistitem();\n tightStack.pop();\n lineEnding();\n tag('</ul>');\n }\n\n /**\n * @returns {undefined}\n */\n function onexitlistitem() {\n if (getData('lastWasTag') && !getData('slurpAllLineEndings')) {\n lineEndingIfNeeded();\n }\n tag('</li>');\n setData('slurpAllLineEndings');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterblockquote() {\n tightStack.push(false);\n lineEndingIfNeeded();\n tag('<blockquote>');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitblockquote() {\n tightStack.pop();\n lineEndingIfNeeded();\n tag('</blockquote>');\n setData('slurpAllLineEndings');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterparagraph() {\n if (!tightStack[tightStack.length - 1]) {\n lineEndingIfNeeded();\n tag('<p>');\n }\n setData('slurpAllLineEndings');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitparagraph() {\n if (tightStack[tightStack.length - 1]) {\n setData('slurpAllLineEndings', true);\n } else {\n tag('</p>');\n }\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onentercodefenced() {\n lineEndingIfNeeded();\n tag('<pre><code');\n setData('fencesCount', 0);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefencedfenceinfo() {\n const value = resume();\n tag(' class=\"language-' + value + '\"');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefencedfence() {\n const count = getData('fencesCount') || 0;\n if (!count) {\n tag('>');\n setData('slurpOneLineEnding', true);\n }\n setData('fencesCount', count + 1);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onentercodeindented() {\n lineEndingIfNeeded();\n tag('<pre><code>');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitflowcode() {\n const count = getData('fencesCount');\n\n // One special case is if we are inside a container, and the fenced code was\n // not closed (meaning it runs to the end).\n // In that case, the following line ending, is considered *outside* the\n // fenced code and block quote by micromark, but CM wants to treat that\n // ending as part of the code.\n if (count !== undefined && count < 2 && data.tightStack.length > 0 && !getData('lastWasTag')) {\n lineEnding();\n }\n\n // But in most cases, it’s simpler: when we’ve seen some data, emit an extra\n // line ending when needed.\n if (getData('flowCodeSeenData')) {\n lineEndingIfNeeded();\n }\n tag('</code></pre>');\n if (count !== undefined && count < 2) lineEndingIfNeeded();\n setData('flowCodeSeenData');\n setData('fencesCount');\n setData('slurpOneLineEnding');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterimage() {\n mediaStack.push({\n image: true\n });\n tags = undefined; // Disallow tags.\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterlink() {\n mediaStack.push({});\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitlabeltext(token) {\n mediaStack[mediaStack.length - 1].labelId = this.sliceSerialize(token);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitlabel() {\n mediaStack[mediaStack.length - 1].label = resume();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitreferencestring(token) {\n mediaStack[mediaStack.length - 1].referenceId = this.sliceSerialize(token);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterresource() {\n buffer(); // We can have line endings in the resource, ignore them.\n mediaStack[mediaStack.length - 1].destination = '';\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterresourcedestinationstring() {\n buffer();\n // Ignore encoding the result, as we’ll first percent encode the url and\n // encode manually after.\n setData('ignoreEncode', true);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitresourcedestinationstring() {\n mediaStack[mediaStack.length - 1].destination = resume();\n setData('ignoreEncode');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitresourcetitlestring() {\n mediaStack[mediaStack.length - 1].title = resume();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitmedia() {\n let index = mediaStack.length - 1; // Skip current.\n const media = mediaStack[index];\n const id = media.referenceId || media.labelId;\n const context = media.destination === undefined ? definitions[normalizeIdentifier(id)] : media;\n tags = true;\n while (index--) {\n if (mediaStack[index].image) {\n tags = undefined;\n break;\n }\n }\n if (media.image) {\n tag('<img src=\"' + sanitizeUri(context.destination, settings.allowDangerousProtocol ? undefined : protocolSource) + '\" alt=\"');\n raw(media.label);\n tag('\"');\n } else {\n tag('<a href=\"' + sanitizeUri(context.destination, settings.allowDangerousProtocol ? undefined : protocolHref) + '\"');\n }\n tag(context.title ? ' title=\"' + context.title + '\"' : '');\n if (media.image) {\n tag(' />');\n } else {\n tag('>');\n raw(media.label);\n tag('</a>');\n }\n mediaStack.pop();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterdefinition() {\n buffer();\n mediaStack.push({});\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitionlabelstring(token) {\n // Discard label, use the source content instead.\n resume();\n mediaStack[mediaStack.length - 1].labelId = this.sliceSerialize(token);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterdefinitiondestinationstring() {\n buffer();\n setData('ignoreEncode', true);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitiondestinationstring() {\n mediaStack[mediaStack.length - 1].destination = resume();\n setData('ignoreEncode');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitiontitlestring() {\n mediaStack[mediaStack.length - 1].title = resume();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinition() {\n const media = mediaStack[mediaStack.length - 1];\n const id = normalizeIdentifier(media.labelId);\n resume();\n if (!hasOwnProperty.call(definitions, id)) {\n definitions[id] = mediaStack[mediaStack.length - 1];\n }\n mediaStack.pop();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onentercontent() {\n setData('slurpAllLineEndings', true);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitatxheadingsequence(token) {\n // Exit for further sequences.\n if (getData('headingRank')) return;\n setData('headingRank', this.sliceSerialize(token).length);\n lineEndingIfNeeded();\n tag('<h' + getData('headingRank') + '>');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onentersetextheading() {\n buffer();\n setData('slurpAllLineEndings');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheadingtext() {\n setData('slurpAllLineEndings', true);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitatxheading() {\n tag('</h' + getData('headingRank') + '>');\n setData('headingRank');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheadinglinesequence(token) {\n setData('headingRank', this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheading() {\n const value = resume();\n lineEndingIfNeeded();\n tag('<h' + getData('headingRank') + '>');\n raw(value);\n tag('</h' + getData('headingRank') + '>');\n setData('slurpAllLineEndings');\n setData('headingRank');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdata(token) {\n raw(encode(this.sliceSerialize(token)));\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitlineending(token) {\n if (getData('slurpAllLineEndings')) {\n return;\n }\n if (getData('slurpOneLineEnding')) {\n setData('slurpOneLineEnding');\n return;\n }\n if (getData('inCodeText')) {\n raw(' ');\n return;\n }\n raw(encode(this.sliceSerialize(token)));\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodeflowvalue(token) {\n raw(encode(this.sliceSerialize(token)));\n setData('flowCodeSeenData', true);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexithardbreak() {\n tag('<br />');\n }\n\n /**\n * @returns {undefined}\n */\n function onenterhtmlflow() {\n lineEndingIfNeeded();\n onenterhtml();\n }\n\n /**\n * @returns {undefined}\n */\n function onexithtml() {\n setData('ignoreEncode');\n }\n\n /**\n * @returns {undefined}\n */\n function onenterhtml() {\n if (settings.allowDangerousHtml) {\n setData('ignoreEncode', true);\n }\n }\n\n /**\n * @returns {undefined}\n */\n function onenteremphasis() {\n tag('<em>');\n }\n\n /**\n * @returns {undefined}\n */\n function onenterstrong() {\n tag('<strong>');\n }\n\n /**\n * @returns {undefined}\n */\n function onentercodetext() {\n setData('inCodeText', true);\n tag('<code>');\n }\n\n /**\n * @returns {undefined}\n */\n function onexitcodetext() {\n setData('inCodeText');\n tag('</code>');\n }\n\n /**\n * @returns {undefined}\n */\n function onexitemphasis() {\n tag('</em>');\n }\n\n /**\n * @returns {undefined}\n */\n function onexitstrong() {\n tag('</strong>');\n }\n\n /**\n * @returns {undefined}\n */\n function onexitthematicbreak() {\n lineEndingIfNeeded();\n tag('<hr />');\n }\n\n /**\n * @this {CompileContext}\n * @param {Token} token\n * @returns {undefined}\n */\n function onexitcharacterreferencemarker(token) {\n setData('characterReferenceType', token.type);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcharacterreferencevalue(token) {\n const value = this.sliceSerialize(token);\n const decoded = getData('characterReferenceType') ? decodeNumericCharacterReference(value, getData('characterReferenceType') === \"characterReferenceMarkerNumeric\" ? 10 : 16) : decodeNamedCharacterReference(value);\n\n // `decodeNamedCharacterReference` can return `false` for invalid named\n // character references,\n // but everything we’ve tokenized is valid.\n raw(encode(/** @type {string} */decoded));\n setData('characterReferenceType');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitautolinkprotocol(token) {\n const uri = this.sliceSerialize(token);\n tag('<a href=\"' + sanitizeUri(uri, settings.allowDangerousProtocol ? undefined : protocolHref) + '\">');\n raw(encode(uri));\n tag('</a>');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitautolinkemail(token) {\n const uri = this.sliceSerialize(token);\n tag('<a href=\"' + sanitizeUri('mailto:' + uri) + '\">');\n raw(encode(uri));\n tag('</a>');\n }\n}","/**\n * @import {Effects, State, TokenType} from 'micromark-util-types'\n */\n\nimport { markdownSpace } from 'micromark-util-character';\n\n// To do: implement `spaceOrTab`, `spaceOrTabMinMax`, `spaceOrTabWithOptions`.\n\n/**\n * Parse spaces and tabs.\n *\n * There is no `nok` parameter:\n *\n * * spaces in markdown are often optional, in which case this factory can be\n * used and `ok` will be switched to whether spaces were found or not\n * * one line ending or space can be detected with `markdownSpace(code)` right\n * before using `factorySpace`\n *\n * ###### Examples\n *\n * Where `␉` represents a tab (plus how much it expands) and `␠` represents a\n * single space.\n *\n * ```markdown\n * ␉\n * ␠␠␠␠\n * ␉␠\n * ```\n *\n * @param {Effects} effects\n * Context.\n * @param {State} ok\n * State switched to when successful.\n * @param {TokenType} type\n * Type (`' \\t'`).\n * @param {number | undefined} [max=Infinity]\n * Max (exclusive).\n * @returns {State}\n * Start state.\n */\nexport function factorySpace(effects, ok, type, max) {\n const limit = max ? max - 1 : Number.POSITIVE_INFINITY;\n let size = 0;\n return start;\n\n /** @type {State} */\n function start(code) {\n if (markdownSpace(code)) {\n effects.enter(type);\n return prefix(code);\n }\n return ok(code);\n }\n\n /** @type {State} */\n function prefix(code) {\n if (markdownSpace(code) && size++ < limit) {\n effects.consume(code);\n return prefix;\n }\n effects.exit(type);\n return ok(code);\n }\n}","/**\n * @import {\n * InitialConstruct,\n * Initializer,\n * State,\n * TokenizeContext,\n * Token\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding } from 'micromark-util-character';\n/** @type {InitialConstruct} */\nexport const content = {\n tokenize: initializeContent\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Initializer}\n * Content.\n */\nfunction initializeContent(effects) {\n const contentStart = effects.attempt(this.parser.constructs.contentInitial, afterContentStartConstruct, paragraphInitial);\n /** @type {Token} */\n let previous;\n return contentStart;\n\n /** @type {State} */\n function afterContentStartConstruct(code) {\n if (code === null) {\n effects.consume(code);\n return;\n }\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return factorySpace(effects, contentStart, \"linePrefix\");\n }\n\n /** @type {State} */\n function paragraphInitial(code) {\n effects.enter(\"paragraph\");\n return lineStart(code);\n }\n\n /** @type {State} */\n function lineStart(code) {\n const token = effects.enter(\"chunkText\", {\n contentType: \"text\",\n previous\n });\n if (previous) {\n previous.next = token;\n }\n previous = token;\n return data(code);\n }\n\n /** @type {State} */\n function data(code) {\n if (code === null) {\n effects.exit(\"chunkText\");\n effects.exit(\"paragraph\");\n effects.consume(code);\n return;\n }\n if (markdownLineEnding(code)) {\n effects.consume(code);\n effects.exit(\"chunkText\");\n return lineStart;\n }\n\n // Data.\n effects.consume(code);\n return data;\n }\n}","/**\n * @import {\n * Construct,\n * ContainerState,\n * InitialConstruct,\n * Initializer,\n * Point,\n * State,\n * TokenizeContext,\n * Tokenizer,\n * Token\n * } from 'micromark-util-types'\n */\n\n/**\n * @typedef {[Construct, ContainerState]} StackItem\n * Construct and its state.\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding } from 'micromark-util-character';\nimport { splice } from 'micromark-util-chunked';\n/** @type {InitialConstruct} */\nexport const document = {\n tokenize: initializeDocument\n};\n\n/** @type {Construct} */\nconst containerConstruct = {\n tokenize: tokenizeContainer\n};\n\n/**\n * @this {TokenizeContext}\n * Self.\n * @type {Initializer}\n * Initializer.\n */\nfunction initializeDocument(effects) {\n const self = this;\n /** @type {Array<StackItem>} */\n const stack = [];\n let continued = 0;\n /** @type {TokenizeContext | undefined} */\n let childFlow;\n /** @type {Token | undefined} */\n let childToken;\n /** @type {number} */\n let lineStartOffset;\n return start;\n\n /** @type {State} */\n function start(code) {\n // First we iterate through the open blocks, starting with the root\n // document, and descending through last children down to the last open\n // block.\n // Each block imposes a condition that the line must satisfy if the block is\n // to remain open.\n // For example, a block quote requires a `>` character.\n // A paragraph requires a non-blank line.\n // In this phase we may match all or just some of the open blocks.\n // But we cannot close unmatched blocks yet, because we may have a lazy\n // continuation line.\n if (continued < stack.length) {\n const item = stack[continued];\n self.containerState = item[1];\n return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code);\n }\n\n // Done.\n return checkNewContainers(code);\n }\n\n /** @type {State} */\n function documentContinue(code) {\n continued++;\n\n // Note: this field is called `_closeFlow` but it also closes containers.\n // Perhaps a good idea to rename it but it’s already used in the wild by\n // extensions.\n if (self.containerState._closeFlow) {\n self.containerState._closeFlow = undefined;\n if (childFlow) {\n closeFlow();\n }\n\n // Note: this algorithm for moving events around is similar to the\n // algorithm when dealing with lazy lines in `writeToChild`.\n const indexBeforeExits = self.events.length;\n let indexBeforeFlow = indexBeforeExits;\n /** @type {Point | undefined} */\n let point;\n\n // Find the flow chunk.\n while (indexBeforeFlow--) {\n if (self.events[indexBeforeFlow][0] === 'exit' && self.events[indexBeforeFlow][1].type === \"chunkFlow\") {\n point = self.events[indexBeforeFlow][1].end;\n break;\n }\n }\n exitContainers(continued);\n\n // Fix positions.\n let index = indexBeforeExits;\n while (index < self.events.length) {\n self.events[index][1].end = {\n ...point\n };\n index++;\n }\n\n // Inject the exits earlier (they’re still also at the end).\n splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));\n\n // Discard the duplicate exits.\n self.events.length = index;\n return checkNewContainers(code);\n }\n return start(code);\n }\n\n /** @type {State} */\n function checkNewContainers(code) {\n // Next, after consuming the continuation markers for existing blocks, we\n // look for new block starts (e.g. `>` for a block quote).\n // If we encounter a new block start, we close any blocks unmatched in\n // step 1 before creating the new block as a child of the last matched\n // block.\n if (continued === stack.length) {\n // No need to `check` whether there’s a container, of `exitContainers`\n // would be moot.\n // We can instead immediately `attempt` to parse one.\n if (!childFlow) {\n return documentContinued(code);\n }\n\n // If we have concrete content, such as block HTML or fenced code,\n // we can’t have containers “pierce” into them, so we can immediately\n // start.\n if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) {\n return flowStart(code);\n }\n\n // If we do have flow, it could still be a blank line,\n // but we’d be interrupting it w/ a new container if there’s a current\n // construct.\n // To do: next major: remove `_gfmTableDynamicInterruptHack` (no longer\n // needed in micromark-extension-gfm-table@1.0.6).\n self.interrupt = Boolean(childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack);\n }\n\n // Check if there is a new container.\n self.containerState = {};\n return effects.check(containerConstruct, thereIsANewContainer, thereIsNoNewContainer)(code);\n }\n\n /** @type {State} */\n function thereIsANewContainer(code) {\n if (childFlow) closeFlow();\n exitContainers(continued);\n return documentContinued(code);\n }\n\n /** @type {State} */\n function thereIsNoNewContainer(code) {\n self.parser.lazy[self.now().line] = continued !== stack.length;\n lineStartOffset = self.now().offset;\n return flowStart(code);\n }\n\n /** @type {State} */\n function documentContinued(code) {\n // Try new containers.\n self.containerState = {};\n return effects.attempt(containerConstruct, containerContinue, flowStart)(code);\n }\n\n /** @type {State} */\n function containerContinue(code) {\n continued++;\n stack.push([self.currentConstruct, self.containerState]);\n // Try another.\n return documentContinued(code);\n }\n\n /** @type {State} */\n function flowStart(code) {\n if (code === null) {\n if (childFlow) closeFlow();\n exitContainers(0);\n effects.consume(code);\n return;\n }\n childFlow = childFlow || self.parser.flow(self.now());\n effects.enter(\"chunkFlow\", {\n _tokenizer: childFlow,\n contentType: \"flow\",\n previous: childToken\n });\n return flowContinue(code);\n }\n\n /** @type {State} */\n function flowContinue(code) {\n if (code === null) {\n writeToChild(effects.exit(\"chunkFlow\"), true);\n exitContainers(0);\n effects.consume(code);\n return;\n }\n if (markdownLineEnding(code)) {\n effects.consume(code);\n writeToChild(effects.exit(\"chunkFlow\"));\n // Get ready for the next line.\n continued = 0;\n self.interrupt = undefined;\n return start;\n }\n effects.consume(code);\n return flowContinue;\n }\n\n /**\n * @param {Token} token\n * Token.\n * @param {boolean | undefined} [endOfFile]\n * Whether the token is at the end of the file (default: `false`).\n * @returns {undefined}\n * Nothing.\n */\n function writeToChild(token, endOfFile) {\n const stream = self.sliceStream(token);\n if (endOfFile) stream.push(null);\n token.previous = childToken;\n if (childToken) childToken.next = token;\n childToken = token;\n childFlow.defineSkip(token.start);\n childFlow.write(stream);\n\n // Alright, so we just added a lazy line:\n //\n // ```markdown\n // > a\n // b.\n //\n // Or:\n //\n // > ~~~c\n // d\n //\n // Or:\n //\n // > | e |\n // f\n // ```\n //\n // The construct in the second example (fenced code) does not accept lazy\n // lines, so it marked itself as done at the end of its first line, and\n // then the content construct parses `d`.\n // Most constructs in markdown match on the first line: if the first line\n // forms a construct, a non-lazy line can’t “unmake” it.\n //\n // The construct in the third example is potentially a GFM table, and\n // those are *weird*.\n // It *could* be a table, from the first line, if the following line\n // matches a condition.\n // In this case, that second line is lazy, which “unmakes” the first line\n // and turns the whole into one content block.\n //\n // We’ve now parsed the non-lazy and the lazy line, and can figure out\n // whether the lazy line started a new flow block.\n // If it did, we exit the current containers between the two flow blocks.\n if (self.parser.lazy[token.start.line]) {\n let index = childFlow.events.length;\n while (index--) {\n if (\n // The token starts before the line ending…\n childFlow.events[index][1].start.offset < lineStartOffset && (\n // …and either is not ended yet…\n !childFlow.events[index][1].end ||\n // …or ends after it.\n childFlow.events[index][1].end.offset > lineStartOffset)) {\n // Exit: there’s still something open, which means it’s a lazy line\n // part of something.\n return;\n }\n }\n\n // Note: this algorithm for moving events around is similar to the\n // algorithm when closing flow in `documentContinue`.\n const indexBeforeExits = self.events.length;\n let indexBeforeFlow = indexBeforeExits;\n /** @type {boolean | undefined} */\n let seen;\n /** @type {Point | undefined} */\n let point;\n\n // Find the previous chunk (the one before the lazy line).\n while (indexBeforeFlow--) {\n if (self.events[indexBeforeFlow][0] === 'exit' && self.events[indexBeforeFlow][1].type === \"chunkFlow\") {\n if (seen) {\n point = self.events[indexBeforeFlow][1].end;\n break;\n }\n seen = true;\n }\n }\n exitContainers(continued);\n\n // Fix positions.\n index = indexBeforeExits;\n while (index < self.events.length) {\n self.events[index][1].end = {\n ...point\n };\n index++;\n }\n\n // Inject the exits earlier (they’re still also at the end).\n splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));\n\n // Discard the duplicate exits.\n self.events.length = index;\n }\n }\n\n /**\n * @param {number} size\n * Size.\n * @returns {undefined}\n * Nothing.\n */\n function exitContainers(size) {\n let index = stack.length;\n\n // Exit open containers.\n while (index-- > size) {\n const entry = stack[index];\n self.containerState = entry[1];\n entry[0].exit.call(self, effects);\n }\n stack.length = size;\n }\n function closeFlow() {\n childFlow.write([null]);\n childToken = undefined;\n childFlow = undefined;\n self.containerState._closeFlow = undefined;\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n * Tokenizer.\n */\nfunction tokenizeContainer(effects, ok, nok) {\n // Always populated by defaults.\n\n return factorySpace(effects, effects.attempt(this.parser.constructs.document, ok, nok), \"linePrefix\", this.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4);\n}","/**\n * @import {Code} from 'micromark-util-types'\n */\n\nimport { markdownLineEndingOrSpace, unicodePunctuation, unicodeWhitespace } from 'micromark-util-character';\n/**\n * Classify whether a code represents whitespace, punctuation, or something\n * else.\n *\n * Used for attention (emphasis, strong), whose sequences can open or close\n * based on the class of surrounding characters.\n *\n * > 👉 **Note**: eof (`null`) is seen as whitespace.\n *\n * @param {Code} code\n * Code.\n * @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined}\n * Group.\n */\nexport function classifyCharacter(code) {\n if (code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) {\n return 1;\n }\n if (unicodePunctuation(code)) {\n return 2;\n }\n}","/**\n * @import {Event, Resolver, TokenizeContext} from 'micromark-util-types'\n */\n\n/**\n * Call all `resolveAll`s.\n *\n * @param {ReadonlyArray<{resolveAll?: Resolver | undefined}>} constructs\n * List of constructs, optionally with `resolveAll`s.\n * @param {Array<Event>} events\n * List of events.\n * @param {TokenizeContext} context\n * Context used by `tokenize`.\n * @returns {Array<Event>}\n * Changed events.\n */\nexport function resolveAll(constructs, events, context) {\n /** @type {Array<Resolver>} */\n const called = []\n let index = -1\n\n while (++index < constructs.length) {\n const resolve = constructs[index].resolveAll\n\n if (resolve && !called.includes(resolve)) {\n events = resolve(events, context)\n called.push(resolve)\n }\n }\n\n return events\n}\n","/**\n * @import {\n * Code,\n * Construct,\n * Event,\n * Point,\n * Resolver,\n * State,\n * TokenizeContext,\n * Tokenizer,\n * Token\n * } from 'micromark-util-types'\n */\n\nimport { push, splice } from 'micromark-util-chunked';\nimport { classifyCharacter } from 'micromark-util-classify-character';\nimport { resolveAll } from 'micromark-util-resolve-all';\n/** @type {Construct} */\nexport const attention = {\n name: 'attention',\n resolveAll: resolveAllAttention,\n tokenize: tokenizeAttention\n};\n\n/**\n * Take all events and resolve attention to emphasis or strong.\n *\n * @type {Resolver}\n */\n// eslint-disable-next-line complexity\nfunction resolveAllAttention(events, context) {\n let index = -1;\n /** @type {number} */\n let open;\n /** @type {Token} */\n let group;\n /** @type {Token} */\n let text;\n /** @type {Token} */\n let openingSequence;\n /** @type {Token} */\n let closingSequence;\n /** @type {number} */\n let use;\n /** @type {Array<Event>} */\n let nextEvents;\n /** @type {number} */\n let offset;\n\n // Walk through all events.\n //\n // Note: performance of this is fine on an mb of normal markdown, but it’s\n // a bottleneck for malicious stuff.\n while (++index < events.length) {\n // Find a token that can close.\n if (events[index][0] === 'enter' && events[index][1].type === 'attentionSequence' && events[index][1]._close) {\n open = index;\n\n // Now walk back to find an opener.\n while (open--) {\n // Find a token that can open the closer.\n if (events[open][0] === 'exit' && events[open][1].type === 'attentionSequence' && events[open][1]._open &&\n // If the markers are the same:\n context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index][1]).charCodeAt(0)) {\n // If the opening can close or the closing can open,\n // and the close size *is not* a multiple of three,\n // but the sum of the opening and closing size *is* multiple of three,\n // then don’t match.\n if ((events[open][1]._close || events[index][1]._open) && (events[index][1].end.offset - events[index][1].start.offset) % 3 && !((events[open][1].end.offset - events[open][1].start.offset + events[index][1].end.offset - events[index][1].start.offset) % 3)) {\n continue;\n }\n\n // Number of markers to use from the sequence.\n use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index][1].end.offset - events[index][1].start.offset > 1 ? 2 : 1;\n const start = {\n ...events[open][1].end\n };\n const end = {\n ...events[index][1].start\n };\n movePoint(start, -use);\n movePoint(end, use);\n openingSequence = {\n type: use > 1 ? \"strongSequence\" : \"emphasisSequence\",\n start,\n end: {\n ...events[open][1].end\n }\n };\n closingSequence = {\n type: use > 1 ? \"strongSequence\" : \"emphasisSequence\",\n start: {\n ...events[index][1].start\n },\n end\n };\n text = {\n type: use > 1 ? \"strongText\" : \"emphasisText\",\n start: {\n ...events[open][1].end\n },\n end: {\n ...events[index][1].start\n }\n };\n group = {\n type: use > 1 ? \"strong\" : \"emphasis\",\n start: {\n ...openingSequence.start\n },\n end: {\n ...closingSequence.end\n }\n };\n events[open][1].end = {\n ...openingSequence.start\n };\n events[index][1].start = {\n ...closingSequence.end\n };\n nextEvents = [];\n\n // If there are more markers in the opening, add them before.\n if (events[open][1].end.offset - events[open][1].start.offset) {\n nextEvents = push(nextEvents, [['enter', events[open][1], context], ['exit', events[open][1], context]]);\n }\n\n // Opening.\n nextEvents = push(nextEvents, [['enter', group, context], ['enter', openingSequence, context], ['exit', openingSequence, context], ['enter', text, context]]);\n\n // Always populated by defaults.\n\n // Between.\n nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index), context));\n\n // Closing.\n nextEvents = push(nextEvents, [['exit', text, context], ['enter', closingSequence, context], ['exit', closingSequence, context], ['exit', group, context]]);\n\n // If there are more markers in the closing, add them after.\n if (events[index][1].end.offset - events[index][1].start.offset) {\n offset = 2;\n nextEvents = push(nextEvents, [['enter', events[index][1], context], ['exit', events[index][1], context]]);\n } else {\n offset = 0;\n }\n splice(events, open - 1, index - open + 3, nextEvents);\n index = open + nextEvents.length - offset - 2;\n break;\n }\n }\n }\n }\n\n // Remove remaining sequences.\n index = -1;\n while (++index < events.length) {\n if (events[index][1].type === 'attentionSequence') {\n events[index][1].type = 'data';\n }\n }\n return events;\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeAttention(effects, ok) {\n const attentionMarkers = this.parser.constructs.attentionMarkers.null;\n const previous = this.previous;\n const before = classifyCharacter(previous);\n\n /** @type {NonNullable<Code>} */\n let marker;\n return start;\n\n /**\n * Before a sequence.\n *\n * ```markdown\n * > | **\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n marker = code;\n effects.enter('attentionSequence');\n return inside(code);\n }\n\n /**\n * In a sequence.\n *\n * ```markdown\n * > | **\n * ^^\n * ```\n *\n * @type {State}\n */\n function inside(code) {\n if (code === marker) {\n effects.consume(code);\n return inside;\n }\n const token = effects.exit('attentionSequence');\n\n // To do: next major: move this to resolver, just like `markdown-rs`.\n const after = classifyCharacter(code);\n\n // Always populated by defaults.\n\n const open = !after || after === 2 && before || attentionMarkers.includes(code);\n const close = !before || before === 2 && after || attentionMarkers.includes(previous);\n token._open = Boolean(marker === 42 ? open : open && (before || !close));\n token._close = Boolean(marker === 42 ? close : close && (after || !open));\n return ok(code);\n }\n}\n\n/**\n * Move a point a bit.\n *\n * Note: `move` only works inside lines! It’s not possible to move past other\n * chunks (replacement characters, tabs, or line endings).\n *\n * @param {Point} point\n * Point.\n * @param {number} offset\n * Amount to move.\n * @returns {undefined}\n * Nothing.\n */\nfunction movePoint(point, offset) {\n point.column += offset;\n point.offset += offset;\n point._bufferIndex += offset;\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { asciiAlphanumeric, asciiAlpha, asciiAtext, asciiControl } from 'micromark-util-character';\n/** @type {Construct} */\nexport const autolink = {\n name: 'autolink',\n tokenize: tokenizeAutolink\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeAutolink(effects, ok, nok) {\n let size = 0;\n return start;\n\n /**\n * Start of an autolink.\n *\n * ```markdown\n * > | a<https://example.com>b\n * ^\n * > | a<user@example.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"autolink\");\n effects.enter(\"autolinkMarker\");\n effects.consume(code);\n effects.exit(\"autolinkMarker\");\n effects.enter(\"autolinkProtocol\");\n return open;\n }\n\n /**\n * After `<`, at protocol or atext.\n *\n * ```markdown\n * > | a<https://example.com>b\n * ^\n * > | a<user@example.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (asciiAlpha(code)) {\n effects.consume(code);\n return schemeOrEmailAtext;\n }\n if (code === 64) {\n return nok(code);\n }\n return emailAtext(code);\n }\n\n /**\n * At second byte of protocol or atext.\n *\n * ```markdown\n * > | a<https://example.com>b\n * ^\n * > | a<user@example.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function schemeOrEmailAtext(code) {\n // ASCII alphanumeric and `+`, `-`, and `.`.\n if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) {\n // Count the previous alphabetical from `open` too.\n size = 1;\n return schemeInsideOrEmailAtext(code);\n }\n return emailAtext(code);\n }\n\n /**\n * In ambiguous protocol or atext.\n *\n * ```markdown\n * > | a<https://example.com>b\n * ^\n * > | a<user@example.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function schemeInsideOrEmailAtext(code) {\n if (code === 58) {\n effects.consume(code);\n size = 0;\n return urlInside;\n }\n\n // ASCII alphanumeric and `+`, `-`, and `.`.\n if ((code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && size++ < 32) {\n effects.consume(code);\n return schemeInsideOrEmailAtext;\n }\n size = 0;\n return emailAtext(code);\n }\n\n /**\n * After protocol, in URL.\n *\n * ```markdown\n * > | a<https://example.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function urlInside(code) {\n if (code === 62) {\n effects.exit(\"autolinkProtocol\");\n effects.enter(\"autolinkMarker\");\n effects.consume(code);\n effects.exit(\"autolinkMarker\");\n effects.exit(\"autolink\");\n return ok;\n }\n\n // ASCII control, space, or `<`.\n if (code === null || code === 32 || code === 60 || asciiControl(code)) {\n return nok(code);\n }\n effects.consume(code);\n return urlInside;\n }\n\n /**\n * In email atext.\n *\n * ```markdown\n * > | a<user.name@example.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function emailAtext(code) {\n if (code === 64) {\n effects.consume(code);\n return emailAtSignOrDot;\n }\n if (asciiAtext(code)) {\n effects.consume(code);\n return emailAtext;\n }\n return nok(code);\n }\n\n /**\n * In label, after at-sign or dot.\n *\n * ```markdown\n * > | a<user.name@example.com>b\n * ^ ^\n * ```\n *\n * @type {State}\n */\n function emailAtSignOrDot(code) {\n return asciiAlphanumeric(code) ? emailLabel(code) : nok(code);\n }\n\n /**\n * In label, where `.` and `>` are allowed.\n *\n * ```markdown\n * > | a<user.name@example.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function emailLabel(code) {\n if (code === 46) {\n effects.consume(code);\n size = 0;\n return emailAtSignOrDot;\n }\n if (code === 62) {\n // Exit, then change the token type.\n effects.exit(\"autolinkProtocol\").type = \"autolinkEmail\";\n effects.enter(\"autolinkMarker\");\n effects.consume(code);\n effects.exit(\"autolinkMarker\");\n effects.exit(\"autolink\");\n return ok;\n }\n return emailValue(code);\n }\n\n /**\n * In label, where `.` and `>` are *not* allowed.\n *\n * Though, this is also used in `emailLabel` to parse other values.\n *\n * ```markdown\n * > | a<user.name@ex-ample.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function emailValue(code) {\n // ASCII alphanumeric or `-`.\n if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) {\n const next = code === 45 ? emailValue : emailLabel;\n effects.consume(code);\n return next;\n }\n return nok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nexport const blankLine = {\n partial: true,\n tokenize: tokenizeBlankLine\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeBlankLine(effects, ok, nok) {\n return start;\n\n /**\n * Start of blank line.\n *\n * > 👉 **Note**: `␠` represents a space character.\n *\n * ```markdown\n * > | ␠␠␊\n * ^\n * > | ␊\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n return markdownSpace(code) ? factorySpace(effects, after, \"linePrefix\")(code) : after(code);\n }\n\n /**\n * At eof/eol, after optional whitespace.\n *\n * > 👉 **Note**: `␠` represents a space character.\n *\n * ```markdown\n * > | ␠␠␊\n * ^\n * > | ␊\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n return code === null || markdownLineEnding(code) ? ok(code) : nok(code);\n }\n}","/**\n * @import {\n * Construct,\n * Exiter,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nexport const blockQuote = {\n continuation: {\n tokenize: tokenizeBlockQuoteContinuation\n },\n exit,\n name: 'blockQuote',\n tokenize: tokenizeBlockQuoteStart\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeBlockQuoteStart(effects, ok, nok) {\n const self = this;\n return start;\n\n /**\n * Start of block quote.\n *\n * ```markdown\n * > | > a\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n if (code === 62) {\n const state = self.containerState;\n if (!state.open) {\n effects.enter(\"blockQuote\", {\n _container: true\n });\n state.open = true;\n }\n effects.enter(\"blockQuotePrefix\");\n effects.enter(\"blockQuoteMarker\");\n effects.consume(code);\n effects.exit(\"blockQuoteMarker\");\n return after;\n }\n return nok(code);\n }\n\n /**\n * After `>`, before optional whitespace.\n *\n * ```markdown\n * > | > a\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n if (markdownSpace(code)) {\n effects.enter(\"blockQuotePrefixWhitespace\");\n effects.consume(code);\n effects.exit(\"blockQuotePrefixWhitespace\");\n effects.exit(\"blockQuotePrefix\");\n return ok;\n }\n effects.exit(\"blockQuotePrefix\");\n return ok(code);\n }\n}\n\n/**\n * Start of block quote continuation.\n *\n * ```markdown\n * | > a\n * > | > b\n * ^\n * ```\n *\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeBlockQuoteContinuation(effects, ok, nok) {\n const self = this;\n return contStart;\n\n /**\n * Start of block quote continuation.\n *\n * Also used to parse the first block quote opening.\n *\n * ```markdown\n * | > a\n * > | > b\n * ^\n * ```\n *\n * @type {State}\n */\n function contStart(code) {\n if (markdownSpace(code)) {\n // Always populated by defaults.\n\n return factorySpace(effects, contBefore, \"linePrefix\", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code);\n }\n return contBefore(code);\n }\n\n /**\n * At `>`, after optional whitespace.\n *\n * Also used to parse the first block quote opening.\n *\n * ```markdown\n * | > a\n * > | > b\n * ^\n * ```\n *\n * @type {State}\n */\n function contBefore(code) {\n return effects.attempt(blockQuote, ok, nok)(code);\n }\n}\n\n/** @type {Exiter} */\nfunction exit(effects) {\n effects.exit(\"blockQuote\");\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { asciiPunctuation } from 'micromark-util-character';\n/** @type {Construct} */\nexport const characterEscape = {\n name: 'characterEscape',\n tokenize: tokenizeCharacterEscape\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeCharacterEscape(effects, ok, nok) {\n return start;\n\n /**\n * Start of character escape.\n *\n * ```markdown\n * > | a\\*b\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"characterEscape\");\n effects.enter(\"escapeMarker\");\n effects.consume(code);\n effects.exit(\"escapeMarker\");\n return inside;\n }\n\n /**\n * After `\\`, at punctuation.\n *\n * ```markdown\n * > | a\\*b\n * ^\n * ```\n *\n * @type {State}\n */\n function inside(code) {\n // ASCII punctuation.\n if (asciiPunctuation(code)) {\n effects.enter(\"characterEscapeValue\");\n effects.consume(code);\n effects.exit(\"characterEscapeValue\");\n effects.exit(\"characterEscape\");\n return ok;\n }\n return nok(code);\n }\n}","/**\n * @import {\n * Code,\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { decodeNamedCharacterReference } from 'decode-named-character-reference';\nimport { asciiAlphanumeric, asciiDigit, asciiHexDigit } from 'micromark-util-character';\n/** @type {Construct} */\nexport const characterReference = {\n name: 'characterReference',\n tokenize: tokenizeCharacterReference\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeCharacterReference(effects, ok, nok) {\n const self = this;\n let size = 0;\n /** @type {number} */\n let max;\n /** @type {(code: Code) => boolean} */\n let test;\n return start;\n\n /**\n * Start of character reference.\n *\n * ```markdown\n * > | a&amp;b\n * ^\n * > | a&#123;b\n * ^\n * > | a&#x9;b\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"characterReference\");\n effects.enter(\"characterReferenceMarker\");\n effects.consume(code);\n effects.exit(\"characterReferenceMarker\");\n return open;\n }\n\n /**\n * After `&`, at `#` for numeric references or alphanumeric for named\n * references.\n *\n * ```markdown\n * > | a&amp;b\n * ^\n * > | a&#123;b\n * ^\n * > | a&#x9;b\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (code === 35) {\n effects.enter(\"characterReferenceMarkerNumeric\");\n effects.consume(code);\n effects.exit(\"characterReferenceMarkerNumeric\");\n return numeric;\n }\n effects.enter(\"characterReferenceValue\");\n max = 31;\n test = asciiAlphanumeric;\n return value(code);\n }\n\n /**\n * After `#`, at `x` for hexadecimals or digit for decimals.\n *\n * ```markdown\n * > | a&#123;b\n * ^\n * > | a&#x9;b\n * ^\n * ```\n *\n * @type {State}\n */\n function numeric(code) {\n if (code === 88 || code === 120) {\n effects.enter(\"characterReferenceMarkerHexadecimal\");\n effects.consume(code);\n effects.exit(\"characterReferenceMarkerHexadecimal\");\n effects.enter(\"characterReferenceValue\");\n max = 6;\n test = asciiHexDigit;\n return value;\n }\n effects.enter(\"characterReferenceValue\");\n max = 7;\n test = asciiDigit;\n return value(code);\n }\n\n /**\n * After markers (`&#x`, `&#`, or `&`), in value, before `;`.\n *\n * The character reference kind defines what and how many characters are\n * allowed.\n *\n * ```markdown\n * > | a&amp;b\n * ^^^\n * > | a&#123;b\n * ^^^\n * > | a&#x9;b\n * ^\n * ```\n *\n * @type {State}\n */\n function value(code) {\n if (code === 59 && size) {\n const token = effects.exit(\"characterReferenceValue\");\n if (test === asciiAlphanumeric && !decodeNamedCharacterReference(self.sliceSerialize(token))) {\n return nok(code);\n }\n\n // To do: `markdown-rs` uses a different name:\n // `CharacterReferenceMarkerSemi`.\n effects.enter(\"characterReferenceMarker\");\n effects.consume(code);\n effects.exit(\"characterReferenceMarker\");\n effects.exit(\"characterReference\");\n return ok;\n }\n if (test(code) && size++ < max) {\n effects.consume(code);\n return value;\n }\n return nok(code);\n }\n}","/**\n * @import {\n * Code,\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nconst nonLazyContinuation = {\n partial: true,\n tokenize: tokenizeNonLazyContinuation\n};\n\n/** @type {Construct} */\nexport const codeFenced = {\n concrete: true,\n name: 'codeFenced',\n tokenize: tokenizeCodeFenced\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeCodeFenced(effects, ok, nok) {\n const self = this;\n /** @type {Construct} */\n const closeStart = {\n partial: true,\n tokenize: tokenizeCloseStart\n };\n let initialPrefix = 0;\n let sizeOpen = 0;\n /** @type {NonNullable<Code>} */\n let marker;\n return start;\n\n /**\n * Start of code.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // To do: parse whitespace like `markdown-rs`.\n return beforeSequenceOpen(code);\n }\n\n /**\n * In opening fence, after prefix, at sequence.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function beforeSequenceOpen(code) {\n const tail = self.events[self.events.length - 1];\n initialPrefix = tail && tail[1].type === \"linePrefix\" ? tail[2].sliceSerialize(tail[1], true).length : 0;\n marker = code;\n effects.enter(\"codeFenced\");\n effects.enter(\"codeFencedFence\");\n effects.enter(\"codeFencedFenceSequence\");\n return sequenceOpen(code);\n }\n\n /**\n * In opening fence sequence.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function sequenceOpen(code) {\n if (code === marker) {\n sizeOpen++;\n effects.consume(code);\n return sequenceOpen;\n }\n if (sizeOpen < 3) {\n return nok(code);\n }\n effects.exit(\"codeFencedFenceSequence\");\n return markdownSpace(code) ? factorySpace(effects, infoBefore, \"whitespace\")(code) : infoBefore(code);\n }\n\n /**\n * In opening fence, after the sequence (and optional whitespace), before info.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function infoBefore(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"codeFencedFence\");\n return self.interrupt ? ok(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);\n }\n effects.enter(\"codeFencedFenceInfo\");\n effects.enter(\"chunkString\", {\n contentType: \"string\"\n });\n return info(code);\n }\n\n /**\n * In info.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function info(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"chunkString\");\n effects.exit(\"codeFencedFenceInfo\");\n return infoBefore(code);\n }\n if (markdownSpace(code)) {\n effects.exit(\"chunkString\");\n effects.exit(\"codeFencedFenceInfo\");\n return factorySpace(effects, metaBefore, \"whitespace\")(code);\n }\n if (code === 96 && code === marker) {\n return nok(code);\n }\n effects.consume(code);\n return info;\n }\n\n /**\n * In opening fence, after info and whitespace, before meta.\n *\n * ```markdown\n * > | ~~~js eval\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function metaBefore(code) {\n if (code === null || markdownLineEnding(code)) {\n return infoBefore(code);\n }\n effects.enter(\"codeFencedFenceMeta\");\n effects.enter(\"chunkString\", {\n contentType: \"string\"\n });\n return meta(code);\n }\n\n /**\n * In meta.\n *\n * ```markdown\n * > | ~~~js eval\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function meta(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"chunkString\");\n effects.exit(\"codeFencedFenceMeta\");\n return infoBefore(code);\n }\n if (code === 96 && code === marker) {\n return nok(code);\n }\n effects.consume(code);\n return meta;\n }\n\n /**\n * At eol/eof in code, before a non-lazy closing fence or content.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * > | alert(1)\n * ^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function atNonLazyBreak(code) {\n return effects.attempt(closeStart, after, contentBefore)(code);\n }\n\n /**\n * Before code content, not a closing fence, at eol.\n *\n * ```markdown\n * | ~~~js\n * > | alert(1)\n * ^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function contentBefore(code) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return contentStart;\n }\n\n /**\n * Before code content, not a closing fence.\n *\n * ```markdown\n * | ~~~js\n * > | alert(1)\n * ^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function contentStart(code) {\n return initialPrefix > 0 && markdownSpace(code) ? factorySpace(effects, beforeContentChunk, \"linePrefix\", initialPrefix + 1)(code) : beforeContentChunk(code);\n }\n\n /**\n * Before code content, after optional prefix.\n *\n * ```markdown\n * | ~~~js\n * > | alert(1)\n * ^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function beforeContentChunk(code) {\n if (code === null || markdownLineEnding(code)) {\n return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);\n }\n effects.enter(\"codeFlowValue\");\n return contentChunk(code);\n }\n\n /**\n * In code content.\n *\n * ```markdown\n * | ~~~js\n * > | alert(1)\n * ^^^^^^^^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function contentChunk(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"codeFlowValue\");\n return beforeContentChunk(code);\n }\n effects.consume(code);\n return contentChunk;\n }\n\n /**\n * After code.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n effects.exit(\"codeFenced\");\n return ok(code);\n }\n\n /**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\n function tokenizeCloseStart(effects, ok, nok) {\n let size = 0;\n return startBefore;\n\n /**\n *\n *\n * @type {State}\n */\n function startBefore(code) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return start;\n }\n\n /**\n * Before closing fence, at optional whitespace.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // Always populated by defaults.\n\n // To do: `enter` here or in next state?\n effects.enter(\"codeFencedFence\");\n return markdownSpace(code) ? factorySpace(effects, beforeSequenceClose, \"linePrefix\", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : beforeSequenceClose(code);\n }\n\n /**\n * In closing fence, after optional whitespace, at sequence.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function beforeSequenceClose(code) {\n if (code === marker) {\n effects.enter(\"codeFencedFenceSequence\");\n return sequenceClose(code);\n }\n return nok(code);\n }\n\n /**\n * In closing fence sequence.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceClose(code) {\n if (code === marker) {\n size++;\n effects.consume(code);\n return sequenceClose;\n }\n if (size >= sizeOpen) {\n effects.exit(\"codeFencedFenceSequence\");\n return markdownSpace(code) ? factorySpace(effects, sequenceCloseAfter, \"whitespace\")(code) : sequenceCloseAfter(code);\n }\n return nok(code);\n }\n\n /**\n * After closing fence sequence, after optional whitespace.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceCloseAfter(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"codeFencedFence\");\n return ok(code);\n }\n return nok(code);\n }\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeNonLazyContinuation(effects, ok, nok) {\n const self = this;\n return start;\n\n /**\n *\n *\n * @type {State}\n */\n function start(code) {\n if (code === null) {\n return nok(code);\n }\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return lineStart;\n }\n\n /**\n *\n *\n * @type {State}\n */\n function lineStart(code) {\n return self.parser.lazy[self.now().line] ? nok(code) : ok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nexport const codeIndented = {\n name: 'codeIndented',\n tokenize: tokenizeCodeIndented\n};\n\n/** @type {Construct} */\nconst furtherStart = {\n partial: true,\n tokenize: tokenizeFurtherStart\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeCodeIndented(effects, ok, nok) {\n const self = this;\n return start;\n\n /**\n * Start of code (indented).\n *\n * > **Parsing note**: it is not needed to check if this first line is a\n * > filled line (that it has a non-whitespace character), because blank lines\n * > are parsed already, so we never run into that.\n *\n * ```markdown\n * > | aaa\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // To do: manually check if interrupting like `markdown-rs`.\n\n effects.enter(\"codeIndented\");\n // To do: use an improved `space_or_tab` function like `markdown-rs`,\n // so that we can drop the next state.\n return factorySpace(effects, afterPrefix, \"linePrefix\", 4 + 1)(code);\n }\n\n /**\n * At start, after 1 or 4 spaces.\n *\n * ```markdown\n * > | aaa\n * ^\n * ```\n *\n * @type {State}\n */\n function afterPrefix(code) {\n const tail = self.events[self.events.length - 1];\n return tail && tail[1].type === \"linePrefix\" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? atBreak(code) : nok(code);\n }\n\n /**\n * At a break.\n *\n * ```markdown\n * > | aaa\n * ^ ^\n * ```\n *\n * @type {State}\n */\n function atBreak(code) {\n if (code === null) {\n return after(code);\n }\n if (markdownLineEnding(code)) {\n return effects.attempt(furtherStart, atBreak, after)(code);\n }\n effects.enter(\"codeFlowValue\");\n return inside(code);\n }\n\n /**\n * In code content.\n *\n * ```markdown\n * > | aaa\n * ^^^^\n * ```\n *\n * @type {State}\n */\n function inside(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"codeFlowValue\");\n return atBreak(code);\n }\n effects.consume(code);\n return inside;\n }\n\n /** @type {State} */\n function after(code) {\n effects.exit(\"codeIndented\");\n // To do: allow interrupting like `markdown-rs`.\n // Feel free to interrupt.\n // tokenizer.interrupt = false\n return ok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeFurtherStart(effects, ok, nok) {\n const self = this;\n return furtherStart;\n\n /**\n * At eol, trying to parse another indent.\n *\n * ```markdown\n * > | aaa\n * ^\n * | bbb\n * ```\n *\n * @type {State}\n */\n function furtherStart(code) {\n // To do: improve `lazy` / `pierce` handling.\n // If this is a lazy line, it can’t be code.\n if (self.parser.lazy[self.now().line]) {\n return nok(code);\n }\n if (markdownLineEnding(code)) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return furtherStart;\n }\n\n // To do: the code here in `micromark-js` is a bit different from\n // `markdown-rs` because there it can attempt spaces.\n // We can’t yet.\n //\n // To do: use an improved `space_or_tab` function like `markdown-rs`,\n // so that we can drop the next state.\n return factorySpace(effects, afterPrefix, \"linePrefix\", 4 + 1)(code);\n }\n\n /**\n * At start, after 1 or 4 spaces.\n *\n * ```markdown\n * > | aaa\n * ^\n * ```\n *\n * @type {State}\n */\n function afterPrefix(code) {\n const tail = self.events[self.events.length - 1];\n return tail && tail[1].type === \"linePrefix\" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? ok(code) : markdownLineEnding(code) ? furtherStart(code) : nok(code);\n }\n}","/**\n * @import {\n * Construct,\n * Previous,\n * Resolver,\n * State,\n * TokenizeContext,\n * Tokenizer,\n * Token\n * } from 'micromark-util-types'\n */\n\nimport { markdownLineEnding } from 'micromark-util-character';\n/** @type {Construct} */\nexport const codeText = {\n name: 'codeText',\n previous,\n resolve: resolveCodeText,\n tokenize: tokenizeCodeText\n};\n\n// To do: next major: don’t resolve, like `markdown-rs`.\n/** @type {Resolver} */\nfunction resolveCodeText(events) {\n let tailExitIndex = events.length - 4;\n let headEnterIndex = 3;\n /** @type {number} */\n let index;\n /** @type {number | undefined} */\n let enter;\n\n // If we start and end with an EOL or a space.\n if ((events[headEnterIndex][1].type === \"lineEnding\" || events[headEnterIndex][1].type === 'space') && (events[tailExitIndex][1].type === \"lineEnding\" || events[tailExitIndex][1].type === 'space')) {\n index = headEnterIndex;\n\n // And we have data.\n while (++index < tailExitIndex) {\n if (events[index][1].type === \"codeTextData\") {\n // Then we have padding.\n events[headEnterIndex][1].type = \"codeTextPadding\";\n events[tailExitIndex][1].type = \"codeTextPadding\";\n headEnterIndex += 2;\n tailExitIndex -= 2;\n break;\n }\n }\n }\n\n // Merge adjacent spaces and data.\n index = headEnterIndex - 1;\n tailExitIndex++;\n while (++index <= tailExitIndex) {\n if (enter === undefined) {\n if (index !== tailExitIndex && events[index][1].type !== \"lineEnding\") {\n enter = index;\n }\n } else if (index === tailExitIndex || events[index][1].type === \"lineEnding\") {\n events[enter][1].type = \"codeTextData\";\n if (index !== enter + 2) {\n events[enter][1].end = events[index - 1][1].end;\n events.splice(enter + 2, index - enter - 2);\n tailExitIndex -= index - enter - 2;\n index = enter + 2;\n }\n enter = undefined;\n }\n }\n return events;\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Previous}\n */\nfunction previous(code) {\n // If there is a previous code, there will always be a tail.\n return code !== 96 || this.events[this.events.length - 1][1].type === \"characterEscape\";\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeCodeText(effects, ok, nok) {\n const self = this;\n let sizeOpen = 0;\n /** @type {number} */\n let size;\n /** @type {Token} */\n let token;\n return start;\n\n /**\n * Start of code (text).\n *\n * ```markdown\n * > | `a`\n * ^\n * > | \\`a`\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"codeText\");\n effects.enter(\"codeTextSequence\");\n return sequenceOpen(code);\n }\n\n /**\n * In opening sequence.\n *\n * ```markdown\n * > | `a`\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceOpen(code) {\n if (code === 96) {\n effects.consume(code);\n sizeOpen++;\n return sequenceOpen;\n }\n effects.exit(\"codeTextSequence\");\n return between(code);\n }\n\n /**\n * Between something and something else.\n *\n * ```markdown\n * > | `a`\n * ^^\n * ```\n *\n * @type {State}\n */\n function between(code) {\n // EOF.\n if (code === null) {\n return nok(code);\n }\n\n // To do: next major: don’t do spaces in resolve, but when compiling,\n // like `markdown-rs`.\n // Tabs don’t work, and virtual spaces don’t make sense.\n if (code === 32) {\n effects.enter('space');\n effects.consume(code);\n effects.exit('space');\n return between;\n }\n\n // Closing fence? Could also be data.\n if (code === 96) {\n token = effects.enter(\"codeTextSequence\");\n size = 0;\n return sequenceClose(code);\n }\n if (markdownLineEnding(code)) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return between;\n }\n\n // Data.\n effects.enter(\"codeTextData\");\n return data(code);\n }\n\n /**\n * In data.\n *\n * ```markdown\n * > | `a`\n * ^\n * ```\n *\n * @type {State}\n */\n function data(code) {\n if (code === null || code === 32 || code === 96 || markdownLineEnding(code)) {\n effects.exit(\"codeTextData\");\n return between(code);\n }\n effects.consume(code);\n return data;\n }\n\n /**\n * In closing sequence.\n *\n * ```markdown\n * > | `a`\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceClose(code) {\n // More.\n if (code === 96) {\n effects.consume(code);\n size++;\n return sequenceClose;\n }\n\n // Done!\n if (size === sizeOpen) {\n effects.exit(\"codeTextSequence\");\n effects.exit(\"codeText\");\n return ok(code);\n }\n\n // More or less accents: mark as data.\n token.type = \"codeTextData\";\n return data(code);\n }\n}","/**\n * Some of the internal operations of micromark do lots of editing\n * operations on very large arrays. This runs into problems with two\n * properties of most circa-2020 JavaScript interpreters:\n *\n * - Array-length modifications at the high end of an array (push/pop) are\n * expected to be common and are implemented in (amortized) time\n * proportional to the number of elements added or removed, whereas\n * other operations (shift/unshift and splice) are much less efficient.\n * - Function arguments are passed on the stack, so adding tens of thousands\n * of elements to an array with `arr.push(...newElements)` will frequently\n * cause stack overflows. (see <https://stackoverflow.com/questions/22123769/rangeerror-maximum-call-stack-size-exceeded-why>)\n *\n * SpliceBuffers are an implementation of gap buffers, which are a\n * generalization of the \"queue made of two stacks\" idea. The splice buffer\n * maintains a cursor, and moving the cursor has cost proportional to the\n * distance the cursor moves, but inserting, deleting, or splicing in\n * new information at the cursor is as efficient as the push/pop operation.\n * This allows for an efficient sequence of splices (or pushes, pops, shifts,\n * or unshifts) as long such edits happen at the same part of the array or\n * generally sweep through the array from the beginning to the end.\n *\n * The interface for splice buffers also supports large numbers of inputs by\n * passing a single array argument rather passing multiple arguments on the\n * function call stack.\n *\n * @template T\n * Item type.\n */\nexport class SpliceBuffer {\n /**\n * @param {ReadonlyArray<T> | null | undefined} [initial]\n * Initial items (optional).\n * @returns\n * Splice buffer.\n */\n constructor(initial) {\n /** @type {Array<T>} */\n this.left = initial ? [...initial] : [];\n /** @type {Array<T>} */\n this.right = [];\n }\n\n /**\n * Array access;\n * does not move the cursor.\n *\n * @param {number} index\n * Index.\n * @return {T}\n * Item.\n */\n get(index) {\n if (index < 0 || index >= this.left.length + this.right.length) {\n throw new RangeError('Cannot access index `' + index + '` in a splice buffer of size `' + (this.left.length + this.right.length) + '`');\n }\n if (index < this.left.length) return this.left[index];\n return this.right[this.right.length - index + this.left.length - 1];\n }\n\n /**\n * The length of the splice buffer, one greater than the largest index in the\n * array.\n */\n get length() {\n return this.left.length + this.right.length;\n }\n\n /**\n * Remove and return `list[0]`;\n * moves the cursor to `0`.\n *\n * @returns {T | undefined}\n * Item, optional.\n */\n shift() {\n this.setCursor(0);\n return this.right.pop();\n }\n\n /**\n * Slice the buffer to get an array;\n * does not move the cursor.\n *\n * @param {number} start\n * Start.\n * @param {number | null | undefined} [end]\n * End (optional).\n * @returns {Array<T>}\n * Array of items.\n */\n slice(start, end) {\n /** @type {number} */\n const stop = end === null || end === undefined ? Number.POSITIVE_INFINITY : end;\n if (stop < this.left.length) {\n return this.left.slice(start, stop);\n }\n if (start > this.left.length) {\n return this.right.slice(this.right.length - stop + this.left.length, this.right.length - start + this.left.length).reverse();\n }\n return this.left.slice(start).concat(this.right.slice(this.right.length - stop + this.left.length).reverse());\n }\n\n /**\n * Mimics the behavior of Array.prototype.splice() except for the change of\n * interface necessary to avoid segfaults when patching in very large arrays.\n *\n * This operation moves cursor is moved to `start` and results in the cursor\n * placed after any inserted items.\n *\n * @param {number} start\n * Start;\n * zero-based index at which to start changing the array;\n * negative numbers count backwards from the end of the array and values\n * that are out-of bounds are clamped to the appropriate end of the array.\n * @param {number | null | undefined} [deleteCount=0]\n * Delete count (default: `0`);\n * maximum number of elements to delete, starting from start.\n * @param {Array<T> | null | undefined} [items=[]]\n * Items to include in place of the deleted items (default: `[]`).\n * @return {Array<T>}\n * Any removed items.\n */\n splice(start, deleteCount, items) {\n /** @type {number} */\n const count = deleteCount || 0;\n this.setCursor(Math.trunc(start));\n const removed = this.right.splice(this.right.length - count, Number.POSITIVE_INFINITY);\n if (items) chunkedPush(this.left, items);\n return removed.reverse();\n }\n\n /**\n * Remove and return the highest-numbered item in the array, so\n * `list[list.length - 1]`;\n * Moves the cursor to `length`.\n *\n * @returns {T | undefined}\n * Item, optional.\n */\n pop() {\n this.setCursor(Number.POSITIVE_INFINITY);\n return this.left.pop();\n }\n\n /**\n * Inserts a single item to the high-numbered side of the array;\n * moves the cursor to `length`.\n *\n * @param {T} item\n * Item.\n * @returns {undefined}\n * Nothing.\n */\n push(item) {\n this.setCursor(Number.POSITIVE_INFINITY);\n this.left.push(item);\n }\n\n /**\n * Inserts many items to the high-numbered side of the array.\n * Moves the cursor to `length`.\n *\n * @param {Array<T>} items\n * Items.\n * @returns {undefined}\n * Nothing.\n */\n pushMany(items) {\n this.setCursor(Number.POSITIVE_INFINITY);\n chunkedPush(this.left, items);\n }\n\n /**\n * Inserts a single item to the low-numbered side of the array;\n * Moves the cursor to `0`.\n *\n * @param {T} item\n * Item.\n * @returns {undefined}\n * Nothing.\n */\n unshift(item) {\n this.setCursor(0);\n this.right.push(item);\n }\n\n /**\n * Inserts many items to the low-numbered side of the array;\n * moves the cursor to `0`.\n *\n * @param {Array<T>} items\n * Items.\n * @returns {undefined}\n * Nothing.\n */\n unshiftMany(items) {\n this.setCursor(0);\n chunkedPush(this.right, items.reverse());\n }\n\n /**\n * Move the cursor to a specific position in the array. Requires\n * time proportional to the distance moved.\n *\n * If `n < 0`, the cursor will end up at the beginning.\n * If `n > length`, the cursor will end up at the end.\n *\n * @param {number} n\n * Position.\n * @return {undefined}\n * Nothing.\n */\n setCursor(n) {\n if (n === this.left.length || n > this.left.length && this.right.length === 0 || n < 0 && this.left.length === 0) return;\n if (n < this.left.length) {\n // Move cursor to the this.left\n const removed = this.left.splice(n, Number.POSITIVE_INFINITY);\n chunkedPush(this.right, removed.reverse());\n } else {\n // Move cursor to the this.right\n const removed = this.right.splice(this.left.length + this.right.length - n, Number.POSITIVE_INFINITY);\n chunkedPush(this.left, removed.reverse());\n }\n }\n}\n\n/**\n * Avoid stack overflow by pushing items onto the stack in segments\n *\n * @template T\n * Item type.\n * @param {Array<T>} list\n * List to inject into.\n * @param {ReadonlyArray<T>} right\n * Items to inject.\n * @return {undefined}\n * Nothing.\n */\nfunction chunkedPush(list, right) {\n /** @type {number} */\n let chunkStart = 0;\n if (right.length < 10000) {\n list.push(...right);\n } else {\n while (chunkStart < right.length) {\n list.push(...right.slice(chunkStart, chunkStart + 10000));\n chunkStart += 10000;\n }\n }\n}","/**\n * @import {Chunk, Event, Token} from 'micromark-util-types'\n */\n\nimport { splice } from 'micromark-util-chunked';\nimport { SpliceBuffer } from './lib/splice-buffer.js';\n\n// Hidden API exposed for testing.\nexport { SpliceBuffer } from './lib/splice-buffer.js';\n\n/**\n * Tokenize subcontent.\n *\n * @param {Array<Event>} eventsArray\n * List of events.\n * @returns {boolean}\n * Whether subtokens were found.\n */\n// eslint-disable-next-line complexity\nexport function subtokenize(eventsArray) {\n /** @type {Record<string, number>} */\n const jumps = {};\n let index = -1;\n /** @type {Event} */\n let event;\n /** @type {number | undefined} */\n let lineIndex;\n /** @type {number} */\n let otherIndex;\n /** @type {Event} */\n let otherEvent;\n /** @type {Array<Event>} */\n let parameters;\n /** @type {Array<Event>} */\n let subevents;\n /** @type {boolean | undefined} */\n let more;\n const events = new SpliceBuffer(eventsArray);\n while (++index < events.length) {\n while (index in jumps) {\n index = jumps[index];\n }\n event = events.get(index);\n\n // Add a hook for the GFM tasklist extension, which needs to know if text\n // is in the first content of a list item.\n if (index && event[1].type === \"chunkFlow\" && events.get(index - 1)[1].type === \"listItemPrefix\") {\n subevents = event[1]._tokenizer.events;\n otherIndex = 0;\n if (otherIndex < subevents.length && subevents[otherIndex][1].type === \"lineEndingBlank\") {\n otherIndex += 2;\n }\n if (otherIndex < subevents.length && subevents[otherIndex][1].type === \"content\") {\n while (++otherIndex < subevents.length) {\n if (subevents[otherIndex][1].type === \"content\") {\n break;\n }\n if (subevents[otherIndex][1].type === \"chunkText\") {\n subevents[otherIndex][1]._isInFirstContentOfListItem = true;\n otherIndex++;\n }\n }\n }\n }\n\n // Enter.\n if (event[0] === 'enter') {\n if (event[1].contentType) {\n Object.assign(jumps, subcontent(events, index));\n index = jumps[index];\n more = true;\n }\n }\n // Exit.\n else if (event[1]._container) {\n otherIndex = index;\n lineIndex = undefined;\n while (otherIndex--) {\n otherEvent = events.get(otherIndex);\n if (otherEvent[1].type === \"lineEnding\" || otherEvent[1].type === \"lineEndingBlank\") {\n if (otherEvent[0] === 'enter') {\n if (lineIndex) {\n events.get(lineIndex)[1].type = \"lineEndingBlank\";\n }\n otherEvent[1].type = \"lineEnding\";\n lineIndex = otherIndex;\n }\n } else if (otherEvent[1].type === \"linePrefix\" || otherEvent[1].type === \"listItemIndent\") {\n // Move past.\n } else {\n break;\n }\n }\n if (lineIndex) {\n // Fix position.\n event[1].end = {\n ...events.get(lineIndex)[1].start\n };\n\n // Switch container exit w/ line endings.\n parameters = events.slice(lineIndex, index);\n parameters.unshift(event);\n events.splice(lineIndex, index - lineIndex + 1, parameters);\n }\n }\n }\n\n // The changes to the `events` buffer must be copied back into the eventsArray\n splice(eventsArray, 0, Number.POSITIVE_INFINITY, events.slice(0));\n return !more;\n}\n\n/**\n * Tokenize embedded tokens.\n *\n * @param {SpliceBuffer<Event>} events\n * Events.\n * @param {number} eventIndex\n * Index.\n * @returns {Record<string, number>}\n * Gaps.\n */\nfunction subcontent(events, eventIndex) {\n const token = events.get(eventIndex)[1];\n const context = events.get(eventIndex)[2];\n let startPosition = eventIndex - 1;\n /** @type {Array<number>} */\n const startPositions = [];\n let tokenizer = token._tokenizer;\n if (!tokenizer) {\n tokenizer = context.parser[token.contentType](token.start);\n if (token._contentTypeTextTrailing) {\n tokenizer._contentTypeTextTrailing = true;\n }\n }\n const childEvents = tokenizer.events;\n /** @type {Array<[number, number]>} */\n const jumps = [];\n /** @type {Record<string, number>} */\n const gaps = {};\n /** @type {Array<Chunk>} */\n let stream;\n /** @type {Token | undefined} */\n let previous;\n let index = -1;\n /** @type {Token | undefined} */\n let current = token;\n let adjust = 0;\n let start = 0;\n const breaks = [start];\n\n // Loop forward through the linked tokens to pass them in order to the\n // subtokenizer.\n while (current) {\n // Find the position of the event for this token.\n while (events.get(++startPosition)[1] !== current) {\n // Empty.\n }\n startPositions.push(startPosition);\n if (!current._tokenizer) {\n stream = context.sliceStream(current);\n if (!current.next) {\n stream.push(null);\n }\n if (previous) {\n tokenizer.defineSkip(current.start);\n }\n if (current._isInFirstContentOfListItem) {\n tokenizer._gfmTasklistFirstContentOfListItem = true;\n }\n tokenizer.write(stream);\n if (current._isInFirstContentOfListItem) {\n tokenizer._gfmTasklistFirstContentOfListItem = undefined;\n }\n }\n\n // Unravel the next token.\n previous = current;\n current = current.next;\n }\n\n // Now, loop back through all events (and linked tokens), to figure out which\n // parts belong where.\n current = token;\n while (++index < childEvents.length) {\n if (\n // Find a void token that includes a break.\n childEvents[index][0] === 'exit' && childEvents[index - 1][0] === 'enter' && childEvents[index][1].type === childEvents[index - 1][1].type && childEvents[index][1].start.line !== childEvents[index][1].end.line) {\n start = index + 1;\n breaks.push(start);\n // Help GC.\n current._tokenizer = undefined;\n current.previous = undefined;\n current = current.next;\n }\n }\n\n // Help GC.\n tokenizer.events = [];\n\n // If there’s one more token (which is the cases for lines that end in an\n // EOF), that’s perfect: the last point we found starts it.\n // If there isn’t then make sure any remaining content is added to it.\n if (current) {\n // Help GC.\n current._tokenizer = undefined;\n current.previous = undefined;\n } else {\n breaks.pop();\n }\n\n // Now splice the events from the subtokenizer into the current events,\n // moving back to front so that splice indices aren’t affected.\n index = breaks.length;\n while (index--) {\n const slice = childEvents.slice(breaks[index], breaks[index + 1]);\n const start = startPositions.pop();\n jumps.push([start, start + slice.length - 1]);\n events.splice(start, 2, slice);\n }\n jumps.reverse();\n index = -1;\n while (++index < jumps.length) {\n gaps[adjust + jumps[index][0]] = adjust + jumps[index][1];\n adjust += jumps[index][1] - jumps[index][0] - 1;\n }\n return gaps;\n}","/**\n * @import {\n * Construct,\n * Resolver,\n * State,\n * TokenizeContext,\n * Tokenizer,\n * Token\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding } from 'micromark-util-character';\nimport { subtokenize } from 'micromark-util-subtokenize';\n/**\n * No name because it must not be turned off.\n * @type {Construct}\n */\nexport const content = {\n resolve: resolveContent,\n tokenize: tokenizeContent\n};\n\n/** @type {Construct} */\nconst continuationConstruct = {\n partial: true,\n tokenize: tokenizeContinuation\n};\n\n/**\n * Content is transparent: it’s parsed right now. That way, definitions are also\n * parsed right now: before text in paragraphs (specifically, media) are parsed.\n *\n * @type {Resolver}\n */\nfunction resolveContent(events) {\n subtokenize(events);\n return events;\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeContent(effects, ok) {\n /** @type {Token | undefined} */\n let previous;\n return chunkStart;\n\n /**\n * Before a content chunk.\n *\n * ```markdown\n * > | abc\n * ^\n * ```\n *\n * @type {State}\n */\n function chunkStart(code) {\n effects.enter(\"content\");\n previous = effects.enter(\"chunkContent\", {\n contentType: \"content\"\n });\n return chunkInside(code);\n }\n\n /**\n * In a content chunk.\n *\n * ```markdown\n * > | abc\n * ^^^\n * ```\n *\n * @type {State}\n */\n function chunkInside(code) {\n if (code === null) {\n return contentEnd(code);\n }\n\n // To do: in `markdown-rs`, each line is parsed on its own, and everything\n // is stitched together resolving.\n if (markdownLineEnding(code)) {\n return effects.check(continuationConstruct, contentContinue, contentEnd)(code);\n }\n\n // Data.\n effects.consume(code);\n return chunkInside;\n }\n\n /**\n *\n *\n * @type {State}\n */\n function contentEnd(code) {\n effects.exit(\"chunkContent\");\n effects.exit(\"content\");\n return ok(code);\n }\n\n /**\n *\n *\n * @type {State}\n */\n function contentContinue(code) {\n effects.consume(code);\n effects.exit(\"chunkContent\");\n previous.next = effects.enter(\"chunkContent\", {\n contentType: \"content\",\n previous\n });\n previous = previous.next;\n return chunkInside;\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeContinuation(effects, ok, nok) {\n const self = this;\n return startLookahead;\n\n /**\n *\n *\n * @type {State}\n */\n function startLookahead(code) {\n effects.exit(\"chunkContent\");\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return factorySpace(effects, prefixed, \"linePrefix\");\n }\n\n /**\n *\n *\n * @type {State}\n */\n function prefixed(code) {\n if (code === null || markdownLineEnding(code)) {\n return nok(code);\n }\n\n // Always populated by defaults.\n\n const tail = self.events[self.events.length - 1];\n if (!self.parser.constructs.disable.null.includes('codeIndented') && tail && tail[1].type === \"linePrefix\" && tail[2].sliceSerialize(tail[1], true).length >= 4) {\n return ok(code);\n }\n return effects.interrupt(self.parser.constructs.flow, nok, ok)(code);\n }\n}","/**\n * @import {Effects, State, TokenType} from 'micromark-util-types'\n */\n\nimport { asciiControl, markdownLineEndingOrSpace, markdownLineEnding } from 'micromark-util-character';\n/**\n * Parse destinations.\n *\n * ###### Examples\n *\n * ```markdown\n * <a>\n * <a\\>b>\n * <a b>\n * <a)>\n * a\n * a\\)b\n * a(b)c\n * a(b)\n * ```\n *\n * @param {Effects} effects\n * Context.\n * @param {State} ok\n * State switched to when successful.\n * @param {State} nok\n * State switched to when unsuccessful.\n * @param {TokenType} type\n * Type for whole (`<a>` or `b`).\n * @param {TokenType} literalType\n * Type when enclosed (`<a>`).\n * @param {TokenType} literalMarkerType\n * Type for enclosing (`<` and `>`).\n * @param {TokenType} rawType\n * Type when not enclosed (`b`).\n * @param {TokenType} stringType\n * Type for the value (`a` or `b`).\n * @param {number | undefined} [max=Infinity]\n * Depth of nested parens (inclusive).\n * @returns {State}\n * Start state.\n */\nexport function factoryDestination(effects, ok, nok, type, literalType, literalMarkerType, rawType, stringType, max) {\n const limit = max || Number.POSITIVE_INFINITY;\n let balance = 0;\n return start;\n\n /**\n * Start of destination.\n *\n * ```markdown\n * > | <aa>\n * ^\n * > | aa\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n if (code === 60) {\n effects.enter(type);\n effects.enter(literalType);\n effects.enter(literalMarkerType);\n effects.consume(code);\n effects.exit(literalMarkerType);\n return enclosedBefore;\n }\n\n // ASCII control, space, closing paren.\n if (code === null || code === 32 || code === 41 || asciiControl(code)) {\n return nok(code);\n }\n effects.enter(type);\n effects.enter(rawType);\n effects.enter(stringType);\n effects.enter(\"chunkString\", {\n contentType: \"string\"\n });\n return raw(code);\n }\n\n /**\n * After `<`, at an enclosed destination.\n *\n * ```markdown\n * > | <aa>\n * ^\n * ```\n *\n * @type {State}\n */\n function enclosedBefore(code) {\n if (code === 62) {\n effects.enter(literalMarkerType);\n effects.consume(code);\n effects.exit(literalMarkerType);\n effects.exit(literalType);\n effects.exit(type);\n return ok;\n }\n effects.enter(stringType);\n effects.enter(\"chunkString\", {\n contentType: \"string\"\n });\n return enclosed(code);\n }\n\n /**\n * In enclosed destination.\n *\n * ```markdown\n * > | <aa>\n * ^\n * ```\n *\n * @type {State}\n */\n function enclosed(code) {\n if (code === 62) {\n effects.exit(\"chunkString\");\n effects.exit(stringType);\n return enclosedBefore(code);\n }\n if (code === null || code === 60 || markdownLineEnding(code)) {\n return nok(code);\n }\n effects.consume(code);\n return code === 92 ? enclosedEscape : enclosed;\n }\n\n /**\n * After `\\`, at a special character.\n *\n * ```markdown\n * > | <a\\*a>\n * ^\n * ```\n *\n * @type {State}\n */\n function enclosedEscape(code) {\n if (code === 60 || code === 62 || code === 92) {\n effects.consume(code);\n return enclosed;\n }\n return enclosed(code);\n }\n\n /**\n * In raw destination.\n *\n * ```markdown\n * > | aa\n * ^\n * ```\n *\n * @type {State}\n */\n function raw(code) {\n if (!balance && (code === null || code === 41 || markdownLineEndingOrSpace(code))) {\n effects.exit(\"chunkString\");\n effects.exit(stringType);\n effects.exit(rawType);\n effects.exit(type);\n return ok(code);\n }\n if (balance < limit && code === 40) {\n effects.consume(code);\n balance++;\n return raw;\n }\n if (code === 41) {\n effects.consume(code);\n balance--;\n return raw;\n }\n\n // ASCII control (but *not* `\\0`) and space and `(`.\n // Note: in `markdown-rs`, `\\0` exists in codes, in `micromark-js` it\n // doesn’t.\n if (code === null || code === 32 || code === 40 || asciiControl(code)) {\n return nok(code);\n }\n effects.consume(code);\n return code === 92 ? rawEscape : raw;\n }\n\n /**\n * After `\\`, at special character.\n *\n * ```markdown\n * > | a\\*a\n * ^\n * ```\n *\n * @type {State}\n */\n function rawEscape(code) {\n if (code === 40 || code === 41 || code === 92) {\n effects.consume(code);\n return raw;\n }\n return raw(code);\n }\n}","/**\n * @import {\n * Effects,\n * State,\n * TokenizeContext,\n * TokenType\n * } from 'micromark-util-types'\n */\n\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/**\n * Parse labels.\n *\n * > 👉 **Note**: labels in markdown are capped at 999 characters in the string.\n *\n * ###### Examples\n *\n * ```markdown\n * [a]\n * [a\n * b]\n * [a\\]b]\n * ```\n *\n * @this {TokenizeContext}\n * Tokenize context.\n * @param {Effects} effects\n * Context.\n * @param {State} ok\n * State switched to when successful.\n * @param {State} nok\n * State switched to when unsuccessful.\n * @param {TokenType} type\n * Type of the whole label (`[a]`).\n * @param {TokenType} markerType\n * Type for the markers (`[` and `]`).\n * @param {TokenType} stringType\n * Type for the identifier (`a`).\n * @returns {State}\n * Start state.\n */\nexport function factoryLabel(effects, ok, nok, type, markerType, stringType) {\n const self = this;\n let size = 0;\n /** @type {boolean} */\n let seen;\n return start;\n\n /**\n * Start of label.\n *\n * ```markdown\n * > | [a]\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(type);\n effects.enter(markerType);\n effects.consume(code);\n effects.exit(markerType);\n effects.enter(stringType);\n return atBreak;\n }\n\n /**\n * In label, at something, before something else.\n *\n * ```markdown\n * > | [a]\n * ^\n * ```\n *\n * @type {State}\n */\n function atBreak(code) {\n if (size > 999 || code === null || code === 91 || code === 93 && !seen ||\n // To do: remove in the future once we’ve switched from\n // `micromark-extension-footnote` to `micromark-extension-gfm-footnote`,\n // which doesn’t need this.\n // Hidden footnotes hook.\n /* c8 ignore next 3 */\n code === 94 && !size && '_hiddenFootnoteSupport' in self.parser.constructs) {\n return nok(code);\n }\n if (code === 93) {\n effects.exit(stringType);\n effects.enter(markerType);\n effects.consume(code);\n effects.exit(markerType);\n effects.exit(type);\n return ok;\n }\n\n // To do: indent? Link chunks and EOLs together?\n if (markdownLineEnding(code)) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return atBreak;\n }\n effects.enter(\"chunkString\", {\n contentType: \"string\"\n });\n return labelInside(code);\n }\n\n /**\n * In label, in text.\n *\n * ```markdown\n * > | [a]\n * ^\n * ```\n *\n * @type {State}\n */\n function labelInside(code) {\n if (code === null || code === 91 || code === 93 || markdownLineEnding(code) || size++ > 999) {\n effects.exit(\"chunkString\");\n return atBreak(code);\n }\n effects.consume(code);\n if (!seen) seen = !markdownSpace(code);\n return code === 92 ? labelEscape : labelInside;\n }\n\n /**\n * After `\\`, at a special character.\n *\n * ```markdown\n * > | [a\\*a]\n * ^\n * ```\n *\n * @type {State}\n */\n function labelEscape(code) {\n if (code === 91 || code === 92 || code === 93) {\n effects.consume(code);\n size++;\n return labelInside;\n }\n return labelInside(code);\n }\n}","/**\n * @import {\n * Code,\n * Effects,\n * State,\n * TokenType\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding } from 'micromark-util-character';\n/**\n * Parse titles.\n *\n * ###### Examples\n *\n * ```markdown\n * \"a\"\n * 'b'\n * (c)\n * \"a\n * b\"\n * 'a\n * b'\n * (a\\)b)\n * ```\n *\n * @param {Effects} effects\n * Context.\n * @param {State} ok\n * State switched to when successful.\n * @param {State} nok\n * State switched to when unsuccessful.\n * @param {TokenType} type\n * Type of the whole title (`\"a\"`, `'b'`, `(c)`).\n * @param {TokenType} markerType\n * Type for the markers (`\"`, `'`, `(`, and `)`).\n * @param {TokenType} stringType\n * Type for the value (`a`).\n * @returns {State}\n * Start state.\n */\nexport function factoryTitle(effects, ok, nok, type, markerType, stringType) {\n /** @type {NonNullable<Code>} */\n let marker;\n return start;\n\n /**\n * Start of title.\n *\n * ```markdown\n * > | \"a\"\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n if (code === 34 || code === 39 || code === 40) {\n effects.enter(type);\n effects.enter(markerType);\n effects.consume(code);\n effects.exit(markerType);\n marker = code === 40 ? 41 : code;\n return begin;\n }\n return nok(code);\n }\n\n /**\n * After opening marker.\n *\n * This is also used at the closing marker.\n *\n * ```markdown\n * > | \"a\"\n * ^\n * ```\n *\n * @type {State}\n */\n function begin(code) {\n if (code === marker) {\n effects.enter(markerType);\n effects.consume(code);\n effects.exit(markerType);\n effects.exit(type);\n return ok;\n }\n effects.enter(stringType);\n return atBreak(code);\n }\n\n /**\n * At something, before something else.\n *\n * ```markdown\n * > | \"a\"\n * ^\n * ```\n *\n * @type {State}\n */\n function atBreak(code) {\n if (code === marker) {\n effects.exit(stringType);\n return begin(marker);\n }\n if (code === null) {\n return nok(code);\n }\n\n // Note: blank lines can’t exist in content.\n if (markdownLineEnding(code)) {\n // To do: use `space_or_tab_eol_with_options`, connect.\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return factorySpace(effects, atBreak, \"linePrefix\");\n }\n effects.enter(\"chunkString\", {\n contentType: \"string\"\n });\n return inside(code);\n }\n\n /**\n *\n *\n * @type {State}\n */\n function inside(code) {\n if (code === marker || code === null || markdownLineEnding(code)) {\n effects.exit(\"chunkString\");\n return atBreak(code);\n }\n effects.consume(code);\n return code === 92 ? escape : inside;\n }\n\n /**\n * After `\\`, at a special character.\n *\n * ```markdown\n * > | \"a\\*b\"\n * ^\n * ```\n *\n * @type {State}\n */\n function escape(code) {\n if (code === marker || code === 92) {\n effects.consume(code);\n return inside;\n }\n return inside(code);\n }\n}","/**\n * @import {Effects, State} from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/**\n * Parse spaces and tabs.\n *\n * There is no `nok` parameter:\n *\n * * line endings or spaces in markdown are often optional, in which case this\n * factory can be used and `ok` will be switched to whether spaces were found\n * or not\n * * one line ending or space can be detected with\n * `markdownLineEndingOrSpace(code)` right before using `factoryWhitespace`\n *\n * @param {Effects} effects\n * Context.\n * @param {State} ok\n * State switched to when successful.\n * @returns {State}\n * Start state.\n */\nexport function factoryWhitespace(effects, ok) {\n /** @type {boolean} */\n let seen;\n return start;\n\n /** @type {State} */\n function start(code) {\n if (markdownLineEnding(code)) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n seen = true;\n return start;\n }\n if (markdownSpace(code)) {\n return factorySpace(effects, start, seen ? \"linePrefix\" : \"lineSuffix\")(code);\n }\n return ok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factoryDestination } from 'micromark-factory-destination';\nimport { factoryLabel } from 'micromark-factory-label';\nimport { factorySpace } from 'micromark-factory-space';\nimport { factoryTitle } from 'micromark-factory-title';\nimport { factoryWhitespace } from 'micromark-factory-whitespace';\nimport { markdownLineEndingOrSpace, markdownLineEnding, markdownSpace } from 'micromark-util-character';\nimport { normalizeIdentifier } from 'micromark-util-normalize-identifier';\n/** @type {Construct} */\nexport const definition = {\n name: 'definition',\n tokenize: tokenizeDefinition\n};\n\n/** @type {Construct} */\nconst titleBefore = {\n partial: true,\n tokenize: tokenizeTitleBefore\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeDefinition(effects, ok, nok) {\n const self = this;\n /** @type {string} */\n let identifier;\n return start;\n\n /**\n * At start of a definition.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // Do not interrupt paragraphs (but do follow definitions).\n // To do: do `interrupt` the way `markdown-rs` does.\n // To do: parse whitespace the way `markdown-rs` does.\n effects.enter(\"definition\");\n return before(code);\n }\n\n /**\n * After optional whitespace, at `[`.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function before(code) {\n // To do: parse whitespace the way `markdown-rs` does.\n\n return factoryLabel.call(self, effects, labelAfter,\n // Note: we don’t need to reset the way `markdown-rs` does.\n nok, \"definitionLabel\", \"definitionLabelMarker\", \"definitionLabelString\")(code);\n }\n\n /**\n * After label.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function labelAfter(code) {\n identifier = normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1));\n if (code === 58) {\n effects.enter(\"definitionMarker\");\n effects.consume(code);\n effects.exit(\"definitionMarker\");\n return markerAfter;\n }\n return nok(code);\n }\n\n /**\n * After marker.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function markerAfter(code) {\n // Note: whitespace is optional.\n return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, destinationBefore)(code) : destinationBefore(code);\n }\n\n /**\n * Before destination.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function destinationBefore(code) {\n return factoryDestination(effects, destinationAfter,\n // Note: we don’t need to reset the way `markdown-rs` does.\n nok, \"definitionDestination\", \"definitionDestinationLiteral\", \"definitionDestinationLiteralMarker\", \"definitionDestinationRaw\", \"definitionDestinationString\")(code);\n }\n\n /**\n * After destination.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function destinationAfter(code) {\n return effects.attempt(titleBefore, after, after)(code);\n }\n\n /**\n * After definition.\n *\n * ```markdown\n * > | [a]: b\n * ^\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n return markdownSpace(code) ? factorySpace(effects, afterWhitespace, \"whitespace\")(code) : afterWhitespace(code);\n }\n\n /**\n * After definition, after optional whitespace.\n *\n * ```markdown\n * > | [a]: b\n * ^\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function afterWhitespace(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"definition\");\n\n // Note: we don’t care about uniqueness.\n // It’s likely that that doesn’t happen very frequently.\n // It is more likely that it wastes precious time.\n self.parser.defined.push(identifier);\n\n // To do: `markdown-rs` interrupt.\n // // You’d be interrupting.\n // tokenizer.interrupt = true\n return ok(code);\n }\n return nok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeTitleBefore(effects, ok, nok) {\n return titleBefore;\n\n /**\n * After destination, at whitespace.\n *\n * ```markdown\n * > | [a]: b\n * ^\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function titleBefore(code) {\n return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, beforeMarker)(code) : nok(code);\n }\n\n /**\n * At title.\n *\n * ```markdown\n * | [a]: b\n * > | \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function beforeMarker(code) {\n return factoryTitle(effects, titleAfter, nok, \"definitionTitle\", \"definitionTitleMarker\", \"definitionTitleString\")(code);\n }\n\n /**\n * After title.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function titleAfter(code) {\n return markdownSpace(code) ? factorySpace(effects, titleAfterOptionalWhitespace, \"whitespace\")(code) : titleAfterOptionalWhitespace(code);\n }\n\n /**\n * After title, after optional whitespace.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function titleAfterOptionalWhitespace(code) {\n return code === null || markdownLineEnding(code) ? ok(code) : nok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { markdownLineEnding } from 'micromark-util-character';\n/** @type {Construct} */\nexport const hardBreakEscape = {\n name: 'hardBreakEscape',\n tokenize: tokenizeHardBreakEscape\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeHardBreakEscape(effects, ok, nok) {\n return start;\n\n /**\n * Start of a hard break (escape).\n *\n * ```markdown\n * > | a\\\n * ^\n * | b\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"hardBreakEscape\");\n effects.consume(code);\n return after;\n }\n\n /**\n * After `\\`, at eol.\n *\n * ```markdown\n * > | a\\\n * ^\n * | b\n * ```\n *\n * @type {State}\n */\n function after(code) {\n if (markdownLineEnding(code)) {\n effects.exit(\"hardBreakEscape\");\n return ok(code);\n }\n return nok(code);\n }\n}","/**\n * @import {\n * Construct,\n * Resolver,\n * State,\n * TokenizeContext,\n * Tokenizer,\n * Token\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEndingOrSpace, markdownLineEnding, markdownSpace } from 'micromark-util-character';\nimport { splice } from 'micromark-util-chunked';\n/** @type {Construct} */\nexport const headingAtx = {\n name: 'headingAtx',\n resolve: resolveHeadingAtx,\n tokenize: tokenizeHeadingAtx\n};\n\n/** @type {Resolver} */\nfunction resolveHeadingAtx(events, context) {\n let contentEnd = events.length - 2;\n let contentStart = 3;\n /** @type {Token} */\n let content;\n /** @type {Token} */\n let text;\n\n // Prefix whitespace, part of the opening.\n if (events[contentStart][1].type === \"whitespace\") {\n contentStart += 2;\n }\n\n // Suffix whitespace, part of the closing.\n if (contentEnd - 2 > contentStart && events[contentEnd][1].type === \"whitespace\") {\n contentEnd -= 2;\n }\n if (events[contentEnd][1].type === \"atxHeadingSequence\" && (contentStart === contentEnd - 1 || contentEnd - 4 > contentStart && events[contentEnd - 2][1].type === \"whitespace\")) {\n contentEnd -= contentStart + 1 === contentEnd ? 2 : 4;\n }\n if (contentEnd > contentStart) {\n content = {\n type: \"atxHeadingText\",\n start: events[contentStart][1].start,\n end: events[contentEnd][1].end\n };\n text = {\n type: \"chunkText\",\n start: events[contentStart][1].start,\n end: events[contentEnd][1].end,\n contentType: \"text\"\n };\n splice(events, contentStart, contentEnd - contentStart + 1, [['enter', content, context], ['enter', text, context], ['exit', text, context], ['exit', content, context]]);\n }\n return events;\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeHeadingAtx(effects, ok, nok) {\n let size = 0;\n return start;\n\n /**\n * Start of a heading (atx).\n *\n * ```markdown\n * > | ## aa\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // To do: parse indent like `markdown-rs`.\n effects.enter(\"atxHeading\");\n return before(code);\n }\n\n /**\n * After optional whitespace, at `#`.\n *\n * ```markdown\n * > | ## aa\n * ^\n * ```\n *\n * @type {State}\n */\n function before(code) {\n effects.enter(\"atxHeadingSequence\");\n return sequenceOpen(code);\n }\n\n /**\n * In opening sequence.\n *\n * ```markdown\n * > | ## aa\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceOpen(code) {\n if (code === 35 && size++ < 6) {\n effects.consume(code);\n return sequenceOpen;\n }\n\n // Always at least one `#`.\n if (code === null || markdownLineEndingOrSpace(code)) {\n effects.exit(\"atxHeadingSequence\");\n return atBreak(code);\n }\n return nok(code);\n }\n\n /**\n * After something, before something else.\n *\n * ```markdown\n * > | ## aa\n * ^\n * ```\n *\n * @type {State}\n */\n function atBreak(code) {\n if (code === 35) {\n effects.enter(\"atxHeadingSequence\");\n return sequenceFurther(code);\n }\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"atxHeading\");\n // To do: interrupt like `markdown-rs`.\n // // Feel free to interrupt.\n // tokenizer.interrupt = false\n return ok(code);\n }\n if (markdownSpace(code)) {\n return factorySpace(effects, atBreak, \"whitespace\")(code);\n }\n\n // To do: generate `data` tokens, add the `text` token later.\n // Needs edit map, see: `markdown.rs`.\n effects.enter(\"atxHeadingText\");\n return data(code);\n }\n\n /**\n * In further sequence (after whitespace).\n *\n * Could be normal “visible” hashes in the heading or a final sequence.\n *\n * ```markdown\n * > | ## aa ##\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceFurther(code) {\n if (code === 35) {\n effects.consume(code);\n return sequenceFurther;\n }\n effects.exit(\"atxHeadingSequence\");\n return atBreak(code);\n }\n\n /**\n * In text.\n *\n * ```markdown\n * > | ## aa\n * ^\n * ```\n *\n * @type {State}\n */\n function data(code) {\n if (code === null || code === 35 || markdownLineEndingOrSpace(code)) {\n effects.exit(\"atxHeadingText\");\n return atBreak(code);\n }\n effects.consume(code);\n return data;\n }\n}","/**\n * List of lowercase HTML “block” tag names.\n *\n * The list, when parsing HTML (flow), results in more relaxed rules (condition\n * 6).\n * Because they are known blocks, the HTML-like syntax doesn’t have to be\n * strictly parsed.\n * For tag names not in this list, a more strict algorithm (condition 7) is used\n * to detect whether the HTML-like syntax is seen as HTML (flow) or not.\n *\n * This is copied from:\n * <https://spec.commonmark.org/0.30/#html-blocks>.\n *\n * > 👉 **Note**: `search` was added in `CommonMark@0.31`.\n */\nexport const htmlBlockNames = [\n 'address',\n 'article',\n 'aside',\n 'base',\n 'basefont',\n 'blockquote',\n 'body',\n 'caption',\n 'center',\n 'col',\n 'colgroup',\n 'dd',\n 'details',\n 'dialog',\n 'dir',\n 'div',\n 'dl',\n 'dt',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'frame',\n 'frameset',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'head',\n 'header',\n 'hr',\n 'html',\n 'iframe',\n 'legend',\n 'li',\n 'link',\n 'main',\n 'menu',\n 'menuitem',\n 'nav',\n 'noframes',\n 'ol',\n 'optgroup',\n 'option',\n 'p',\n 'param',\n 'search',\n 'section',\n 'summary',\n 'table',\n 'tbody',\n 'td',\n 'tfoot',\n 'th',\n 'thead',\n 'title',\n 'tr',\n 'track',\n 'ul'\n]\n\n/**\n * List of lowercase HTML “raw” tag names.\n *\n * The list, when parsing HTML (flow), results in HTML that can include lines\n * without exiting, until a closing tag also in this list is found (condition\n * 1).\n *\n * This module is copied from:\n * <https://spec.commonmark.org/0.30/#html-blocks>.\n *\n * > 👉 **Note**: `textarea` was added in `CommonMark@0.30`.\n */\nexport const htmlRawNames = ['pre', 'script', 'style', 'textarea']\n","/**\n * @import {\n * Code,\n * Construct,\n * Resolver,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { asciiAlphanumeric, asciiAlpha, markdownLineEndingOrSpace, markdownLineEnding, markdownSpace } from 'micromark-util-character';\nimport { htmlBlockNames, htmlRawNames } from 'micromark-util-html-tag-name';\nimport { blankLine } from './blank-line.js';\n\n/** @type {Construct} */\nexport const htmlFlow = {\n concrete: true,\n name: 'htmlFlow',\n resolveTo: resolveToHtmlFlow,\n tokenize: tokenizeHtmlFlow\n};\n\n/** @type {Construct} */\nconst blankLineBefore = {\n partial: true,\n tokenize: tokenizeBlankLineBefore\n};\nconst nonLazyContinuationStart = {\n partial: true,\n tokenize: tokenizeNonLazyContinuationStart\n};\n\n/** @type {Resolver} */\nfunction resolveToHtmlFlow(events) {\n let index = events.length;\n while (index--) {\n if (events[index][0] === 'enter' && events[index][1].type === \"htmlFlow\") {\n break;\n }\n }\n if (index > 1 && events[index - 2][1].type === \"linePrefix\") {\n // Add the prefix start to the HTML token.\n events[index][1].start = events[index - 2][1].start;\n // Add the prefix start to the HTML line token.\n events[index + 1][1].start = events[index - 2][1].start;\n // Remove the line prefix.\n events.splice(index - 2, 2);\n }\n return events;\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeHtmlFlow(effects, ok, nok) {\n const self = this;\n /** @type {number} */\n let marker;\n /** @type {boolean} */\n let closingTag;\n /** @type {string} */\n let buffer;\n /** @type {number} */\n let index;\n /** @type {Code} */\n let markerB;\n return start;\n\n /**\n * Start of HTML (flow).\n *\n * ```markdown\n * > | <x />\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // To do: parse indent like `markdown-rs`.\n return before(code);\n }\n\n /**\n * At `<`, after optional whitespace.\n *\n * ```markdown\n * > | <x />\n * ^\n * ```\n *\n * @type {State}\n */\n function before(code) {\n effects.enter(\"htmlFlow\");\n effects.enter(\"htmlFlowData\");\n effects.consume(code);\n return open;\n }\n\n /**\n * After `<`, at tag name or other stuff.\n *\n * ```markdown\n * > | <x />\n * ^\n * > | <!doctype>\n * ^\n * > | <!--xxx-->\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (code === 33) {\n effects.consume(code);\n return declarationOpen;\n }\n if (code === 47) {\n effects.consume(code);\n closingTag = true;\n return tagCloseStart;\n }\n if (code === 63) {\n effects.consume(code);\n marker = 3;\n // To do:\n // tokenizer.concrete = true\n // To do: use `markdown-rs` style interrupt.\n // While we’re in an instruction instead of a declaration, we’re on a `?`\n // right now, so we do need to search for `>`, similar to declarations.\n return self.interrupt ? ok : continuationDeclarationInside;\n }\n\n // ASCII alphabetical.\n if (asciiAlpha(code)) {\n // Always the case.\n effects.consume(code);\n buffer = String.fromCharCode(code);\n return tagName;\n }\n return nok(code);\n }\n\n /**\n * After `<!`, at declaration, comment, or CDATA.\n *\n * ```markdown\n * > | <!doctype>\n * ^\n * > | <!--xxx-->\n * ^\n * > | <![CDATA[>&<]]>\n * ^\n * ```\n *\n * @type {State}\n */\n function declarationOpen(code) {\n if (code === 45) {\n effects.consume(code);\n marker = 2;\n return commentOpenInside;\n }\n if (code === 91) {\n effects.consume(code);\n marker = 5;\n index = 0;\n return cdataOpenInside;\n }\n\n // ASCII alphabetical.\n if (asciiAlpha(code)) {\n effects.consume(code);\n marker = 4;\n // // Do not form containers.\n // tokenizer.concrete = true\n return self.interrupt ? ok : continuationDeclarationInside;\n }\n return nok(code);\n }\n\n /**\n * After `<!-`, inside a comment, at another `-`.\n *\n * ```markdown\n * > | <!--xxx-->\n * ^\n * ```\n *\n * @type {State}\n */\n function commentOpenInside(code) {\n if (code === 45) {\n effects.consume(code);\n // // Do not form containers.\n // tokenizer.concrete = true\n return self.interrupt ? ok : continuationDeclarationInside;\n }\n return nok(code);\n }\n\n /**\n * After `<![`, inside CDATA, expecting `CDATA[`.\n *\n * ```markdown\n * > | <![CDATA[>&<]]>\n * ^^^^^^\n * ```\n *\n * @type {State}\n */\n function cdataOpenInside(code) {\n const value = \"CDATA[\";\n if (code === value.charCodeAt(index++)) {\n effects.consume(code);\n if (index === value.length) {\n // // Do not form containers.\n // tokenizer.concrete = true\n return self.interrupt ? ok : continuation;\n }\n return cdataOpenInside;\n }\n return nok(code);\n }\n\n /**\n * After `</`, in closing tag, at tag name.\n *\n * ```markdown\n * > | </x>\n * ^\n * ```\n *\n * @type {State}\n */\n function tagCloseStart(code) {\n if (asciiAlpha(code)) {\n // Always the case.\n effects.consume(code);\n buffer = String.fromCharCode(code);\n return tagName;\n }\n return nok(code);\n }\n\n /**\n * In tag name.\n *\n * ```markdown\n * > | <ab>\n * ^^\n * > | </ab>\n * ^^\n * ```\n *\n * @type {State}\n */\n function tagName(code) {\n if (code === null || code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {\n const slash = code === 47;\n const name = buffer.toLowerCase();\n if (!slash && !closingTag && htmlRawNames.includes(name)) {\n marker = 1;\n // // Do not form containers.\n // tokenizer.concrete = true\n return self.interrupt ? ok(code) : continuation(code);\n }\n if (htmlBlockNames.includes(buffer.toLowerCase())) {\n marker = 6;\n if (slash) {\n effects.consume(code);\n return basicSelfClosing;\n }\n\n // // Do not form containers.\n // tokenizer.concrete = true\n return self.interrupt ? ok(code) : continuation(code);\n }\n marker = 7;\n // Do not support complete HTML when interrupting.\n return self.interrupt && !self.parser.lazy[self.now().line] ? nok(code) : closingTag ? completeClosingTagAfter(code) : completeAttributeNameBefore(code);\n }\n\n // ASCII alphanumerical and `-`.\n if (code === 45 || asciiAlphanumeric(code)) {\n effects.consume(code);\n buffer += String.fromCharCode(code);\n return tagName;\n }\n return nok(code);\n }\n\n /**\n * After closing slash of a basic tag name.\n *\n * ```markdown\n * > | <div/>\n * ^\n * ```\n *\n * @type {State}\n */\n function basicSelfClosing(code) {\n if (code === 62) {\n effects.consume(code);\n // // Do not form containers.\n // tokenizer.concrete = true\n return self.interrupt ? ok : continuation;\n }\n return nok(code);\n }\n\n /**\n * After closing slash of a complete tag name.\n *\n * ```markdown\n * > | <x/>\n * ^\n * ```\n *\n * @type {State}\n */\n function completeClosingTagAfter(code) {\n if (markdownSpace(code)) {\n effects.consume(code);\n return completeClosingTagAfter;\n }\n return completeEnd(code);\n }\n\n /**\n * At an attribute name.\n *\n * At first, this state is used after a complete tag name, after whitespace,\n * where it expects optional attributes or the end of the tag.\n * It is also reused after attributes, when expecting more optional\n * attributes.\n *\n * ```markdown\n * > | <a />\n * ^\n * > | <a :b>\n * ^\n * > | <a _b>\n * ^\n * > | <a b>\n * ^\n * > | <a >\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAttributeNameBefore(code) {\n if (code === 47) {\n effects.consume(code);\n return completeEnd;\n }\n\n // ASCII alphanumerical and `:` and `_`.\n if (code === 58 || code === 95 || asciiAlpha(code)) {\n effects.consume(code);\n return completeAttributeName;\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return completeAttributeNameBefore;\n }\n return completeEnd(code);\n }\n\n /**\n * In attribute name.\n *\n * ```markdown\n * > | <a :b>\n * ^\n * > | <a _b>\n * ^\n * > | <a b>\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAttributeName(code) {\n // ASCII alphanumerical and `-`, `.`, `:`, and `_`.\n if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {\n effects.consume(code);\n return completeAttributeName;\n }\n return completeAttributeNameAfter(code);\n }\n\n /**\n * After attribute name, at an optional initializer, the end of the tag, or\n * whitespace.\n *\n * ```markdown\n * > | <a b>\n * ^\n * > | <a b=c>\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAttributeNameAfter(code) {\n if (code === 61) {\n effects.consume(code);\n return completeAttributeValueBefore;\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return completeAttributeNameAfter;\n }\n return completeAttributeNameBefore(code);\n }\n\n /**\n * Before unquoted, double quoted, or single quoted attribute value, allowing\n * whitespace.\n *\n * ```markdown\n * > | <a b=c>\n * ^\n * > | <a b=\"c\">\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAttributeValueBefore(code) {\n if (code === null || code === 60 || code === 61 || code === 62 || code === 96) {\n return nok(code);\n }\n if (code === 34 || code === 39) {\n effects.consume(code);\n markerB = code;\n return completeAttributeValueQuoted;\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return completeAttributeValueBefore;\n }\n return completeAttributeValueUnquoted(code);\n }\n\n /**\n * In double or single quoted attribute value.\n *\n * ```markdown\n * > | <a b=\"c\">\n * ^\n * > | <a b='c'>\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAttributeValueQuoted(code) {\n if (code === markerB) {\n effects.consume(code);\n markerB = null;\n return completeAttributeValueQuotedAfter;\n }\n if (code === null || markdownLineEnding(code)) {\n return nok(code);\n }\n effects.consume(code);\n return completeAttributeValueQuoted;\n }\n\n /**\n * In unquoted attribute value.\n *\n * ```markdown\n * > | <a b=c>\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAttributeValueUnquoted(code) {\n if (code === null || code === 34 || code === 39 || code === 47 || code === 60 || code === 61 || code === 62 || code === 96 || markdownLineEndingOrSpace(code)) {\n return completeAttributeNameAfter(code);\n }\n effects.consume(code);\n return completeAttributeValueUnquoted;\n }\n\n /**\n * After double or single quoted attribute value, before whitespace or the\n * end of the tag.\n *\n * ```markdown\n * > | <a b=\"c\">\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAttributeValueQuotedAfter(code) {\n if (code === 47 || code === 62 || markdownSpace(code)) {\n return completeAttributeNameBefore(code);\n }\n return nok(code);\n }\n\n /**\n * In certain circumstances of a complete tag where only an `>` is allowed.\n *\n * ```markdown\n * > | <a b=\"c\">\n * ^\n * ```\n *\n * @type {State}\n */\n function completeEnd(code) {\n if (code === 62) {\n effects.consume(code);\n return completeAfter;\n }\n return nok(code);\n }\n\n /**\n * After `>` in a complete tag.\n *\n * ```markdown\n * > | <x>\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAfter(code) {\n if (code === null || markdownLineEnding(code)) {\n // // Do not form containers.\n // tokenizer.concrete = true\n return continuation(code);\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return completeAfter;\n }\n return nok(code);\n }\n\n /**\n * In continuation of any HTML kind.\n *\n * ```markdown\n * > | <!--xxx-->\n * ^\n * ```\n *\n * @type {State}\n */\n function continuation(code) {\n if (code === 45 && marker === 2) {\n effects.consume(code);\n return continuationCommentInside;\n }\n if (code === 60 && marker === 1) {\n effects.consume(code);\n return continuationRawTagOpen;\n }\n if (code === 62 && marker === 4) {\n effects.consume(code);\n return continuationClose;\n }\n if (code === 63 && marker === 3) {\n effects.consume(code);\n return continuationDeclarationInside;\n }\n if (code === 93 && marker === 5) {\n effects.consume(code);\n return continuationCdataInside;\n }\n if (markdownLineEnding(code) && (marker === 6 || marker === 7)) {\n effects.exit(\"htmlFlowData\");\n return effects.check(blankLineBefore, continuationAfter, continuationStart)(code);\n }\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"htmlFlowData\");\n return continuationStart(code);\n }\n effects.consume(code);\n return continuation;\n }\n\n /**\n * In continuation, at eol.\n *\n * ```markdown\n * > | <x>\n * ^\n * | asd\n * ```\n *\n * @type {State}\n */\n function continuationStart(code) {\n return effects.check(nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code);\n }\n\n /**\n * In continuation, at eol, before non-lazy content.\n *\n * ```markdown\n * > | <x>\n * ^\n * | asd\n * ```\n *\n * @type {State}\n */\n function continuationStartNonLazy(code) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return continuationBefore;\n }\n\n /**\n * In continuation, before non-lazy content.\n *\n * ```markdown\n * | <x>\n * > | asd\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationBefore(code) {\n if (code === null || markdownLineEnding(code)) {\n return continuationStart(code);\n }\n effects.enter(\"htmlFlowData\");\n return continuation(code);\n }\n\n /**\n * In comment continuation, after one `-`, expecting another.\n *\n * ```markdown\n * > | <!--xxx-->\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationCommentInside(code) {\n if (code === 45) {\n effects.consume(code);\n return continuationDeclarationInside;\n }\n return continuation(code);\n }\n\n /**\n * In raw continuation, after `<`, at `/`.\n *\n * ```markdown\n * > | <script>console.log(1)</script>\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationRawTagOpen(code) {\n if (code === 47) {\n effects.consume(code);\n buffer = '';\n return continuationRawEndTag;\n }\n return continuation(code);\n }\n\n /**\n * In raw continuation, after `</`, in a raw tag name.\n *\n * ```markdown\n * > | <script>console.log(1)</script>\n * ^^^^^^\n * ```\n *\n * @type {State}\n */\n function continuationRawEndTag(code) {\n if (code === 62) {\n const name = buffer.toLowerCase();\n if (htmlRawNames.includes(name)) {\n effects.consume(code);\n return continuationClose;\n }\n return continuation(code);\n }\n if (asciiAlpha(code) && buffer.length < 8) {\n // Always the case.\n effects.consume(code);\n buffer += String.fromCharCode(code);\n return continuationRawEndTag;\n }\n return continuation(code);\n }\n\n /**\n * In cdata continuation, after `]`, expecting `]>`.\n *\n * ```markdown\n * > | <![CDATA[>&<]]>\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationCdataInside(code) {\n if (code === 93) {\n effects.consume(code);\n return continuationDeclarationInside;\n }\n return continuation(code);\n }\n\n /**\n * In declaration or instruction continuation, at `>`.\n *\n * ```markdown\n * > | <!-->\n * ^\n * > | <?>\n * ^\n * > | <!q>\n * ^\n * > | <!--ab-->\n * ^\n * > | <![CDATA[>&<]]>\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationDeclarationInside(code) {\n if (code === 62) {\n effects.consume(code);\n return continuationClose;\n }\n\n // More dashes.\n if (code === 45 && marker === 2) {\n effects.consume(code);\n return continuationDeclarationInside;\n }\n return continuation(code);\n }\n\n /**\n * In closed continuation: everything we get until the eol/eof is part of it.\n *\n * ```markdown\n * > | <!doctype>\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationClose(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"htmlFlowData\");\n return continuationAfter(code);\n }\n effects.consume(code);\n return continuationClose;\n }\n\n /**\n * Done.\n *\n * ```markdown\n * > | <!doctype>\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationAfter(code) {\n effects.exit(\"htmlFlow\");\n // // Feel free to interrupt.\n // tokenizer.interrupt = false\n // // No longer concrete.\n // tokenizer.concrete = false\n return ok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeNonLazyContinuationStart(effects, ok, nok) {\n const self = this;\n return start;\n\n /**\n * At eol, before continuation.\n *\n * ```markdown\n * > | * ```js\n * ^\n * | b\n * ```\n *\n * @type {State}\n */\n function start(code) {\n if (markdownLineEnding(code)) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return after;\n }\n return nok(code);\n }\n\n /**\n * A continuation.\n *\n * ```markdown\n * | * ```js\n * > | b\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n return self.parser.lazy[self.now().line] ? nok(code) : ok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeBlankLineBefore(effects, ok, nok) {\n return start;\n\n /**\n * Before eol, expecting blank line.\n *\n * ```markdown\n * > | <div>\n * ^\n * |\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return effects.attempt(blankLine, ok, nok);\n }\n}","/**\n * @import {\n * Code,\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { asciiAlphanumeric, asciiAlpha, markdownLineEndingOrSpace, markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nexport const htmlText = {\n name: 'htmlText',\n tokenize: tokenizeHtmlText\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeHtmlText(effects, ok, nok) {\n const self = this;\n /** @type {NonNullable<Code> | undefined} */\n let marker;\n /** @type {number} */\n let index;\n /** @type {State} */\n let returnState;\n return start;\n\n /**\n * Start of HTML (text).\n *\n * ```markdown\n * > | a <b> c\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"htmlText\");\n effects.enter(\"htmlTextData\");\n effects.consume(code);\n return open;\n }\n\n /**\n * After `<`, at tag name or other stuff.\n *\n * ```markdown\n * > | a <b> c\n * ^\n * > | a <!doctype> c\n * ^\n * > | a <!--b--> c\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (code === 33) {\n effects.consume(code);\n return declarationOpen;\n }\n if (code === 47) {\n effects.consume(code);\n return tagCloseStart;\n }\n if (code === 63) {\n effects.consume(code);\n return instruction;\n }\n\n // ASCII alphabetical.\n if (asciiAlpha(code)) {\n effects.consume(code);\n return tagOpen;\n }\n return nok(code);\n }\n\n /**\n * After `<!`, at declaration, comment, or CDATA.\n *\n * ```markdown\n * > | a <!doctype> c\n * ^\n * > | a <!--b--> c\n * ^\n * > | a <![CDATA[>&<]]> c\n * ^\n * ```\n *\n * @type {State}\n */\n function declarationOpen(code) {\n if (code === 45) {\n effects.consume(code);\n return commentOpenInside;\n }\n if (code === 91) {\n effects.consume(code);\n index = 0;\n return cdataOpenInside;\n }\n if (asciiAlpha(code)) {\n effects.consume(code);\n return declaration;\n }\n return nok(code);\n }\n\n /**\n * In a comment, after `<!-`, at another `-`.\n *\n * ```markdown\n * > | a <!--b--> c\n * ^\n * ```\n *\n * @type {State}\n */\n function commentOpenInside(code) {\n if (code === 45) {\n effects.consume(code);\n return commentEnd;\n }\n return nok(code);\n }\n\n /**\n * In comment.\n *\n * ```markdown\n * > | a <!--b--> c\n * ^\n * ```\n *\n * @type {State}\n */\n function comment(code) {\n if (code === null) {\n return nok(code);\n }\n if (code === 45) {\n effects.consume(code);\n return commentClose;\n }\n if (markdownLineEnding(code)) {\n returnState = comment;\n return lineEndingBefore(code);\n }\n effects.consume(code);\n return comment;\n }\n\n /**\n * In comment, after `-`.\n *\n * ```markdown\n * > | a <!--b--> c\n * ^\n * ```\n *\n * @type {State}\n */\n function commentClose(code) {\n if (code === 45) {\n effects.consume(code);\n return commentEnd;\n }\n return comment(code);\n }\n\n /**\n * In comment, after `--`.\n *\n * ```markdown\n * > | a <!--b--> c\n * ^\n * ```\n *\n * @type {State}\n */\n function commentEnd(code) {\n return code === 62 ? end(code) : code === 45 ? commentClose(code) : comment(code);\n }\n\n /**\n * After `<![`, in CDATA, expecting `CDATA[`.\n *\n * ```markdown\n * > | a <![CDATA[>&<]]> b\n * ^^^^^^\n * ```\n *\n * @type {State}\n */\n function cdataOpenInside(code) {\n const value = \"CDATA[\";\n if (code === value.charCodeAt(index++)) {\n effects.consume(code);\n return index === value.length ? cdata : cdataOpenInside;\n }\n return nok(code);\n }\n\n /**\n * In CDATA.\n *\n * ```markdown\n * > | a <![CDATA[>&<]]> b\n * ^^^\n * ```\n *\n * @type {State}\n */\n function cdata(code) {\n if (code === null) {\n return nok(code);\n }\n if (code === 93) {\n effects.consume(code);\n return cdataClose;\n }\n if (markdownLineEnding(code)) {\n returnState = cdata;\n return lineEndingBefore(code);\n }\n effects.consume(code);\n return cdata;\n }\n\n /**\n * In CDATA, after `]`, at another `]`.\n *\n * ```markdown\n * > | a <![CDATA[>&<]]> b\n * ^\n * ```\n *\n * @type {State}\n */\n function cdataClose(code) {\n if (code === 93) {\n effects.consume(code);\n return cdataEnd;\n }\n return cdata(code);\n }\n\n /**\n * In CDATA, after `]]`, at `>`.\n *\n * ```markdown\n * > | a <![CDATA[>&<]]> b\n * ^\n * ```\n *\n * @type {State}\n */\n function cdataEnd(code) {\n if (code === 62) {\n return end(code);\n }\n if (code === 93) {\n effects.consume(code);\n return cdataEnd;\n }\n return cdata(code);\n }\n\n /**\n * In declaration.\n *\n * ```markdown\n * > | a <!b> c\n * ^\n * ```\n *\n * @type {State}\n */\n function declaration(code) {\n if (code === null || code === 62) {\n return end(code);\n }\n if (markdownLineEnding(code)) {\n returnState = declaration;\n return lineEndingBefore(code);\n }\n effects.consume(code);\n return declaration;\n }\n\n /**\n * In instruction.\n *\n * ```markdown\n * > | a <?b?> c\n * ^\n * ```\n *\n * @type {State}\n */\n function instruction(code) {\n if (code === null) {\n return nok(code);\n }\n if (code === 63) {\n effects.consume(code);\n return instructionClose;\n }\n if (markdownLineEnding(code)) {\n returnState = instruction;\n return lineEndingBefore(code);\n }\n effects.consume(code);\n return instruction;\n }\n\n /**\n * In instruction, after `?`, at `>`.\n *\n * ```markdown\n * > | a <?b?> c\n * ^\n * ```\n *\n * @type {State}\n */\n function instructionClose(code) {\n return code === 62 ? end(code) : instruction(code);\n }\n\n /**\n * After `</`, in closing tag, at tag name.\n *\n * ```markdown\n * > | a </b> c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagCloseStart(code) {\n // ASCII alphabetical.\n if (asciiAlpha(code)) {\n effects.consume(code);\n return tagClose;\n }\n return nok(code);\n }\n\n /**\n * After `</x`, in a tag name.\n *\n * ```markdown\n * > | a </b> c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagClose(code) {\n // ASCII alphanumerical and `-`.\n if (code === 45 || asciiAlphanumeric(code)) {\n effects.consume(code);\n return tagClose;\n }\n return tagCloseBetween(code);\n }\n\n /**\n * In closing tag, after tag name.\n *\n * ```markdown\n * > | a </b> c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagCloseBetween(code) {\n if (markdownLineEnding(code)) {\n returnState = tagCloseBetween;\n return lineEndingBefore(code);\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return tagCloseBetween;\n }\n return end(code);\n }\n\n /**\n * After `<x`, in opening tag name.\n *\n * ```markdown\n * > | a <b> c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpen(code) {\n // ASCII alphanumerical and `-`.\n if (code === 45 || asciiAlphanumeric(code)) {\n effects.consume(code);\n return tagOpen;\n }\n if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {\n return tagOpenBetween(code);\n }\n return nok(code);\n }\n\n /**\n * In opening tag, after tag name.\n *\n * ```markdown\n * > | a <b> c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenBetween(code) {\n if (code === 47) {\n effects.consume(code);\n return end;\n }\n\n // ASCII alphabetical and `:` and `_`.\n if (code === 58 || code === 95 || asciiAlpha(code)) {\n effects.consume(code);\n return tagOpenAttributeName;\n }\n if (markdownLineEnding(code)) {\n returnState = tagOpenBetween;\n return lineEndingBefore(code);\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return tagOpenBetween;\n }\n return end(code);\n }\n\n /**\n * In attribute name.\n *\n * ```markdown\n * > | a <b c> d\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeName(code) {\n // ASCII alphabetical and `-`, `.`, `:`, and `_`.\n if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {\n effects.consume(code);\n return tagOpenAttributeName;\n }\n return tagOpenAttributeNameAfter(code);\n }\n\n /**\n * After attribute name, before initializer, the end of the tag, or\n * whitespace.\n *\n * ```markdown\n * > | a <b c> d\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeNameAfter(code) {\n if (code === 61) {\n effects.consume(code);\n return tagOpenAttributeValueBefore;\n }\n if (markdownLineEnding(code)) {\n returnState = tagOpenAttributeNameAfter;\n return lineEndingBefore(code);\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return tagOpenAttributeNameAfter;\n }\n return tagOpenBetween(code);\n }\n\n /**\n * Before unquoted, double quoted, or single quoted attribute value, allowing\n * whitespace.\n *\n * ```markdown\n * > | a <b c=d> e\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeValueBefore(code) {\n if (code === null || code === 60 || code === 61 || code === 62 || code === 96) {\n return nok(code);\n }\n if (code === 34 || code === 39) {\n effects.consume(code);\n marker = code;\n return tagOpenAttributeValueQuoted;\n }\n if (markdownLineEnding(code)) {\n returnState = tagOpenAttributeValueBefore;\n return lineEndingBefore(code);\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return tagOpenAttributeValueBefore;\n }\n effects.consume(code);\n return tagOpenAttributeValueUnquoted;\n }\n\n /**\n * In double or single quoted attribute value.\n *\n * ```markdown\n * > | a <b c=\"d\"> e\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeValueQuoted(code) {\n if (code === marker) {\n effects.consume(code);\n marker = undefined;\n return tagOpenAttributeValueQuotedAfter;\n }\n if (code === null) {\n return nok(code);\n }\n if (markdownLineEnding(code)) {\n returnState = tagOpenAttributeValueQuoted;\n return lineEndingBefore(code);\n }\n effects.consume(code);\n return tagOpenAttributeValueQuoted;\n }\n\n /**\n * In unquoted attribute value.\n *\n * ```markdown\n * > | a <b c=d> e\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeValueUnquoted(code) {\n if (code === null || code === 34 || code === 39 || code === 60 || code === 61 || code === 96) {\n return nok(code);\n }\n if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {\n return tagOpenBetween(code);\n }\n effects.consume(code);\n return tagOpenAttributeValueUnquoted;\n }\n\n /**\n * After double or single quoted attribute value, before whitespace or the end\n * of the tag.\n *\n * ```markdown\n * > | a <b c=\"d\"> e\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeValueQuotedAfter(code) {\n if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {\n return tagOpenBetween(code);\n }\n return nok(code);\n }\n\n /**\n * In certain circumstances of a tag where only an `>` is allowed.\n *\n * ```markdown\n * > | a <b c=\"d\"> e\n * ^\n * ```\n *\n * @type {State}\n */\n function end(code) {\n if (code === 62) {\n effects.consume(code);\n effects.exit(\"htmlTextData\");\n effects.exit(\"htmlText\");\n return ok;\n }\n return nok(code);\n }\n\n /**\n * At eol.\n *\n * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about\n * > empty tokens.\n *\n * ```markdown\n * > | a <!--a\n * ^\n * | b-->\n * ```\n *\n * @type {State}\n */\n function lineEndingBefore(code) {\n effects.exit(\"htmlTextData\");\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return lineEndingAfter;\n }\n\n /**\n * After eol, at optional whitespace.\n *\n * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about\n * > empty tokens.\n *\n * ```markdown\n * | a <!--a\n * > | b-->\n * ^\n * ```\n *\n * @type {State}\n */\n function lineEndingAfter(code) {\n // Always populated by defaults.\n\n return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, \"linePrefix\", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : lineEndingAfterPrefix(code);\n }\n\n /**\n * After eol, after optional whitespace.\n *\n * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about\n * > empty tokens.\n *\n * ```markdown\n * | a <!--a\n * > | b-->\n * ^\n * ```\n *\n * @type {State}\n */\n function lineEndingAfterPrefix(code) {\n effects.enter(\"htmlTextData\");\n return returnState(code);\n }\n}","/**\n * @import {\n * Construct,\n * Event,\n * Resolver,\n * State,\n * TokenizeContext,\n * Tokenizer,\n * Token\n * } from 'micromark-util-types'\n */\n\nimport { factoryDestination } from 'micromark-factory-destination';\nimport { factoryLabel } from 'micromark-factory-label';\nimport { factoryTitle } from 'micromark-factory-title';\nimport { factoryWhitespace } from 'micromark-factory-whitespace';\nimport { markdownLineEndingOrSpace } from 'micromark-util-character';\nimport { push, splice } from 'micromark-util-chunked';\nimport { normalizeIdentifier } from 'micromark-util-normalize-identifier';\nimport { resolveAll } from 'micromark-util-resolve-all';\n/** @type {Construct} */\nexport const labelEnd = {\n name: 'labelEnd',\n resolveAll: resolveAllLabelEnd,\n resolveTo: resolveToLabelEnd,\n tokenize: tokenizeLabelEnd\n};\n\n/** @type {Construct} */\nconst resourceConstruct = {\n tokenize: tokenizeResource\n};\n/** @type {Construct} */\nconst referenceFullConstruct = {\n tokenize: tokenizeReferenceFull\n};\n/** @type {Construct} */\nconst referenceCollapsedConstruct = {\n tokenize: tokenizeReferenceCollapsed\n};\n\n/** @type {Resolver} */\nfunction resolveAllLabelEnd(events) {\n let index = -1;\n /** @type {Array<Event>} */\n const newEvents = [];\n while (++index < events.length) {\n const token = events[index][1];\n newEvents.push(events[index]);\n if (token.type === \"labelImage\" || token.type === \"labelLink\" || token.type === \"labelEnd\") {\n // Remove the marker.\n const offset = token.type === \"labelImage\" ? 4 : 2;\n token.type = \"data\";\n index += offset;\n }\n }\n\n // If the events are equal, we don't have to copy newEvents to events\n if (events.length !== newEvents.length) {\n splice(events, 0, events.length, newEvents);\n }\n return events;\n}\n\n/** @type {Resolver} */\nfunction resolveToLabelEnd(events, context) {\n let index = events.length;\n let offset = 0;\n /** @type {Token} */\n let token;\n /** @type {number | undefined} */\n let open;\n /** @type {number | undefined} */\n let close;\n /** @type {Array<Event>} */\n let media;\n\n // Find an opening.\n while (index--) {\n token = events[index][1];\n if (open) {\n // If we see another link, or inactive link label, we’ve been here before.\n if (token.type === \"link\" || token.type === \"labelLink\" && token._inactive) {\n break;\n }\n\n // Mark other link openings as inactive, as we can’t have links in\n // links.\n if (events[index][0] === 'enter' && token.type === \"labelLink\") {\n token._inactive = true;\n }\n } else if (close) {\n if (events[index][0] === 'enter' && (token.type === \"labelImage\" || token.type === \"labelLink\") && !token._balanced) {\n open = index;\n if (token.type !== \"labelLink\") {\n offset = 2;\n break;\n }\n }\n } else if (token.type === \"labelEnd\") {\n close = index;\n }\n }\n const group = {\n type: events[open][1].type === \"labelLink\" ? \"link\" : \"image\",\n start: {\n ...events[open][1].start\n },\n end: {\n ...events[events.length - 1][1].end\n }\n };\n const label = {\n type: \"label\",\n start: {\n ...events[open][1].start\n },\n end: {\n ...events[close][1].end\n }\n };\n const text = {\n type: \"labelText\",\n start: {\n ...events[open + offset + 2][1].end\n },\n end: {\n ...events[close - 2][1].start\n }\n };\n media = [['enter', group, context], ['enter', label, context]];\n\n // Opening marker.\n media = push(media, events.slice(open + 1, open + offset + 3));\n\n // Text open.\n media = push(media, [['enter', text, context]]);\n\n // Always populated by defaults.\n\n // Between.\n media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + offset + 4, close - 3), context));\n\n // Text close, marker close, label close.\n media = push(media, [['exit', text, context], events[close - 2], events[close - 1], ['exit', label, context]]);\n\n // Reference, resource, or so.\n media = push(media, events.slice(close + 1));\n\n // Media close.\n media = push(media, [['exit', group, context]]);\n splice(events, open, events.length, media);\n return events;\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeLabelEnd(effects, ok, nok) {\n const self = this;\n let index = self.events.length;\n /** @type {Token} */\n let labelStart;\n /** @type {boolean} */\n let defined;\n\n // Find an opening.\n while (index--) {\n if ((self.events[index][1].type === \"labelImage\" || self.events[index][1].type === \"labelLink\") && !self.events[index][1]._balanced) {\n labelStart = self.events[index][1];\n break;\n }\n }\n return start;\n\n /**\n * Start of label end.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * > | [a][b] c\n * ^\n * > | [a][] b\n * ^\n * > | [a] b\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // If there is not an okay opening.\n if (!labelStart) {\n return nok(code);\n }\n\n // If the corresponding label (link) start is marked as inactive,\n // it means we’d be wrapping a link, like this:\n //\n // ```markdown\n // > | a [b [c](d) e](f) g.\n // ^\n // ```\n //\n // We can’t have that, so it’s just balanced brackets.\n if (labelStart._inactive) {\n return labelEndNok(code);\n }\n defined = self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize({\n start: labelStart.end,\n end: self.now()\n })));\n effects.enter(\"labelEnd\");\n effects.enter(\"labelMarker\");\n effects.consume(code);\n effects.exit(\"labelMarker\");\n effects.exit(\"labelEnd\");\n return after;\n }\n\n /**\n * After `]`.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * > | [a][b] c\n * ^\n * > | [a][] b\n * ^\n * > | [a] b\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n // Note: `markdown-rs` also parses GFM footnotes here, which for us is in\n // an extension.\n\n // Resource (`[asd](fgh)`)?\n if (code === 40) {\n return effects.attempt(resourceConstruct, labelEndOk, defined ? labelEndOk : labelEndNok)(code);\n }\n\n // Full (`[asd][fgh]`) or collapsed (`[asd][]`) reference?\n if (code === 91) {\n return effects.attempt(referenceFullConstruct, labelEndOk, defined ? referenceNotFull : labelEndNok)(code);\n }\n\n // Shortcut (`[asd]`) reference?\n return defined ? labelEndOk(code) : labelEndNok(code);\n }\n\n /**\n * After `]`, at `[`, but not at a full reference.\n *\n * > 👉 **Note**: we only get here if the label is defined.\n *\n * ```markdown\n * > | [a][] b\n * ^\n * > | [a] b\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceNotFull(code) {\n return effects.attempt(referenceCollapsedConstruct, labelEndOk, labelEndNok)(code);\n }\n\n /**\n * Done, we found something.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * > | [a][b] c\n * ^\n * > | [a][] b\n * ^\n * > | [a] b\n * ^\n * ```\n *\n * @type {State}\n */\n function labelEndOk(code) {\n // Note: `markdown-rs` does a bunch of stuff here.\n return ok(code);\n }\n\n /**\n * Done, it’s nothing.\n *\n * There was an okay opening, but we didn’t match anything.\n *\n * ```markdown\n * > | [a](b c\n * ^\n * > | [a][b c\n * ^\n * > | [a] b\n * ^\n * ```\n *\n * @type {State}\n */\n function labelEndNok(code) {\n labelStart._balanced = true;\n return nok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeResource(effects, ok, nok) {\n return resourceStart;\n\n /**\n * At a resource.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceStart(code) {\n effects.enter(\"resource\");\n effects.enter(\"resourceMarker\");\n effects.consume(code);\n effects.exit(\"resourceMarker\");\n return resourceBefore;\n }\n\n /**\n * In resource, after `(`, at optional whitespace.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceBefore(code) {\n return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceOpen)(code) : resourceOpen(code);\n }\n\n /**\n * In resource, after optional whitespace, at `)` or a destination.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceOpen(code) {\n if (code === 41) {\n return resourceEnd(code);\n }\n return factoryDestination(effects, resourceDestinationAfter, resourceDestinationMissing, \"resourceDestination\", \"resourceDestinationLiteral\", \"resourceDestinationLiteralMarker\", \"resourceDestinationRaw\", \"resourceDestinationString\", 32)(code);\n }\n\n /**\n * In resource, after destination, at optional whitespace.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceDestinationAfter(code) {\n return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceBetween)(code) : resourceEnd(code);\n }\n\n /**\n * At invalid destination.\n *\n * ```markdown\n * > | [a](<<) b\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceDestinationMissing(code) {\n return nok(code);\n }\n\n /**\n * In resource, after destination and whitespace, at `(` or title.\n *\n * ```markdown\n * > | [a](b ) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceBetween(code) {\n if (code === 34 || code === 39 || code === 40) {\n return factoryTitle(effects, resourceTitleAfter, nok, \"resourceTitle\", \"resourceTitleMarker\", \"resourceTitleString\")(code);\n }\n return resourceEnd(code);\n }\n\n /**\n * In resource, after title, at optional whitespace.\n *\n * ```markdown\n * > | [a](b \"c\") d\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceTitleAfter(code) {\n return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceEnd)(code) : resourceEnd(code);\n }\n\n /**\n * In resource, at `)`.\n *\n * ```markdown\n * > | [a](b) d\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceEnd(code) {\n if (code === 41) {\n effects.enter(\"resourceMarker\");\n effects.consume(code);\n effects.exit(\"resourceMarker\");\n effects.exit(\"resource\");\n return ok;\n }\n return nok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeReferenceFull(effects, ok, nok) {\n const self = this;\n return referenceFull;\n\n /**\n * In a reference (full), at the `[`.\n *\n * ```markdown\n * > | [a][b] d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceFull(code) {\n return factoryLabel.call(self, effects, referenceFullAfter, referenceFullMissing, \"reference\", \"referenceMarker\", \"referenceString\")(code);\n }\n\n /**\n * In a reference (full), after `]`.\n *\n * ```markdown\n * > | [a][b] d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceFullAfter(code) {\n return self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1))) ? ok(code) : nok(code);\n }\n\n /**\n * In reference (full) that was missing.\n *\n * ```markdown\n * > | [a][b d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceFullMissing(code) {\n return nok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeReferenceCollapsed(effects, ok, nok) {\n return referenceCollapsedStart;\n\n /**\n * In reference (collapsed), at `[`.\n *\n * > 👉 **Note**: we only get here if the label is defined.\n *\n * ```markdown\n * > | [a][] d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceCollapsedStart(code) {\n // We only attempt a collapsed label if there’s a `[`.\n\n effects.enter(\"reference\");\n effects.enter(\"referenceMarker\");\n effects.consume(code);\n effects.exit(\"referenceMarker\");\n return referenceCollapsedOpen;\n }\n\n /**\n * In reference (collapsed), at `]`.\n *\n * > 👉 **Note**: we only get here if the label is defined.\n *\n * ```markdown\n * > | [a][] d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceCollapsedOpen(code) {\n if (code === 93) {\n effects.enter(\"referenceMarker\");\n effects.consume(code);\n effects.exit(\"referenceMarker\");\n effects.exit(\"reference\");\n return ok;\n }\n return nok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { labelEnd } from './label-end.js';\n\n/** @type {Construct} */\nexport const labelStartImage = {\n name: 'labelStartImage',\n resolveAll: labelEnd.resolveAll,\n tokenize: tokenizeLabelStartImage\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeLabelStartImage(effects, ok, nok) {\n const self = this;\n return start;\n\n /**\n * Start of label (image) start.\n *\n * ```markdown\n * > | a ![b] c\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"labelImage\");\n effects.enter(\"labelImageMarker\");\n effects.consume(code);\n effects.exit(\"labelImageMarker\");\n return open;\n }\n\n /**\n * After `!`, at `[`.\n *\n * ```markdown\n * > | a ![b] c\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (code === 91) {\n effects.enter(\"labelMarker\");\n effects.consume(code);\n effects.exit(\"labelMarker\");\n effects.exit(\"labelImage\");\n return after;\n }\n return nok(code);\n }\n\n /**\n * After `![`.\n *\n * ```markdown\n * > | a ![b] c\n * ^\n * ```\n *\n * This is needed in because, when GFM footnotes are enabled, images never\n * form when started with a `^`.\n * Instead, links form:\n *\n * ```markdown\n * ![^a](b)\n *\n * ![^a][b]\n *\n * [b]: c\n * ```\n *\n * ```html\n * <p>!<a href=\\\"b\\\">^a</a></p>\n * <p>!<a href=\\\"c\\\">^a</a></p>\n * ```\n *\n * @type {State}\n */\n function after(code) {\n // To do: use a new field to do this, this is still needed for\n // `micromark-extension-gfm-footnote`, but the `label-start-link`\n // behavior isn’t.\n // Hidden footnotes hook.\n /* c8 ignore next 3 */\n return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs ? nok(code) : ok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { labelEnd } from './label-end.js';\n\n/** @type {Construct} */\nexport const labelStartLink = {\n name: 'labelStartLink',\n resolveAll: labelEnd.resolveAll,\n tokenize: tokenizeLabelStartLink\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeLabelStartLink(effects, ok, nok) {\n const self = this;\n return start;\n\n /**\n * Start of label (link) start.\n *\n * ```markdown\n * > | a [b] c\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"labelLink\");\n effects.enter(\"labelMarker\");\n effects.consume(code);\n effects.exit(\"labelMarker\");\n effects.exit(\"labelLink\");\n return after;\n }\n\n /** @type {State} */\n function after(code) {\n // To do: this isn’t needed in `micromark-extension-gfm-footnote`,\n // remove.\n // Hidden footnotes hook.\n /* c8 ignore next 3 */\n return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs ? nok(code) : ok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding } from 'micromark-util-character';\n/** @type {Construct} */\nexport const lineEnding = {\n name: 'lineEnding',\n tokenize: tokenizeLineEnding\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeLineEnding(effects, ok) {\n return start;\n\n /** @type {State} */\n function start(code) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return factorySpace(effects, ok, \"linePrefix\");\n }\n}","/**\n * @import {\n * Code,\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nexport const thematicBreak = {\n name: 'thematicBreak',\n tokenize: tokenizeThematicBreak\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeThematicBreak(effects, ok, nok) {\n let size = 0;\n /** @type {NonNullable<Code>} */\n let marker;\n return start;\n\n /**\n * Start of thematic break.\n *\n * ```markdown\n * > | ***\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"thematicBreak\");\n // To do: parse indent like `markdown-rs`.\n return before(code);\n }\n\n /**\n * After optional whitespace, at marker.\n *\n * ```markdown\n * > | ***\n * ^\n * ```\n *\n * @type {State}\n */\n function before(code) {\n marker = code;\n return atBreak(code);\n }\n\n /**\n * After something, before something else.\n *\n * ```markdown\n * > | ***\n * ^\n * ```\n *\n * @type {State}\n */\n function atBreak(code) {\n if (code === marker) {\n effects.enter(\"thematicBreakSequence\");\n return sequence(code);\n }\n if (size >= 3 && (code === null || markdownLineEnding(code))) {\n effects.exit(\"thematicBreak\");\n return ok(code);\n }\n return nok(code);\n }\n\n /**\n * In sequence.\n *\n * ```markdown\n * > | ***\n * ^\n * ```\n *\n * @type {State}\n */\n function sequence(code) {\n if (code === marker) {\n effects.consume(code);\n size++;\n return sequence;\n }\n effects.exit(\"thematicBreakSequence\");\n return markdownSpace(code) ? factorySpace(effects, atBreak, \"whitespace\")(code) : atBreak(code);\n }\n}","/**\n * @import {\n * Code,\n * Construct,\n * Exiter,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { asciiDigit, markdownSpace } from 'micromark-util-character';\nimport { blankLine } from './blank-line.js';\nimport { thematicBreak } from './thematic-break.js';\n\n/** @type {Construct} */\nexport const list = {\n continuation: {\n tokenize: tokenizeListContinuation\n },\n exit: tokenizeListEnd,\n name: 'list',\n tokenize: tokenizeListStart\n};\n\n/** @type {Construct} */\nconst listItemPrefixWhitespaceConstruct = {\n partial: true,\n tokenize: tokenizeListItemPrefixWhitespace\n};\n\n/** @type {Construct} */\nconst indentConstruct = {\n partial: true,\n tokenize: tokenizeIndent\n};\n\n// To do: `markdown-rs` parses list items on their own and later stitches them\n// together.\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeListStart(effects, ok, nok) {\n const self = this;\n const tail = self.events[self.events.length - 1];\n let initialSize = tail && tail[1].type === \"linePrefix\" ? tail[2].sliceSerialize(tail[1], true).length : 0;\n let size = 0;\n return start;\n\n /** @type {State} */\n function start(code) {\n const kind = self.containerState.type || (code === 42 || code === 43 || code === 45 ? \"listUnordered\" : \"listOrdered\");\n if (kind === \"listUnordered\" ? !self.containerState.marker || code === self.containerState.marker : asciiDigit(code)) {\n if (!self.containerState.type) {\n self.containerState.type = kind;\n effects.enter(kind, {\n _container: true\n });\n }\n if (kind === \"listUnordered\") {\n effects.enter(\"listItemPrefix\");\n return code === 42 || code === 45 ? effects.check(thematicBreak, nok, atMarker)(code) : atMarker(code);\n }\n if (!self.interrupt || code === 49) {\n effects.enter(\"listItemPrefix\");\n effects.enter(\"listItemValue\");\n return inside(code);\n }\n }\n return nok(code);\n }\n\n /** @type {State} */\n function inside(code) {\n if (asciiDigit(code) && ++size < 10) {\n effects.consume(code);\n return inside;\n }\n if ((!self.interrupt || size < 2) && (self.containerState.marker ? code === self.containerState.marker : code === 41 || code === 46)) {\n effects.exit(\"listItemValue\");\n return atMarker(code);\n }\n return nok(code);\n }\n\n /**\n * @type {State}\n **/\n function atMarker(code) {\n effects.enter(\"listItemMarker\");\n effects.consume(code);\n effects.exit(\"listItemMarker\");\n self.containerState.marker = self.containerState.marker || code;\n return effects.check(blankLine,\n // Can’t be empty when interrupting.\n self.interrupt ? nok : onBlank, effects.attempt(listItemPrefixWhitespaceConstruct, endOfPrefix, otherPrefix));\n }\n\n /** @type {State} */\n function onBlank(code) {\n self.containerState.initialBlankLine = true;\n initialSize++;\n return endOfPrefix(code);\n }\n\n /** @type {State} */\n function otherPrefix(code) {\n if (markdownSpace(code)) {\n effects.enter(\"listItemPrefixWhitespace\");\n effects.consume(code);\n effects.exit(\"listItemPrefixWhitespace\");\n return endOfPrefix;\n }\n return nok(code);\n }\n\n /** @type {State} */\n function endOfPrefix(code) {\n self.containerState.size = initialSize + self.sliceSerialize(effects.exit(\"listItemPrefix\"), true).length;\n return ok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeListContinuation(effects, ok, nok) {\n const self = this;\n self.containerState._closeFlow = undefined;\n return effects.check(blankLine, onBlank, notBlank);\n\n /** @type {State} */\n function onBlank(code) {\n self.containerState.furtherBlankLines = self.containerState.furtherBlankLines || self.containerState.initialBlankLine;\n\n // We have a blank line.\n // Still, try to consume at most the items size.\n return factorySpace(effects, ok, \"listItemIndent\", self.containerState.size + 1)(code);\n }\n\n /** @type {State} */\n function notBlank(code) {\n if (self.containerState.furtherBlankLines || !markdownSpace(code)) {\n self.containerState.furtherBlankLines = undefined;\n self.containerState.initialBlankLine = undefined;\n return notInCurrentItem(code);\n }\n self.containerState.furtherBlankLines = undefined;\n self.containerState.initialBlankLine = undefined;\n return effects.attempt(indentConstruct, ok, notInCurrentItem)(code);\n }\n\n /** @type {State} */\n function notInCurrentItem(code) {\n // While we do continue, we signal that the flow should be closed.\n self.containerState._closeFlow = true;\n // As we’re closing flow, we’re no longer interrupting.\n self.interrupt = undefined;\n // Always populated by defaults.\n\n return factorySpace(effects, effects.attempt(list, ok, nok), \"linePrefix\", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeIndent(effects, ok, nok) {\n const self = this;\n return factorySpace(effects, afterPrefix, \"listItemIndent\", self.containerState.size + 1);\n\n /** @type {State} */\n function afterPrefix(code) {\n const tail = self.events[self.events.length - 1];\n return tail && tail[1].type === \"listItemIndent\" && tail[2].sliceSerialize(tail[1], true).length === self.containerState.size ? ok(code) : nok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Exiter}\n */\nfunction tokenizeListEnd(effects) {\n effects.exit(this.containerState.type);\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeListItemPrefixWhitespace(effects, ok, nok) {\n const self = this;\n\n // Always populated by defaults.\n\n return factorySpace(effects, afterPrefix, \"listItemPrefixWhitespace\", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4 + 1);\n\n /** @type {State} */\n function afterPrefix(code) {\n const tail = self.events[self.events.length - 1];\n return !markdownSpace(code) && tail && tail[1].type === \"listItemPrefixWhitespace\" ? ok(code) : nok(code);\n }\n}","/**\n * @import {\n * Code,\n * Construct,\n * Resolver,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nexport const setextUnderline = {\n name: 'setextUnderline',\n resolveTo: resolveToSetextUnderline,\n tokenize: tokenizeSetextUnderline\n};\n\n/** @type {Resolver} */\nfunction resolveToSetextUnderline(events, context) {\n // To do: resolve like `markdown-rs`.\n let index = events.length;\n /** @type {number | undefined} */\n let content;\n /** @type {number | undefined} */\n let text;\n /** @type {number | undefined} */\n let definition;\n\n // Find the opening of the content.\n // It’ll always exist: we don’t tokenize if it isn’t there.\n while (index--) {\n if (events[index][0] === 'enter') {\n if (events[index][1].type === \"content\") {\n content = index;\n break;\n }\n if (events[index][1].type === \"paragraph\") {\n text = index;\n }\n }\n // Exit\n else {\n if (events[index][1].type === \"content\") {\n // Remove the content end (if needed we’ll add it later)\n events.splice(index, 1);\n }\n if (!definition && events[index][1].type === \"definition\") {\n definition = index;\n }\n }\n }\n const heading = {\n type: \"setextHeading\",\n start: {\n ...events[content][1].start\n },\n end: {\n ...events[events.length - 1][1].end\n }\n };\n\n // Change the paragraph to setext heading text.\n events[text][1].type = \"setextHeadingText\";\n\n // If we have definitions in the content, we’ll keep on having content,\n // but we need move it.\n if (definition) {\n events.splice(text, 0, ['enter', heading, context]);\n events.splice(definition + 1, 0, ['exit', events[content][1], context]);\n events[content][1].end = {\n ...events[definition][1].end\n };\n } else {\n events[content][1] = heading;\n }\n\n // Add the heading exit at the end.\n events.push(['exit', heading, context]);\n return events;\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeSetextUnderline(effects, ok, nok) {\n const self = this;\n /** @type {NonNullable<Code>} */\n let marker;\n return start;\n\n /**\n * At start of heading (setext) underline.\n *\n * ```markdown\n * | aa\n * > | ==\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n let index = self.events.length;\n /** @type {boolean | undefined} */\n let paragraph;\n // Find an opening.\n while (index--) {\n // Skip enter/exit of line ending, line prefix, and content.\n // We can now either have a definition or a paragraph.\n if (self.events[index][1].type !== \"lineEnding\" && self.events[index][1].type !== \"linePrefix\" && self.events[index][1].type !== \"content\") {\n paragraph = self.events[index][1].type === \"paragraph\";\n break;\n }\n }\n\n // To do: handle lazy/pierce like `markdown-rs`.\n // To do: parse indent like `markdown-rs`.\n if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) {\n effects.enter(\"setextHeadingLine\");\n marker = code;\n return before(code);\n }\n return nok(code);\n }\n\n /**\n * After optional whitespace, at `-` or `=`.\n *\n * ```markdown\n * | aa\n * > | ==\n * ^\n * ```\n *\n * @type {State}\n */\n function before(code) {\n effects.enter(\"setextHeadingLineSequence\");\n return inside(code);\n }\n\n /**\n * In sequence.\n *\n * ```markdown\n * | aa\n * > | ==\n * ^\n * ```\n *\n * @type {State}\n */\n function inside(code) {\n if (code === marker) {\n effects.consume(code);\n return inside;\n }\n effects.exit(\"setextHeadingLineSequence\");\n return markdownSpace(code) ? factorySpace(effects, after, \"lineSuffix\")(code) : after(code);\n }\n\n /**\n * After sequence, after optional whitespace.\n *\n * ```markdown\n * | aa\n * > | ==\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"setextHeadingLine\");\n return ok(code);\n }\n return nok(code);\n }\n}","/**\n * @import {\n * InitialConstruct,\n * Initializer,\n * State,\n * TokenizeContext\n * } from 'micromark-util-types'\n */\n\nimport { blankLine, content } from 'micromark-core-commonmark';\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding } from 'micromark-util-character';\n/** @type {InitialConstruct} */\nexport const flow = {\n tokenize: initializeFlow\n};\n\n/**\n * @this {TokenizeContext}\n * Self.\n * @type {Initializer}\n * Initializer.\n */\nfunction initializeFlow(effects) {\n const self = this;\n const initial = effects.attempt(\n // Try to parse a blank line.\n blankLine, atBlankEnding,\n // Try to parse initial flow (essentially, only code).\n effects.attempt(this.parser.constructs.flowInitial, afterConstruct, factorySpace(effects, effects.attempt(this.parser.constructs.flow, afterConstruct, effects.attempt(content, afterConstruct)), \"linePrefix\")));\n return initial;\n\n /** @type {State} */\n function atBlankEnding(code) {\n if (code === null) {\n effects.consume(code);\n return;\n }\n effects.enter(\"lineEndingBlank\");\n effects.consume(code);\n effects.exit(\"lineEndingBlank\");\n self.currentConstruct = undefined;\n return initial;\n }\n\n /** @type {State} */\n function afterConstruct(code) {\n if (code === null) {\n effects.consume(code);\n return;\n }\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n self.currentConstruct = undefined;\n return initial;\n }\n}","/**\n * @import {\n * Code,\n * InitialConstruct,\n * Initializer,\n * Resolver,\n * State,\n * TokenizeContext\n * } from 'micromark-util-types'\n */\n\nexport const resolver = {\n resolveAll: createResolver()\n};\nexport const string = initializeFactory('string');\nexport const text = initializeFactory('text');\n\n/**\n * @param {'string' | 'text'} field\n * Field.\n * @returns {InitialConstruct}\n * Construct.\n */\nfunction initializeFactory(field) {\n return {\n resolveAll: createResolver(field === 'text' ? resolveAllLineSuffixes : undefined),\n tokenize: initializeText\n };\n\n /**\n * @this {TokenizeContext}\n * Context.\n * @type {Initializer}\n */\n function initializeText(effects) {\n const self = this;\n const constructs = this.parser.constructs[field];\n const text = effects.attempt(constructs, start, notText);\n return start;\n\n /** @type {State} */\n function start(code) {\n return atBreak(code) ? text(code) : notText(code);\n }\n\n /** @type {State} */\n function notText(code) {\n if (code === null) {\n effects.consume(code);\n return;\n }\n effects.enter(\"data\");\n effects.consume(code);\n return data;\n }\n\n /** @type {State} */\n function data(code) {\n if (atBreak(code)) {\n effects.exit(\"data\");\n return text(code);\n }\n\n // Data.\n effects.consume(code);\n return data;\n }\n\n /**\n * @param {Code} code\n * Code.\n * @returns {boolean}\n * Whether the code is a break.\n */\n function atBreak(code) {\n if (code === null) {\n return true;\n }\n const list = constructs[code];\n let index = -1;\n if (list) {\n // Always populated by defaults.\n\n while (++index < list.length) {\n const item = list[index];\n if (!item.previous || item.previous.call(self, self.previous)) {\n return true;\n }\n }\n }\n return false;\n }\n }\n}\n\n/**\n * @param {Resolver | undefined} [extraResolver]\n * Resolver.\n * @returns {Resolver}\n * Resolver.\n */\nfunction createResolver(extraResolver) {\n return resolveAllText;\n\n /** @type {Resolver} */\n function resolveAllText(events, context) {\n let index = -1;\n /** @type {number | undefined} */\n let enter;\n\n // A rather boring computation (to merge adjacent `data` events) which\n // improves mm performance by 29%.\n while (++index <= events.length) {\n if (enter === undefined) {\n if (events[index] && events[index][1].type === \"data\") {\n enter = index;\n index++;\n }\n } else if (!events[index] || events[index][1].type !== \"data\") {\n // Don’t do anything if there is one data token.\n if (index !== enter + 2) {\n events[enter][1].end = events[index - 1][1].end;\n events.splice(enter + 2, index - enter - 2);\n index = enter + 2;\n }\n enter = undefined;\n }\n }\n return extraResolver ? extraResolver(events, context) : events;\n }\n}\n\n/**\n * A rather ugly set of instructions which again looks at chunks in the input\n * stream.\n * The reason to do this here is that it is *much* faster to parse in reverse.\n * And that we can’t hook into `null` to split the line suffix before an EOF.\n * To do: figure out if we can make this into a clean utility, or even in core.\n * As it will be useful for GFMs literal autolink extension (and maybe even\n * tables?)\n *\n * @type {Resolver}\n */\nfunction resolveAllLineSuffixes(events, context) {\n let eventIndex = 0; // Skip first.\n\n while (++eventIndex <= events.length) {\n if ((eventIndex === events.length || events[eventIndex][1].type === \"lineEnding\") && events[eventIndex - 1][1].type === \"data\") {\n const data = events[eventIndex - 1][1];\n const chunks = context.sliceStream(data);\n let index = chunks.length;\n let bufferIndex = -1;\n let size = 0;\n /** @type {boolean | undefined} */\n let tabs;\n while (index--) {\n const chunk = chunks[index];\n if (typeof chunk === 'string') {\n bufferIndex = chunk.length;\n while (chunk.charCodeAt(bufferIndex - 1) === 32) {\n size++;\n bufferIndex--;\n }\n if (bufferIndex) break;\n bufferIndex = -1;\n }\n // Number\n else if (chunk === -2) {\n tabs = true;\n size++;\n } else if (chunk === -1) {\n // Empty\n } else {\n // Replacement character, exit.\n index++;\n break;\n }\n }\n\n // Allow final trailing whitespace.\n if (context._contentTypeTextTrailing && eventIndex === events.length) {\n size = 0;\n }\n if (size) {\n const token = {\n type: eventIndex === events.length || tabs || size < 2 ? \"lineSuffix\" : \"hardBreakTrailing\",\n start: {\n _bufferIndex: index ? bufferIndex : data.start._bufferIndex + bufferIndex,\n _index: data.start._index + index,\n line: data.end.line,\n column: data.end.column - size,\n offset: data.end.offset - size\n },\n end: {\n ...data.end\n }\n };\n data.end = {\n ...token.start\n };\n if (data.start.offset === data.end.offset) {\n Object.assign(data, token);\n } else {\n events.splice(eventIndex, 0, ['enter', token, context], ['exit', token, context]);\n eventIndex += 2;\n }\n }\n eventIndex++;\n }\n }\n return events;\n}","/**\n * @import {Extension} from 'micromark-util-types'\n */\n\nimport { attention, autolink, blockQuote, characterEscape, characterReference, codeFenced, codeIndented, codeText, definition, hardBreakEscape, headingAtx, htmlFlow, htmlText, labelEnd, labelStartImage, labelStartLink, lineEnding, list, setextUnderline, thematicBreak } from 'micromark-core-commonmark';\nimport { resolver as resolveText } from './initialize/text.js';\n\n/** @satisfies {Extension['document']} */\nexport const document = {\n [42]: list,\n [43]: list,\n [45]: list,\n [48]: list,\n [49]: list,\n [50]: list,\n [51]: list,\n [52]: list,\n [53]: list,\n [54]: list,\n [55]: list,\n [56]: list,\n [57]: list,\n [62]: blockQuote\n};\n\n/** @satisfies {Extension['contentInitial']} */\nexport const contentInitial = {\n [91]: definition\n};\n\n/** @satisfies {Extension['flowInitial']} */\nexport const flowInitial = {\n [-2]: codeIndented,\n [-1]: codeIndented,\n [32]: codeIndented\n};\n\n/** @satisfies {Extension['flow']} */\nexport const flow = {\n [35]: headingAtx,\n [42]: thematicBreak,\n [45]: [setextUnderline, thematicBreak],\n [60]: htmlFlow,\n [61]: setextUnderline,\n [95]: thematicBreak,\n [96]: codeFenced,\n [126]: codeFenced\n};\n\n/** @satisfies {Extension['string']} */\nexport const string = {\n [38]: characterReference,\n [92]: characterEscape\n};\n\n/** @satisfies {Extension['text']} */\nexport const text = {\n [-5]: lineEnding,\n [-4]: lineEnding,\n [-3]: lineEnding,\n [33]: labelStartImage,\n [38]: characterReference,\n [42]: attention,\n [60]: [autolink, htmlText],\n [91]: labelStartLink,\n [92]: [hardBreakEscape, characterEscape],\n [93]: labelEnd,\n [95]: attention,\n [96]: codeText\n};\n\n/** @satisfies {Extension['insideSpan']} */\nexport const insideSpan = {\n null: [attention, resolveText]\n};\n\n/** @satisfies {Extension['attentionMarkers']} */\nexport const attentionMarkers = {\n null: [42, 95]\n};\n\n/** @satisfies {Extension['disable']} */\nexport const disable = {\n null: []\n};","/**\n * @import {\n * Chunk,\n * Code,\n * ConstructRecord,\n * Construct,\n * Effects,\n * InitialConstruct,\n * ParseContext,\n * Point,\n * State,\n * TokenizeContext,\n * Token\n * } from 'micromark-util-types'\n */\n\n/**\n * @callback Restore\n * Restore the state.\n * @returns {undefined}\n * Nothing.\n *\n * @typedef Info\n * Info.\n * @property {Restore} restore\n * Restore.\n * @property {number} from\n * From.\n *\n * @callback ReturnHandle\n * Handle a successful run.\n * @param {Construct} construct\n * Construct.\n * @param {Info} info\n * Info.\n * @returns {undefined}\n * Nothing.\n */\n\nimport { markdownLineEnding } from 'micromark-util-character';\nimport { push, splice } from 'micromark-util-chunked';\nimport { resolveAll } from 'micromark-util-resolve-all';\n/**\n * Create a tokenizer.\n * Tokenizers deal with one type of data (e.g., containers, flow, text).\n * The parser is the object dealing with it all.\n * `initialize` works like other constructs, except that only its `tokenize`\n * function is used, in which case it doesn’t receive an `ok` or `nok`.\n * `from` can be given to set the point before the first character, although\n * when further lines are indented, they must be set with `defineSkip`.\n *\n * @param {ParseContext} parser\n * Parser.\n * @param {InitialConstruct} initialize\n * Construct.\n * @param {Omit<Point, '_bufferIndex' | '_index'> | undefined} [from]\n * Point (optional).\n * @returns {TokenizeContext}\n * Context.\n */\nexport function createTokenizer(parser, initialize, from) {\n /** @type {Point} */\n let point = {\n _bufferIndex: -1,\n _index: 0,\n line: from && from.line || 1,\n column: from && from.column || 1,\n offset: from && from.offset || 0\n };\n /** @type {Record<string, number>} */\n const columnStart = {};\n /** @type {Array<Construct>} */\n const resolveAllConstructs = [];\n /** @type {Array<Chunk>} */\n let chunks = [];\n /** @type {Array<Token>} */\n let stack = [];\n /** @type {boolean | undefined} */\n let consumed = true;\n\n /**\n * Tools used for tokenizing.\n *\n * @type {Effects}\n */\n const effects = {\n attempt: constructFactory(onsuccessfulconstruct),\n check: constructFactory(onsuccessfulcheck),\n consume,\n enter,\n exit,\n interrupt: constructFactory(onsuccessfulcheck, {\n interrupt: true\n })\n };\n\n /**\n * State and tools for resolving and serializing.\n *\n * @type {TokenizeContext}\n */\n const context = {\n code: null,\n containerState: {},\n defineSkip,\n events: [],\n now,\n parser,\n previous: null,\n sliceSerialize,\n sliceStream,\n write\n };\n\n /**\n * The state function.\n *\n * @type {State | undefined}\n */\n let state = initialize.tokenize.call(context, effects);\n\n /**\n * Track which character we expect to be consumed, to catch bugs.\n *\n * @type {Code}\n */\n let expectedCode;\n if (initialize.resolveAll) {\n resolveAllConstructs.push(initialize);\n }\n return context;\n\n /** @type {TokenizeContext['write']} */\n function write(slice) {\n chunks = push(chunks, slice);\n main();\n\n // Exit if we’re not done, resolve might change stuff.\n if (chunks[chunks.length - 1] !== null) {\n return [];\n }\n addResult(initialize, 0);\n\n // Otherwise, resolve, and exit.\n context.events = resolveAll(resolveAllConstructs, context.events, context);\n return context.events;\n }\n\n //\n // Tools.\n //\n\n /** @type {TokenizeContext['sliceSerialize']} */\n function sliceSerialize(token, expandTabs) {\n return serializeChunks(sliceStream(token), expandTabs);\n }\n\n /** @type {TokenizeContext['sliceStream']} */\n function sliceStream(token) {\n return sliceChunks(chunks, token);\n }\n\n /** @type {TokenizeContext['now']} */\n function now() {\n // This is a hot path, so we clone manually instead of `Object.assign({}, point)`\n const {\n _bufferIndex,\n _index,\n line,\n column,\n offset\n } = point;\n return {\n _bufferIndex,\n _index,\n line,\n column,\n offset\n };\n }\n\n /** @type {TokenizeContext['defineSkip']} */\n function defineSkip(value) {\n columnStart[value.line] = value.column;\n accountForPotentialSkip();\n }\n\n //\n // State management.\n //\n\n /**\n * Main loop (note that `_index` and `_bufferIndex` in `point` are modified by\n * `consume`).\n * Here is where we walk through the chunks, which either include strings of\n * several characters, or numerical character codes.\n * The reason to do this in a loop instead of a call is so the stack can\n * drain.\n *\n * @returns {undefined}\n * Nothing.\n */\n function main() {\n /** @type {number} */\n let chunkIndex;\n while (point._index < chunks.length) {\n const chunk = chunks[point._index];\n\n // If we’re in a buffer chunk, loop through it.\n if (typeof chunk === 'string') {\n chunkIndex = point._index;\n if (point._bufferIndex < 0) {\n point._bufferIndex = 0;\n }\n while (point._index === chunkIndex && point._bufferIndex < chunk.length) {\n go(chunk.charCodeAt(point._bufferIndex));\n }\n } else {\n go(chunk);\n }\n }\n }\n\n /**\n * Deal with one code.\n *\n * @param {Code} code\n * Code.\n * @returns {undefined}\n * Nothing.\n */\n function go(code) {\n consumed = undefined;\n expectedCode = code;\n state = state(code);\n }\n\n /** @type {Effects['consume']} */\n function consume(code) {\n if (markdownLineEnding(code)) {\n point.line++;\n point.column = 1;\n point.offset += code === -3 ? 2 : 1;\n accountForPotentialSkip();\n } else if (code !== -1) {\n point.column++;\n point.offset++;\n }\n\n // Not in a string chunk.\n if (point._bufferIndex < 0) {\n point._index++;\n } else {\n point._bufferIndex++;\n\n // At end of string chunk.\n if (point._bufferIndex ===\n // Points w/ non-negative `_bufferIndex` reference\n // strings.\n /** @type {string} */\n chunks[point._index].length) {\n point._bufferIndex = -1;\n point._index++;\n }\n }\n\n // Expose the previous character.\n context.previous = code;\n\n // Mark as consumed.\n consumed = true;\n }\n\n /** @type {Effects['enter']} */\n function enter(type, fields) {\n /** @type {Token} */\n // @ts-expect-error Patch instead of assign required fields to help GC.\n const token = fields || {};\n token.type = type;\n token.start = now();\n context.events.push(['enter', token, context]);\n stack.push(token);\n return token;\n }\n\n /** @type {Effects['exit']} */\n function exit(type) {\n const token = stack.pop();\n token.end = now();\n context.events.push(['exit', token, context]);\n return token;\n }\n\n /**\n * Use results.\n *\n * @type {ReturnHandle}\n */\n function onsuccessfulconstruct(construct, info) {\n addResult(construct, info.from);\n }\n\n /**\n * Discard results.\n *\n * @type {ReturnHandle}\n */\n function onsuccessfulcheck(_, info) {\n info.restore();\n }\n\n /**\n * Factory to attempt/check/interrupt.\n *\n * @param {ReturnHandle} onreturn\n * Callback.\n * @param {{interrupt?: boolean | undefined} | undefined} [fields]\n * Fields.\n */\n function constructFactory(onreturn, fields) {\n return hook;\n\n /**\n * Handle either an object mapping codes to constructs, a list of\n * constructs, or a single construct.\n *\n * @param {Array<Construct> | ConstructRecord | Construct} constructs\n * Constructs.\n * @param {State} returnState\n * State.\n * @param {State | undefined} [bogusState]\n * State.\n * @returns {State}\n * State.\n */\n function hook(constructs, returnState, bogusState) {\n /** @type {ReadonlyArray<Construct>} */\n let listOfConstructs;\n /** @type {number} */\n let constructIndex;\n /** @type {Construct} */\n let currentConstruct;\n /** @type {Info} */\n let info;\n return Array.isArray(constructs) ? /* c8 ignore next 1 */\n handleListOfConstructs(constructs) : 'tokenize' in constructs ?\n // Looks like a construct.\n handleListOfConstructs([(/** @type {Construct} */constructs)]) : handleMapOfConstructs(constructs);\n\n /**\n * Handle a list of construct.\n *\n * @param {ConstructRecord} map\n * Constructs.\n * @returns {State}\n * State.\n */\n function handleMapOfConstructs(map) {\n return start;\n\n /** @type {State} */\n function start(code) {\n const left = code !== null && map[code];\n const all = code !== null && map.null;\n const list = [\n // To do: add more extension tests.\n /* c8 ignore next 2 */\n ...(Array.isArray(left) ? left : left ? [left] : []), ...(Array.isArray(all) ? all : all ? [all] : [])];\n return handleListOfConstructs(list)(code);\n }\n }\n\n /**\n * Handle a list of construct.\n *\n * @param {ReadonlyArray<Construct>} list\n * Constructs.\n * @returns {State}\n * State.\n */\n function handleListOfConstructs(list) {\n listOfConstructs = list;\n constructIndex = 0;\n if (list.length === 0) {\n return bogusState;\n }\n return handleConstruct(list[constructIndex]);\n }\n\n /**\n * Handle a single construct.\n *\n * @param {Construct} construct\n * Construct.\n * @returns {State}\n * State.\n */\n function handleConstruct(construct) {\n return start;\n\n /** @type {State} */\n function start(code) {\n // To do: not needed to store if there is no bogus state, probably?\n // Currently doesn’t work because `inspect` in document does a check\n // w/o a bogus, which doesn’t make sense. But it does seem to help perf\n // by not storing.\n info = store();\n currentConstruct = construct;\n if (!construct.partial) {\n context.currentConstruct = construct;\n }\n\n // Always populated by defaults.\n\n if (construct.name && context.parser.constructs.disable.null.includes(construct.name)) {\n return nok(code);\n }\n return construct.tokenize.call(\n // If we do have fields, create an object w/ `context` as its\n // prototype.\n // This allows a “live binding”, which is needed for `interrupt`.\n fields ? Object.assign(Object.create(context), fields) : context, effects, ok, nok)(code);\n }\n }\n\n /** @type {State} */\n function ok(code) {\n consumed = true;\n onreturn(currentConstruct, info);\n return returnState;\n }\n\n /** @type {State} */\n function nok(code) {\n consumed = true;\n info.restore();\n if (++constructIndex < listOfConstructs.length) {\n return handleConstruct(listOfConstructs[constructIndex]);\n }\n return bogusState;\n }\n }\n }\n\n /**\n * @param {Construct} construct\n * Construct.\n * @param {number} from\n * From.\n * @returns {undefined}\n * Nothing.\n */\n function addResult(construct, from) {\n if (construct.resolveAll && !resolveAllConstructs.includes(construct)) {\n resolveAllConstructs.push(construct);\n }\n if (construct.resolve) {\n splice(context.events, from, context.events.length - from, construct.resolve(context.events.slice(from), context));\n }\n if (construct.resolveTo) {\n context.events = construct.resolveTo(context.events, context);\n }\n }\n\n /**\n * Store state.\n *\n * @returns {Info}\n * Info.\n */\n function store() {\n const startPoint = now();\n const startPrevious = context.previous;\n const startCurrentConstruct = context.currentConstruct;\n const startEventsIndex = context.events.length;\n const startStack = Array.from(stack);\n return {\n from: startEventsIndex,\n restore\n };\n\n /**\n * Restore state.\n *\n * @returns {undefined}\n * Nothing.\n */\n function restore() {\n point = startPoint;\n context.previous = startPrevious;\n context.currentConstruct = startCurrentConstruct;\n context.events.length = startEventsIndex;\n stack = startStack;\n accountForPotentialSkip();\n }\n }\n\n /**\n * Move the current point a bit forward in the line when it’s on a column\n * skip.\n *\n * @returns {undefined}\n * Nothing.\n */\n function accountForPotentialSkip() {\n if (point.line in columnStart && point.column < 2) {\n point.column = columnStart[point.line];\n point.offset += columnStart[point.line] - 1;\n }\n }\n}\n\n/**\n * Get the chunks from a slice of chunks in the range of a token.\n *\n * @param {ReadonlyArray<Chunk>} chunks\n * Chunks.\n * @param {Pick<Token, 'end' | 'start'>} token\n * Token.\n * @returns {Array<Chunk>}\n * Chunks.\n */\nfunction sliceChunks(chunks, token) {\n const startIndex = token.start._index;\n const startBufferIndex = token.start._bufferIndex;\n const endIndex = token.end._index;\n const endBufferIndex = token.end._bufferIndex;\n /** @type {Array<Chunk>} */\n let view;\n if (startIndex === endIndex) {\n // @ts-expect-error `_bufferIndex` is used on string chunks.\n view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)];\n } else {\n view = chunks.slice(startIndex, endIndex);\n if (startBufferIndex > -1) {\n const head = view[0];\n if (typeof head === 'string') {\n view[0] = head.slice(startBufferIndex);\n /* c8 ignore next 4 -- used to be used, no longer */\n } else {\n view.shift();\n }\n }\n if (endBufferIndex > 0) {\n // @ts-expect-error `_bufferIndex` is used on string chunks.\n view.push(chunks[endIndex].slice(0, endBufferIndex));\n }\n }\n return view;\n}\n\n/**\n * Get the string value of a slice of chunks.\n *\n * @param {ReadonlyArray<Chunk>} chunks\n * Chunks.\n * @param {boolean | undefined} [expandTabs=false]\n * Whether to expand tabs (default: `false`).\n * @returns {string}\n * Result.\n */\nfunction serializeChunks(chunks, expandTabs) {\n let index = -1;\n /** @type {Array<string>} */\n const result = [];\n /** @type {boolean | undefined} */\n let atTab;\n while (++index < chunks.length) {\n const chunk = chunks[index];\n /** @type {string} */\n let value;\n if (typeof chunk === 'string') {\n value = chunk;\n } else switch (chunk) {\n case -5:\n {\n value = \"\\r\";\n break;\n }\n case -4:\n {\n value = \"\\n\";\n break;\n }\n case -3:\n {\n value = \"\\r\" + \"\\n\";\n break;\n }\n case -2:\n {\n value = expandTabs ? \" \" : \"\\t\";\n break;\n }\n case -1:\n {\n if (!expandTabs && atTab) continue;\n value = \" \";\n break;\n }\n default:\n {\n // Currently only replacement character.\n value = String.fromCharCode(chunk);\n }\n }\n atTab = chunk === -2;\n result.push(value);\n }\n return result.join('');\n}","/**\n * @import {\n * Create,\n * FullNormalizedExtension,\n * InitialConstruct,\n * ParseContext,\n * ParseOptions\n * } from 'micromark-util-types'\n */\n\nimport { combineExtensions } from 'micromark-util-combine-extensions';\nimport { content } from './initialize/content.js';\nimport { document } from './initialize/document.js';\nimport { flow } from './initialize/flow.js';\nimport { string, text } from './initialize/text.js';\nimport * as defaultConstructs from './constructs.js';\nimport { createTokenizer } from './create-tokenizer.js';\n\n/**\n * @param {ParseOptions | null | undefined} [options]\n * Configuration (optional).\n * @returns {ParseContext}\n * Parser.\n */\nexport function parse(options) {\n const settings = options || {};\n const constructs = /** @type {FullNormalizedExtension} */\n combineExtensions([defaultConstructs, ...(settings.extensions || [])]);\n\n /** @type {ParseContext} */\n const parser = {\n constructs,\n content: create(content),\n defined: [],\n document: create(document),\n flow: create(flow),\n lazy: {},\n string: create(string),\n text: create(text)\n };\n return parser;\n\n /**\n * @param {InitialConstruct} initial\n * Construct to start with.\n * @returns {Create}\n * Create a tokenizer.\n */\n function create(initial) {\n return creator;\n /** @type {Create} */\n function creator(from) {\n return createTokenizer(parser, initial, from);\n }\n }\n}","/**\n * @import {Event} from 'micromark-util-types'\n */\n\nimport { subtokenize } from 'micromark-util-subtokenize';\n\n/**\n * @param {Array<Event>} events\n * Events.\n * @returns {Array<Event>}\n * Events.\n */\nexport function postprocess(events) {\n while (!subtokenize(events)) {\n // Empty\n }\n return events;\n}","/**\n * @import {Chunk, Code, Encoding, Value} from 'micromark-util-types'\n */\n\n/**\n * @callback Preprocessor\n * Preprocess a value.\n * @param {Value} value\n * Value.\n * @param {Encoding | null | undefined} [encoding]\n * Encoding when `value` is a typed array (optional).\n * @param {boolean | null | undefined} [end=false]\n * Whether this is the last chunk (default: `false`).\n * @returns {Array<Chunk>}\n * Chunks.\n */\n\nconst search = /[\\0\\t\\n\\r]/g;\n\n/**\n * @returns {Preprocessor}\n * Preprocess a value.\n */\nexport function preprocess() {\n let column = 1;\n let buffer = '';\n /** @type {boolean | undefined} */\n let start = true;\n /** @type {boolean | undefined} */\n let atCarriageReturn;\n return preprocessor;\n\n /** @type {Preprocessor} */\n // eslint-disable-next-line complexity\n function preprocessor(value, encoding, end) {\n /** @type {Array<Chunk>} */\n const chunks = [];\n /** @type {RegExpMatchArray | null} */\n let match;\n /** @type {number} */\n let next;\n /** @type {number} */\n let startPosition;\n /** @type {number} */\n let endPosition;\n /** @type {Code} */\n let code;\n value = buffer + (typeof value === 'string' ? value.toString() : new TextDecoder(encoding || undefined).decode(value));\n startPosition = 0;\n buffer = '';\n if (start) {\n // To do: `markdown-rs` actually parses BOMs (byte order mark).\n if (value.charCodeAt(0) === 65279) {\n startPosition++;\n }\n start = undefined;\n }\n while (startPosition < value.length) {\n search.lastIndex = startPosition;\n match = search.exec(value);\n endPosition = match && match.index !== undefined ? match.index : value.length;\n code = value.charCodeAt(endPosition);\n if (!match) {\n buffer = value.slice(startPosition);\n break;\n }\n if (code === 10 && startPosition === endPosition && atCarriageReturn) {\n chunks.push(-3);\n atCarriageReturn = undefined;\n } else {\n if (atCarriageReturn) {\n chunks.push(-5);\n atCarriageReturn = undefined;\n }\n if (startPosition < endPosition) {\n chunks.push(value.slice(startPosition, endPosition));\n column += endPosition - startPosition;\n }\n switch (code) {\n case 0:\n {\n chunks.push(65533);\n column++;\n break;\n }\n case 9:\n {\n next = Math.ceil(column / 4) * 4;\n chunks.push(-2);\n while (column++ < next) chunks.push(-1);\n break;\n }\n case 10:\n {\n chunks.push(-4);\n column = 1;\n break;\n }\n default:\n {\n atCarriageReturn = true;\n column = 1;\n }\n }\n }\n startPosition = endPosition + 1;\n }\n if (end) {\n if (atCarriageReturn) chunks.push(-5);\n if (buffer) chunks.push(buffer);\n chunks.push(null);\n }\n return chunks;\n }\n}","/**\n * @import {Encoding, Value} from 'micromark-util-types'\n */\n\n/**\n * @typedef {import('micromark-util-types').Options} Options\n */\n\nimport { compile } from './lib/compile.js';\nimport { parse } from './lib/parse.js';\nimport { postprocess } from './lib/postprocess.js';\nimport { preprocess } from './lib/preprocess.js';\nexport { compile } from './lib/compile.js';\nexport { parse } from './lib/parse.js';\nexport { postprocess } from './lib/postprocess.js';\nexport { preprocess } from './lib/preprocess.js';\n\n/**\n * Compile markdown to HTML.\n *\n * > Note: which encodings are supported depends on the engine.\n * > For info on Node.js, see:\n * > <https://nodejs.org/api/util.html#whatwg-supported-encodings>.\n *\n * @overload\n * @param {Value} value\n * Markdown to parse (`string` or `Uint8Array`).\n * @param {Encoding | null | undefined} encoding\n * Character encoding to understand `value` as when it’s a `Uint8Array`\n * (`string`, default: `'utf8'`).\n * @param {Options | null | undefined} [options]\n * Configuration.\n * @returns {string}\n * Compiled HTML.\n *\n * @overload\n * @param {Value} value\n * Markdown to parse (`string` or `Uint8Array`).\n * @param {Options | null | undefined} [options]\n * Configuration.\n * @returns {string}\n * Compiled HTML.\n *\n * @param {Value} value\n * Markdown to parse (`string` or `Uint8Array`).\n * @param {Encoding | Options | null | undefined} [encoding]\n * Character encoding to understand `value` as when it’s a `Uint8Array`\n * (`string`, default: `'utf8'`).\n * @param {Options | null | undefined} [options]\n * Configuration.\n * @returns {string}\n * Compiled HTML.\n */\nexport function micromark(value, encoding, options) {\n if (typeof encoding !== 'string') {\n options = encoding;\n encoding = undefined;\n }\n return compile(options)(postprocess(parse(options).document().write(preprocess()(value, encoding, true))));\n}","/**\n * @import {Options} from 'micromark-extension-gfm-strikethrough'\n * @import {Event, Extension, Resolver, State, Token, TokenizeContext, Tokenizer} from 'micromark-util-types'\n */\n\nimport { splice } from 'micromark-util-chunked';\nimport { classifyCharacter } from 'micromark-util-classify-character';\nimport { resolveAll } from 'micromark-util-resolve-all';\n/**\n * Create an extension for `micromark` to enable GFM strikethrough syntax.\n *\n * @param {Options | null | undefined} [options={}]\n * Configuration.\n * @returns {Extension}\n * Extension for `micromark` that can be passed in `extensions`, to\n * enable GFM strikethrough syntax.\n */\nexport function gfmStrikethrough(options) {\n const options_ = options || {};\n let single = options_.singleTilde;\n const tokenizer = {\n name: 'strikethrough',\n tokenize: tokenizeStrikethrough,\n resolveAll: resolveAllStrikethrough\n };\n if (single === null || single === undefined) {\n single = true;\n }\n return {\n text: {\n [126]: tokenizer\n },\n insideSpan: {\n null: [tokenizer]\n },\n attentionMarkers: {\n null: [126]\n }\n };\n\n /**\n * Take events and resolve strikethrough.\n *\n * @type {Resolver}\n */\n function resolveAllStrikethrough(events, context) {\n let index = -1;\n\n // Walk through all events.\n while (++index < events.length) {\n // Find a token that can close.\n if (events[index][0] === 'enter' && events[index][1].type === 'strikethroughSequenceTemporary' && events[index][1]._close) {\n let open = index;\n\n // Now walk back to find an opener.\n while (open--) {\n // Find a token that can open the closer.\n if (events[open][0] === 'exit' && events[open][1].type === 'strikethroughSequenceTemporary' && events[open][1]._open &&\n // If the sizes are the same:\n events[index][1].end.offset - events[index][1].start.offset === events[open][1].end.offset - events[open][1].start.offset) {\n events[index][1].type = 'strikethroughSequence';\n events[open][1].type = 'strikethroughSequence';\n\n /** @type {Token} */\n const strikethrough = {\n type: 'strikethrough',\n start: Object.assign({}, events[open][1].start),\n end: Object.assign({}, events[index][1].end)\n };\n\n /** @type {Token} */\n const text = {\n type: 'strikethroughText',\n start: Object.assign({}, events[open][1].end),\n end: Object.assign({}, events[index][1].start)\n };\n\n // Opening.\n /** @type {Array<Event>} */\n const nextEvents = [['enter', strikethrough, context], ['enter', events[open][1], context], ['exit', events[open][1], context], ['enter', text, context]];\n const insideSpan = context.parser.constructs.insideSpan.null;\n if (insideSpan) {\n // Between.\n splice(nextEvents, nextEvents.length, 0, resolveAll(insideSpan, events.slice(open + 1, index), context));\n }\n\n // Closing.\n splice(nextEvents, nextEvents.length, 0, [['exit', text, context], ['enter', events[index][1], context], ['exit', events[index][1], context], ['exit', strikethrough, context]]);\n splice(events, open - 1, index - open + 3, nextEvents);\n index = open + nextEvents.length - 2;\n break;\n }\n }\n }\n }\n index = -1;\n while (++index < events.length) {\n if (events[index][1].type === 'strikethroughSequenceTemporary') {\n events[index][1].type = \"data\";\n }\n }\n return events;\n }\n\n /**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\n function tokenizeStrikethrough(effects, ok, nok) {\n const previous = this.previous;\n const events = this.events;\n let size = 0;\n return start;\n\n /** @type {State} */\n function start(code) {\n if (previous === 126 && events[events.length - 1][1].type !== \"characterEscape\") {\n return nok(code);\n }\n effects.enter('strikethroughSequenceTemporary');\n return more(code);\n }\n\n /** @type {State} */\n function more(code) {\n const before = classifyCharacter(previous);\n if (code === 126) {\n // If this is the third marker, exit.\n if (size > 1) return nok(code);\n effects.consume(code);\n size++;\n return more;\n }\n if (size < 2 && !single) return nok(code);\n const token = effects.exit('strikethroughSequenceTemporary');\n const after = classifyCharacter(code);\n token._open = !after || after === 2 && Boolean(before);\n token._close = !before || before === 2 && Boolean(after);\n return ok(code);\n }\n }\n}","function extend(destination) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) destination[key] = source[key];\n }\n }\n return destination;\n}\nfunction repeat(character, count) {\n return Array(count + 1).join(character);\n}\nfunction trimLeadingNewlines(string) {\n return string.replace(/^\\n*/, '');\n}\nfunction trimTrailingNewlines(string) {\n // avoid match-at-end regexp bottleneck, see #370\n var indexEnd = string.length;\n while (indexEnd > 0 && string[indexEnd - 1] === '\\n') indexEnd--;\n return string.substring(0, indexEnd);\n}\nfunction trimNewlines(string) {\n return trimTrailingNewlines(trimLeadingNewlines(string));\n}\nvar blockElements = ['ADDRESS', 'ARTICLE', 'ASIDE', 'AUDIO', 'BLOCKQUOTE', 'BODY', 'CANVAS', 'CENTER', 'DD', 'DIR', 'DIV', 'DL', 'DT', 'FIELDSET', 'FIGCAPTION', 'FIGURE', 'FOOTER', 'FORM', 'FRAMESET', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'HEADER', 'HGROUP', 'HR', 'HTML', 'ISINDEX', 'LI', 'MAIN', 'MENU', 'NAV', 'NOFRAMES', 'NOSCRIPT', 'OL', 'OUTPUT', 'P', 'PRE', 'SECTION', 'TABLE', 'TBODY', 'TD', 'TFOOT', 'TH', 'THEAD', 'TR', 'UL'];\nfunction isBlock(node) {\n return is(node, blockElements);\n}\nvar voidElements = ['AREA', 'BASE', 'BR', 'COL', 'COMMAND', 'EMBED', 'HR', 'IMG', 'INPUT', 'KEYGEN', 'LINK', 'META', 'PARAM', 'SOURCE', 'TRACK', 'WBR'];\nfunction isVoid(node) {\n return is(node, voidElements);\n}\nfunction hasVoid(node) {\n return has(node, voidElements);\n}\nvar meaningfulWhenBlankElements = ['A', 'TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TH', 'TD', 'IFRAME', 'SCRIPT', 'AUDIO', 'VIDEO'];\nfunction isMeaningfulWhenBlank(node) {\n return is(node, meaningfulWhenBlankElements);\n}\nfunction hasMeaningfulWhenBlank(node) {\n return has(node, meaningfulWhenBlankElements);\n}\nfunction is(node, tagNames) {\n return tagNames.indexOf(node.nodeName) >= 0;\n}\nfunction has(node, tagNames) {\n return node.getElementsByTagName && tagNames.some(function (tagName) {\n return node.getElementsByTagName(tagName).length;\n });\n}\nvar markdownEscapes = [[/\\\\/g, '\\\\\\\\'], [/\\*/g, '\\\\*'], [/^-/g, '\\\\-'], [/^\\+ /g, '\\\\+ '], [/^(=+)/g, '\\\\$1'], [/^(#{1,6}) /g, '\\\\$1 '], [/`/g, '\\\\`'], [/^~~~/g, '\\\\~~~'], [/\\[/g, '\\\\['], [/\\]/g, '\\\\]'], [/^>/g, '\\\\>'], [/_/g, '\\\\_'], [/^(\\d+)\\. /g, '$1\\\\. ']];\nfunction escapeMarkdown(string) {\n return markdownEscapes.reduce(function (accumulator, escape) {\n return accumulator.replace(escape[0], escape[1]);\n }, string);\n}\n\nvar rules = {};\nrules.paragraph = {\n filter: 'p',\n replacement: function (content) {\n return '\\n\\n' + content + '\\n\\n';\n }\n};\nrules.lineBreak = {\n filter: 'br',\n replacement: function (content, node, options) {\n return options.br + '\\n';\n }\n};\nrules.heading = {\n filter: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],\n replacement: function (content, node, options) {\n var hLevel = Number(node.nodeName.charAt(1));\n if (options.headingStyle === 'setext' && hLevel < 3) {\n var underline = repeat(hLevel === 1 ? '=' : '-', content.length);\n return '\\n\\n' + content + '\\n' + underline + '\\n\\n';\n } else {\n return '\\n\\n' + repeat('#', hLevel) + ' ' + content + '\\n\\n';\n }\n }\n};\nrules.blockquote = {\n filter: 'blockquote',\n replacement: function (content) {\n content = trimNewlines(content).replace(/^/gm, '> ');\n return '\\n\\n' + content + '\\n\\n';\n }\n};\nrules.list = {\n filter: ['ul', 'ol'],\n replacement: function (content, node) {\n var parent = node.parentNode;\n if (parent.nodeName === 'LI' && parent.lastElementChild === node) {\n return '\\n' + content;\n } else {\n return '\\n\\n' + content + '\\n\\n';\n }\n }\n};\nrules.listItem = {\n filter: 'li',\n replacement: function (content, node, options) {\n var prefix = options.bulletListMarker + ' ';\n var parent = node.parentNode;\n if (parent.nodeName === 'OL') {\n var start = parent.getAttribute('start');\n var index = Array.prototype.indexOf.call(parent.children, node);\n prefix = (start ? Number(start) + index : index + 1) + '. ';\n }\n var isParagraph = /\\n$/.test(content);\n content = trimNewlines(content) + (isParagraph ? '\\n' : '');\n content = content.replace(/\\n/gm, '\\n' + ' '.repeat(prefix.length)); // indent\n return prefix + content + (node.nextSibling ? '\\n' : '');\n }\n};\nrules.indentedCodeBlock = {\n filter: function (node, options) {\n return options.codeBlockStyle === 'indented' && node.nodeName === 'PRE' && node.firstChild && node.firstChild.nodeName === 'CODE';\n },\n replacement: function (content, node, options) {\n return '\\n\\n ' + node.firstChild.textContent.replace(/\\n/g, '\\n ') + '\\n\\n';\n }\n};\nrules.fencedCodeBlock = {\n filter: function (node, options) {\n return options.codeBlockStyle === 'fenced' && node.nodeName === 'PRE' && node.firstChild && node.firstChild.nodeName === 'CODE';\n },\n replacement: function (content, node, options) {\n var className = node.firstChild.getAttribute('class') || '';\n var language = (className.match(/language-(\\S+)/) || [null, ''])[1];\n var code = node.firstChild.textContent;\n var fenceChar = options.fence.charAt(0);\n var fenceSize = 3;\n var fenceInCodeRegex = new RegExp('^' + fenceChar + '{3,}', 'gm');\n var match;\n while (match = fenceInCodeRegex.exec(code)) {\n if (match[0].length >= fenceSize) {\n fenceSize = match[0].length + 1;\n }\n }\n var fence = repeat(fenceChar, fenceSize);\n return '\\n\\n' + fence + language + '\\n' + code.replace(/\\n$/, '') + '\\n' + fence + '\\n\\n';\n }\n};\nrules.horizontalRule = {\n filter: 'hr',\n replacement: function (content, node, options) {\n return '\\n\\n' + options.hr + '\\n\\n';\n }\n};\nrules.inlineLink = {\n filter: function (node, options) {\n return options.linkStyle === 'inlined' && node.nodeName === 'A' && node.getAttribute('href');\n },\n replacement: function (content, node) {\n var href = escapeLinkDestination(node.getAttribute('href'));\n var title = escapeLinkTitle(cleanAttribute(node.getAttribute('title')));\n var titlePart = title ? ' \"' + title + '\"' : '';\n return '[' + content + '](' + href + titlePart + ')';\n }\n};\nrules.referenceLink = {\n filter: function (node, options) {\n return options.linkStyle === 'referenced' && node.nodeName === 'A' && node.getAttribute('href');\n },\n replacement: function (content, node, options) {\n var href = escapeLinkDestination(node.getAttribute('href'));\n var title = cleanAttribute(node.getAttribute('title'));\n if (title) title = ' \"' + escapeLinkTitle(title) + '\"';\n var replacement;\n var reference;\n switch (options.linkReferenceStyle) {\n case 'collapsed':\n replacement = '[' + content + '][]';\n reference = '[' + content + ']: ' + href + title;\n break;\n case 'shortcut':\n replacement = '[' + content + ']';\n reference = '[' + content + ']: ' + href + title;\n break;\n default:\n var id = this.references.length + 1;\n replacement = '[' + content + '][' + id + ']';\n reference = '[' + id + ']: ' + href + title;\n }\n this.references.push(reference);\n return replacement;\n },\n references: [],\n append: function (options) {\n var references = '';\n if (this.references.length) {\n references = '\\n\\n' + this.references.join('\\n') + '\\n\\n';\n this.references = []; // Reset references\n }\n return references;\n }\n};\nrules.emphasis = {\n filter: ['em', 'i'],\n replacement: function (content, node, options) {\n if (!content.trim()) return '';\n return options.emDelimiter + content + options.emDelimiter;\n }\n};\nrules.strong = {\n filter: ['strong', 'b'],\n replacement: function (content, node, options) {\n if (!content.trim()) return '';\n return options.strongDelimiter + content + options.strongDelimiter;\n }\n};\nrules.code = {\n filter: function (node) {\n var hasSiblings = node.previousSibling || node.nextSibling;\n var isCodeBlock = node.parentNode.nodeName === 'PRE' && !hasSiblings;\n return node.nodeName === 'CODE' && !isCodeBlock;\n },\n replacement: function (content) {\n if (!content) return '';\n content = content.replace(/\\r?\\n|\\r/g, ' ');\n var extraSpace = /^`|^ .*?[^ ].* $|`$/.test(content) ? ' ' : '';\n var delimiter = '`';\n var matches = content.match(/`+/gm) || [];\n while (matches.indexOf(delimiter) !== -1) delimiter = delimiter + '`';\n return delimiter + extraSpace + content + extraSpace + delimiter;\n }\n};\nrules.image = {\n filter: 'img',\n replacement: function (content, node) {\n var alt = escapeMarkdown(cleanAttribute(node.getAttribute('alt')));\n var src = escapeLinkDestination(node.getAttribute('src') || '');\n var title = cleanAttribute(node.getAttribute('title'));\n var titlePart = title ? ' \"' + escapeLinkTitle(title) + '\"' : '';\n return src ? '![' + alt + ']' + '(' + src + titlePart + ')' : '';\n }\n};\nfunction cleanAttribute(attribute) {\n return attribute ? attribute.replace(/(\\n+\\s*)+/g, '\\n') : '';\n}\nfunction escapeLinkDestination(destination) {\n var escaped = destination.replace(/([<>()])/g, '\\\\$1');\n return escaped.indexOf(' ') >= 0 ? '<' + escaped + '>' : escaped;\n}\nfunction escapeLinkTitle(title) {\n return title.replace(/\"/g, '\\\\\"');\n}\n\n/**\n * Manages a collection of rules used to convert HTML to Markdown\n */\n\nfunction Rules(options) {\n this.options = options;\n this._keep = [];\n this._remove = [];\n this.blankRule = {\n replacement: options.blankReplacement\n };\n this.keepReplacement = options.keepReplacement;\n this.defaultRule = {\n replacement: options.defaultReplacement\n };\n this.array = [];\n for (var key in options.rules) this.array.push(options.rules[key]);\n}\nRules.prototype = {\n add: function (key, rule) {\n this.array.unshift(rule);\n },\n keep: function (filter) {\n this._keep.unshift({\n filter: filter,\n replacement: this.keepReplacement\n });\n },\n remove: function (filter) {\n this._remove.unshift({\n filter: filter,\n replacement: function () {\n return '';\n }\n });\n },\n forNode: function (node) {\n if (node.isBlank) return this.blankRule;\n var rule;\n if (rule = findRule(this.array, node, this.options)) return rule;\n if (rule = findRule(this._keep, node, this.options)) return rule;\n if (rule = findRule(this._remove, node, this.options)) return rule;\n return this.defaultRule;\n },\n forEach: function (fn) {\n for (var i = 0; i < this.array.length; i++) fn(this.array[i], i);\n }\n};\nfunction findRule(rules, node, options) {\n for (var i = 0; i < rules.length; i++) {\n var rule = rules[i];\n if (filterValue(rule, node, options)) return rule;\n }\n return undefined;\n}\nfunction filterValue(rule, node, options) {\n var filter = rule.filter;\n if (typeof filter === 'string') {\n if (filter === node.nodeName.toLowerCase()) return true;\n } else if (Array.isArray(filter)) {\n if (filter.indexOf(node.nodeName.toLowerCase()) > -1) return true;\n } else if (typeof filter === 'function') {\n if (filter.call(rule, node, options)) return true;\n } else {\n throw new TypeError('`filter` needs to be a string, array, or function');\n }\n}\n\n/**\n * The collapseWhitespace function is adapted from collapse-whitespace\n * by Luc Thevenard.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2014 Luc Thevenard <lucthevenard@gmail.com>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n/**\n * collapseWhitespace(options) removes extraneous whitespace from an the given element.\n *\n * @param {Object} options\n */\nfunction collapseWhitespace(options) {\n var element = options.element;\n var isBlock = options.isBlock;\n var isVoid = options.isVoid;\n var isPre = options.isPre || function (node) {\n return node.nodeName === 'PRE';\n };\n if (!element.firstChild || isPre(element)) return;\n var prevText = null;\n var keepLeadingWs = false;\n var prev = null;\n var node = next(prev, element, isPre);\n while (node !== element) {\n if (node.nodeType === 3 || node.nodeType === 4) {\n // Node.TEXT_NODE or Node.CDATA_SECTION_NODE\n var text = node.data.replace(/[ \\r\\n\\t]+/g, ' ');\n if ((!prevText || / $/.test(prevText.data)) && !keepLeadingWs && text[0] === ' ') {\n text = text.substr(1);\n }\n\n // `text` might be empty at this point.\n if (!text) {\n node = remove(node);\n continue;\n }\n node.data = text;\n prevText = node;\n } else if (node.nodeType === 1) {\n // Node.ELEMENT_NODE\n if (isBlock(node) || node.nodeName === 'BR') {\n if (prevText) {\n prevText.data = prevText.data.replace(/ $/, '');\n }\n prevText = null;\n keepLeadingWs = false;\n } else if (isVoid(node) || isPre(node)) {\n // Avoid trimming space around non-block, non-BR void elements and inline PRE.\n prevText = null;\n keepLeadingWs = true;\n } else if (prevText) {\n // Drop protection if set previously.\n keepLeadingWs = false;\n }\n } else {\n node = remove(node);\n continue;\n }\n var nextNode = next(prev, node, isPre);\n prev = node;\n node = nextNode;\n }\n if (prevText) {\n prevText.data = prevText.data.replace(/ $/, '');\n if (!prevText.data) {\n remove(prevText);\n }\n }\n}\n\n/**\n * remove(node) removes the given node from the DOM and returns the\n * next node in the sequence.\n *\n * @param {Node} node\n * @return {Node} node\n */\nfunction remove(node) {\n var next = node.nextSibling || node.parentNode;\n node.parentNode.removeChild(node);\n return next;\n}\n\n/**\n * next(prev, current, isPre) returns the next node in the sequence, given the\n * current and previous nodes.\n *\n * @param {Node} prev\n * @param {Node} current\n * @param {Function} isPre\n * @return {Node}\n */\nfunction next(prev, current, isPre) {\n if (prev && prev.parentNode === current || isPre(current)) {\n return current.nextSibling || current.parentNode;\n }\n return current.firstChild || current.nextSibling || current.parentNode;\n}\n\n/*\n * Set up window for Node.js\n */\n\nvar root = typeof window !== 'undefined' ? window : {};\n\n/*\n * Parsing HTML strings\n */\n\nfunction canParseHTMLNatively() {\n var Parser = root.DOMParser;\n var canParse = false;\n\n // Adapted from https://gist.github.com/1129031\n // Firefox/Opera/IE throw errors on unsupported types\n try {\n // WebKit returns null on unsupported types\n if (new Parser().parseFromString('', 'text/html')) {\n canParse = true;\n }\n } catch (e) {}\n return canParse;\n}\nfunction createHTMLParser() {\n var Parser = function () {};\n {\n if (shouldUseActiveX()) {\n Parser.prototype.parseFromString = function (string) {\n var doc = new window.ActiveXObject('htmlfile');\n doc.designMode = 'on'; // disable on-page scripts\n doc.open();\n doc.write(string);\n doc.close();\n return doc;\n };\n } else {\n Parser.prototype.parseFromString = function (string) {\n var doc = document.implementation.createHTMLDocument('');\n doc.open();\n doc.write(string);\n doc.close();\n return doc;\n };\n }\n }\n return Parser;\n}\nfunction shouldUseActiveX() {\n var useActiveX = false;\n try {\n document.implementation.createHTMLDocument('').open();\n } catch (e) {\n if (root.ActiveXObject) useActiveX = true;\n }\n return useActiveX;\n}\nvar HTMLParser = canParseHTMLNatively() ? root.DOMParser : createHTMLParser();\n\nfunction RootNode(input, options) {\n var root;\n if (typeof input === 'string') {\n var doc = htmlParser().parseFromString(\n // DOM parsers arrange elements in the <head> and <body>.\n // Wrapping in a custom element ensures elements are reliably arranged in\n // a single element.\n '<x-turndown id=\"turndown-root\">' + input + '</x-turndown>', 'text/html');\n root = doc.getElementById('turndown-root');\n } else {\n root = input.cloneNode(true);\n }\n collapseWhitespace({\n element: root,\n isBlock: isBlock,\n isVoid: isVoid,\n isPre: options.preformattedCode ? isPreOrCode : null\n });\n return root;\n}\nvar _htmlParser;\nfunction htmlParser() {\n _htmlParser = _htmlParser || new HTMLParser();\n return _htmlParser;\n}\nfunction isPreOrCode(node) {\n return node.nodeName === 'PRE' || node.nodeName === 'CODE';\n}\n\nfunction Node(node, options) {\n node.isBlock = isBlock(node);\n node.isCode = node.nodeName === 'CODE' || node.parentNode.isCode;\n node.isBlank = isBlank(node);\n node.flankingWhitespace = flankingWhitespace(node, options);\n return node;\n}\nfunction isBlank(node) {\n return !isVoid(node) && !isMeaningfulWhenBlank(node) && /^\\s*$/i.test(node.textContent) && !hasVoid(node) && !hasMeaningfulWhenBlank(node);\n}\nfunction flankingWhitespace(node, options) {\n if (node.isBlock || options.preformattedCode && node.isCode) {\n return {\n leading: '',\n trailing: ''\n };\n }\n var edges = edgeWhitespace(node.textContent);\n\n // abandon leading ASCII WS if left-flanked by ASCII WS\n if (edges.leadingAscii && isFlankedByWhitespace('left', node, options)) {\n edges.leading = edges.leadingNonAscii;\n }\n\n // abandon trailing ASCII WS if right-flanked by ASCII WS\n if (edges.trailingAscii && isFlankedByWhitespace('right', node, options)) {\n edges.trailing = edges.trailingNonAscii;\n }\n return {\n leading: edges.leading,\n trailing: edges.trailing\n };\n}\nfunction edgeWhitespace(string) {\n var m = string.match(/^(([ \\t\\r\\n]*)(\\s*))(?:(?=\\S)[\\s\\S]*\\S)?((\\s*?)([ \\t\\r\\n]*))$/);\n return {\n leading: m[1],\n // whole string for whitespace-only strings\n leadingAscii: m[2],\n leadingNonAscii: m[3],\n trailing: m[4],\n // empty for whitespace-only strings\n trailingNonAscii: m[5],\n trailingAscii: m[6]\n };\n}\nfunction isFlankedByWhitespace(side, node, options) {\n var sibling;\n var regExp;\n var isFlanked;\n if (side === 'left') {\n sibling = node.previousSibling;\n regExp = / $/;\n } else {\n sibling = node.nextSibling;\n regExp = /^ /;\n }\n if (sibling) {\n if (sibling.nodeType === 3) {\n isFlanked = regExp.test(sibling.nodeValue);\n } else if (options.preformattedCode && sibling.nodeName === 'CODE') {\n isFlanked = false;\n } else if (sibling.nodeType === 1 && !isBlock(sibling)) {\n isFlanked = regExp.test(sibling.textContent);\n }\n }\n return isFlanked;\n}\n\nvar reduce = Array.prototype.reduce;\nfunction TurndownService(options) {\n if (!(this instanceof TurndownService)) return new TurndownService(options);\n var defaults = {\n rules: rules,\n headingStyle: 'setext',\n hr: '* * *',\n bulletListMarker: '*',\n codeBlockStyle: 'indented',\n fence: '```',\n emDelimiter: '_',\n strongDelimiter: '**',\n linkStyle: 'inlined',\n linkReferenceStyle: 'full',\n br: ' ',\n preformattedCode: false,\n blankReplacement: function (content, node) {\n return node.isBlock ? '\\n\\n' : '';\n },\n keepReplacement: function (content, node) {\n return node.isBlock ? '\\n\\n' + node.outerHTML + '\\n\\n' : node.outerHTML;\n },\n defaultReplacement: function (content, node) {\n return node.isBlock ? '\\n\\n' + content + '\\n\\n' : content;\n }\n };\n this.options = extend({}, defaults, options);\n this.rules = new Rules(this.options);\n}\nTurndownService.prototype = {\n /**\n * The entry point for converting a string or DOM node to Markdown\n * @public\n * @param {String|HTMLElement} input The string or DOM node to convert\n * @returns A Markdown representation of the input\n * @type String\n */\n\n turndown: function (input) {\n if (!canConvert(input)) {\n throw new TypeError(input + ' is not a string, or an element/document/fragment node.');\n }\n if (input === '') return '';\n var output = process.call(this, new RootNode(input, this.options));\n return postProcess.call(this, output);\n },\n /**\n * Add one or more plugins\n * @public\n * @param {Function|Array} plugin The plugin or array of plugins to add\n * @returns The Turndown instance for chaining\n * @type Object\n */\n\n use: function (plugin) {\n if (Array.isArray(plugin)) {\n for (var i = 0; i < plugin.length; i++) this.use(plugin[i]);\n } else if (typeof plugin === 'function') {\n plugin(this);\n } else {\n throw new TypeError('plugin must be a Function or an Array of Functions');\n }\n return this;\n },\n /**\n * Adds a rule\n * @public\n * @param {String} key The unique key of the rule\n * @param {Object} rule The rule\n * @returns The Turndown instance for chaining\n * @type Object\n */\n\n addRule: function (key, rule) {\n this.rules.add(key, rule);\n return this;\n },\n /**\n * Keep a node (as HTML) that matches the filter\n * @public\n * @param {String|Array|Function} filter The unique key of the rule\n * @returns The Turndown instance for chaining\n * @type Object\n */\n\n keep: function (filter) {\n this.rules.keep(filter);\n return this;\n },\n /**\n * Remove a node that matches the filter\n * @public\n * @param {String|Array|Function} filter The unique key of the rule\n * @returns The Turndown instance for chaining\n * @type Object\n */\n\n remove: function (filter) {\n this.rules.remove(filter);\n return this;\n },\n /**\n * Escapes Markdown syntax\n * @public\n * @param {String} string The string to escape\n * @returns A string with Markdown syntax escaped\n * @type String\n */\n\n escape: function (string) {\n return escapeMarkdown(string);\n }\n};\n\n/**\n * Reduces a DOM node down to its Markdown string equivalent\n * @private\n * @param {HTMLElement} parentNode The node to convert\n * @returns A Markdown representation of the node\n * @type String\n */\n\nfunction process(parentNode) {\n var self = this;\n return reduce.call(parentNode.childNodes, function (output, node) {\n node = new Node(node, self.options);\n var replacement = '';\n if (node.nodeType === 3) {\n replacement = node.isCode ? node.nodeValue : self.escape(node.nodeValue);\n } else if (node.nodeType === 1) {\n replacement = replacementForNode.call(self, node);\n }\n return join(output, replacement);\n }, '');\n}\n\n/**\n * Appends strings as each rule requires and trims the output\n * @private\n * @param {String} output The conversion output\n * @returns A trimmed version of the ouput\n * @type String\n */\n\nfunction postProcess(output) {\n var self = this;\n this.rules.forEach(function (rule) {\n if (typeof rule.append === 'function') {\n output = join(output, rule.append(self.options));\n }\n });\n return output.replace(/^[\\t\\r\\n]+/, '').replace(/[\\t\\r\\n\\s]+$/, '');\n}\n\n/**\n * Converts an element node to its Markdown equivalent\n * @private\n * @param {HTMLElement} node The node to convert\n * @returns A Markdown representation of the node\n * @type String\n */\n\nfunction replacementForNode(node) {\n var rule = this.rules.forNode(node);\n var content = process.call(this, node);\n var whitespace = node.flankingWhitespace;\n if (whitespace.leading || whitespace.trailing) content = content.trim();\n return whitespace.leading + rule.replacement(content, node, this.options) + whitespace.trailing;\n}\n\n/**\n * Joins replacement to the current output with appropriate number of new lines\n * @private\n * @param {String} output The current conversion output\n * @param {String} replacement The string to append to the output\n * @returns Joined output\n * @type String\n */\n\nfunction join(output, replacement) {\n var s1 = trimTrailingNewlines(output);\n var s2 = trimLeadingNewlines(replacement);\n var nls = Math.max(output.length - s1.length, replacement.length - s2.length);\n var separator = '\\n\\n'.substring(0, nls);\n return s1 + separator + s2;\n}\n\n/**\n * Determines whether an input can be converted\n * @private\n * @param {String|HTMLElement} input Describe this parameter\n * @returns Describe what it returns\n * @type String|Object|Array|Boolean|Number\n */\n\nfunction canConvert(input) {\n return input != null && (typeof input === 'string' || input.nodeType && (input.nodeType === 1 || input.nodeType === 9 || input.nodeType === 11));\n}\n\nexport { TurndownService as default };\n","/**\n * @typedef {import('mdast').Nodes} Nodes\n *\n * @typedef Options\n * Configuration (optional).\n * @property {boolean | null | undefined} [includeImageAlt=true]\n * Whether to use `alt` for `image`s (default: `true`).\n * @property {boolean | null | undefined} [includeHtml=true]\n * Whether to use `value` of HTML (default: `true`).\n */\n\n/** @type {Options} */\nconst emptyOptions = {}\n\n/**\n * Get the text content of a node or list of nodes.\n *\n * Prefers the node’s plain-text fields, otherwise serializes its children,\n * and if the given value is an array, serialize the nodes in it.\n *\n * @param {unknown} [value]\n * Thing to serialize, typically `Node`.\n * @param {Options | null | undefined} [options]\n * Configuration (optional).\n * @returns {string}\n * Serialized `value`.\n */\nexport function toString(value, options) {\n const settings = options || emptyOptions\n const includeImageAlt =\n typeof settings.includeImageAlt === 'boolean'\n ? settings.includeImageAlt\n : true\n const includeHtml =\n typeof settings.includeHtml === 'boolean' ? settings.includeHtml : true\n\n return one(value, includeImageAlt, includeHtml)\n}\n\n/**\n * One node or several nodes.\n *\n * @param {unknown} value\n * Thing to serialize.\n * @param {boolean} includeImageAlt\n * Include image `alt`s.\n * @param {boolean} includeHtml\n * Include HTML.\n * @returns {string}\n * Serialized node.\n */\nfunction one(value, includeImageAlt, includeHtml) {\n if (node(value)) {\n if ('value' in value) {\n return value.type === 'html' && !includeHtml ? '' : value.value\n }\n\n if (includeImageAlt && 'alt' in value && value.alt) {\n return value.alt\n }\n\n if ('children' in value) {\n return all(value.children, includeImageAlt, includeHtml)\n }\n }\n\n if (Array.isArray(value)) {\n return all(value, includeImageAlt, includeHtml)\n }\n\n return ''\n}\n\n/**\n * Serialize a list of nodes.\n *\n * @param {Array<unknown>} values\n * Thing to serialize.\n * @param {boolean} includeImageAlt\n * Include image `alt`s.\n * @param {boolean} includeHtml\n * Include HTML.\n * @returns {string}\n * Serialized nodes.\n */\nfunction all(values, includeImageAlt, includeHtml) {\n /** @type {Array<string>} */\n const result = []\n let index = -1\n\n while (++index < values.length) {\n result[index] = one(values[index], includeImageAlt, includeHtml)\n }\n\n return result.join('')\n}\n\n/**\n * Check if `value` looks like a node.\n *\n * @param {unknown} value\n * Thing.\n * @returns {value is Nodes}\n * Whether `value` is a node.\n */\nfunction node(value) {\n return Boolean(value && typeof value === 'object')\n}\n","import { decodeNamedCharacterReference } from 'decode-named-character-reference';\nimport { decodeNumericCharacterReference } from 'micromark-util-decode-numeric-character-reference';\nconst characterEscapeOrReference = /\\\\([!-/:-@[-`{-~])|&(#(?:\\d{1,7}|x[\\da-f]{1,6})|[\\da-z]{1,31});/gi;\n\n/**\n * Decode markdown strings (which occur in places such as fenced code info\n * strings, destinations, labels, and titles).\n *\n * The “string” content type allows character escapes and -references.\n * This decodes those.\n *\n * @param {string} value\n * Value to decode.\n * @returns {string}\n * Decoded value.\n */\nexport function decodeString(value) {\n return value.replace(characterEscapeOrReference, decode);\n}\n\n/**\n * @param {string} $0\n * Match.\n * @param {string} $1\n * Character escape.\n * @param {string} $2\n * Character reference.\n * @returns {string}\n * Decoded value\n */\nfunction decode($0, $1, $2) {\n if ($1) {\n // Escape.\n return $1;\n }\n\n // Reference.\n const head = $2.charCodeAt(0);\n if (head === 35) {\n const head = $2.charCodeAt(1);\n const hex = head === 120 || head === 88;\n return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10);\n }\n return decodeNamedCharacterReference($2) || $0;\n}","/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Point} Point\n * @typedef {import('unist').Position} Position\n */\n\n/**\n * @typedef NodeLike\n * @property {string} type\n * @property {PositionLike | null | undefined} [position]\n *\n * @typedef PointLike\n * @property {number | null | undefined} [line]\n * @property {number | null | undefined} [column]\n * @property {number | null | undefined} [offset]\n *\n * @typedef PositionLike\n * @property {PointLike | null | undefined} [start]\n * @property {PointLike | null | undefined} [end]\n */\n\n/**\n * Serialize the positional info of a point, position (start and end points),\n * or node.\n *\n * @param {Node | NodeLike | Point | PointLike | Position | PositionLike | null | undefined} [value]\n * Node, position, or point.\n * @returns {string}\n * Pretty printed positional info of a node (`string`).\n *\n * In the format of a range `ls:cs-le:ce` (when given `node` or `position`)\n * or a point `l:c` (when given `point`), where `l` stands for line, `c` for\n * column, `s` for `start`, and `e` for end.\n * An empty string (`''`) is returned if the given value is neither `node`,\n * `position`, nor `point`.\n */\nexport function stringifyPosition(value) {\n // Nothing.\n if (!value || typeof value !== 'object') {\n return ''\n }\n\n // Node.\n if ('position' in value || 'type' in value) {\n return position(value.position)\n }\n\n // Position.\n if ('start' in value || 'end' in value) {\n return position(value)\n }\n\n // Point.\n if ('line' in value || 'column' in value) {\n return point(value)\n }\n\n // ?\n return ''\n}\n\n/**\n * @param {Point | PointLike | null | undefined} point\n * @returns {string}\n */\nfunction point(point) {\n return index(point && point.line) + ':' + index(point && point.column)\n}\n\n/**\n * @param {Position | PositionLike | null | undefined} pos\n * @returns {string}\n */\nfunction position(pos) {\n return point(pos && pos.start) + '-' + point(pos && pos.end)\n}\n\n/**\n * @param {number | null | undefined} value\n * @returns {number}\n */\nfunction index(value) {\n return value && typeof value === 'number' ? value : 1\n}\n","/**\n * @import {\n * Break,\n * Blockquote,\n * Code,\n * Definition,\n * Emphasis,\n * Heading,\n * Html,\n * Image,\n * InlineCode,\n * Link,\n * ListItem,\n * List,\n * Nodes,\n * Paragraph,\n * PhrasingContent,\n * ReferenceType,\n * Root,\n * Strong,\n * Text,\n * ThematicBreak\n * } from 'mdast'\n * @import {\n * Encoding,\n * Event,\n * Token,\n * Value\n * } from 'micromark-util-types'\n * @import {Point} from 'unist'\n * @import {\n * CompileContext,\n * CompileData,\n * Config,\n * Extension,\n * Handle,\n * OnEnterError,\n * Options\n * } from './types.js'\n */\n\nimport { toString } from 'mdast-util-to-string';\nimport { parse, postprocess, preprocess } from 'micromark';\nimport { decodeNumericCharacterReference } from 'micromark-util-decode-numeric-character-reference';\nimport { decodeString } from 'micromark-util-decode-string';\nimport { normalizeIdentifier } from 'micromark-util-normalize-identifier';\nimport { decodeNamedCharacterReference } from 'decode-named-character-reference';\nimport { stringifyPosition } from 'unist-util-stringify-position';\nconst own = {}.hasOwnProperty;\n\n/**\n * Turn markdown into a syntax tree.\n *\n * @overload\n * @param {Value} value\n * @param {Encoding | null | undefined} [encoding]\n * @param {Options | null | undefined} [options]\n * @returns {Root}\n *\n * @overload\n * @param {Value} value\n * @param {Options | null | undefined} [options]\n * @returns {Root}\n *\n * @param {Value} value\n * Markdown to parse.\n * @param {Encoding | Options | null | undefined} [encoding]\n * Character encoding for when `value` is `Buffer`.\n * @param {Options | null | undefined} [options]\n * Configuration.\n * @returns {Root}\n * mdast tree.\n */\nexport function fromMarkdown(value, encoding, options) {\n if (encoding && typeof encoding === 'object') {\n options = encoding;\n encoding = undefined;\n }\n return compiler(options)(postprocess(parse(options).document().write(preprocess()(value, encoding, true))));\n}\n\n/**\n * Note this compiler only understand complete buffering, not streaming.\n *\n * @param {Options | null | undefined} [options]\n */\nfunction compiler(options) {\n /** @type {Config} */\n const config = {\n transforms: [],\n canContainEols: ['emphasis', 'fragment', 'heading', 'paragraph', 'strong'],\n enter: {\n autolink: opener(link),\n autolinkProtocol: onenterdata,\n autolinkEmail: onenterdata,\n atxHeading: opener(heading),\n blockQuote: opener(blockQuote),\n characterEscape: onenterdata,\n characterReference: onenterdata,\n codeFenced: opener(codeFlow),\n codeFencedFenceInfo: buffer,\n codeFencedFenceMeta: buffer,\n codeIndented: opener(codeFlow, buffer),\n codeText: opener(codeText, buffer),\n codeTextData: onenterdata,\n data: onenterdata,\n codeFlowValue: onenterdata,\n definition: opener(definition),\n definitionDestinationString: buffer,\n definitionLabelString: buffer,\n definitionTitleString: buffer,\n emphasis: opener(emphasis),\n hardBreakEscape: opener(hardBreak),\n hardBreakTrailing: opener(hardBreak),\n htmlFlow: opener(html, buffer),\n htmlFlowData: onenterdata,\n htmlText: opener(html, buffer),\n htmlTextData: onenterdata,\n image: opener(image),\n label: buffer,\n link: opener(link),\n listItem: opener(listItem),\n listItemValue: onenterlistitemvalue,\n listOrdered: opener(list, onenterlistordered),\n listUnordered: opener(list),\n paragraph: opener(paragraph),\n reference: onenterreference,\n referenceString: buffer,\n resourceDestinationString: buffer,\n resourceTitleString: buffer,\n setextHeading: opener(heading),\n strong: opener(strong),\n thematicBreak: opener(thematicBreak)\n },\n exit: {\n atxHeading: closer(),\n atxHeadingSequence: onexitatxheadingsequence,\n autolink: closer(),\n autolinkEmail: onexitautolinkemail,\n autolinkProtocol: onexitautolinkprotocol,\n blockQuote: closer(),\n characterEscapeValue: onexitdata,\n characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker,\n characterReferenceMarkerNumeric: onexitcharacterreferencemarker,\n characterReferenceValue: onexitcharacterreferencevalue,\n characterReference: onexitcharacterreference,\n codeFenced: closer(onexitcodefenced),\n codeFencedFence: onexitcodefencedfence,\n codeFencedFenceInfo: onexitcodefencedfenceinfo,\n codeFencedFenceMeta: onexitcodefencedfencemeta,\n codeFlowValue: onexitdata,\n codeIndented: closer(onexitcodeindented),\n codeText: closer(onexitcodetext),\n codeTextData: onexitdata,\n data: onexitdata,\n definition: closer(),\n definitionDestinationString: onexitdefinitiondestinationstring,\n definitionLabelString: onexitdefinitionlabelstring,\n definitionTitleString: onexitdefinitiontitlestring,\n emphasis: closer(),\n hardBreakEscape: closer(onexithardbreak),\n hardBreakTrailing: closer(onexithardbreak),\n htmlFlow: closer(onexithtmlflow),\n htmlFlowData: onexitdata,\n htmlText: closer(onexithtmltext),\n htmlTextData: onexitdata,\n image: closer(onexitimage),\n label: onexitlabel,\n labelText: onexitlabeltext,\n lineEnding: onexitlineending,\n link: closer(onexitlink),\n listItem: closer(),\n listOrdered: closer(),\n listUnordered: closer(),\n paragraph: closer(),\n referenceString: onexitreferencestring,\n resourceDestinationString: onexitresourcedestinationstring,\n resourceTitleString: onexitresourcetitlestring,\n resource: onexitresource,\n setextHeading: closer(onexitsetextheading),\n setextHeadingLineSequence: onexitsetextheadinglinesequence,\n setextHeadingText: onexitsetextheadingtext,\n strong: closer(),\n thematicBreak: closer()\n }\n };\n configure(config, (options || {}).mdastExtensions || []);\n\n /** @type {CompileData} */\n const data = {};\n return compile;\n\n /**\n * Turn micromark events into an mdast tree.\n *\n * @param {Array<Event>} events\n * Events.\n * @returns {Root}\n * mdast tree.\n */\n function compile(events) {\n /** @type {Root} */\n let tree = {\n type: 'root',\n children: []\n };\n /** @type {Omit<CompileContext, 'sliceSerialize'>} */\n const context = {\n stack: [tree],\n tokenStack: [],\n config,\n enter,\n exit,\n buffer,\n resume,\n data\n };\n /** @type {Array<number>} */\n const listStack = [];\n let index = -1;\n while (++index < events.length) {\n // We preprocess lists to add `listItem` tokens, and to infer whether\n // items the list itself are spread out.\n if (events[index][1].type === \"listOrdered\" || events[index][1].type === \"listUnordered\") {\n if (events[index][0] === 'enter') {\n listStack.push(index);\n } else {\n const tail = listStack.pop();\n index = prepareList(events, tail, index);\n }\n }\n }\n index = -1;\n while (++index < events.length) {\n const handler = config[events[index][0]];\n if (own.call(handler, events[index][1].type)) {\n handler[events[index][1].type].call(Object.assign({\n sliceSerialize: events[index][2].sliceSerialize\n }, context), events[index][1]);\n }\n }\n\n // Handle tokens still being open.\n if (context.tokenStack.length > 0) {\n const tail = context.tokenStack[context.tokenStack.length - 1];\n const handler = tail[1] || defaultOnError;\n handler.call(context, undefined, tail[0]);\n }\n\n // Figure out `root` position.\n tree.position = {\n start: point(events.length > 0 ? events[0][1].start : {\n line: 1,\n column: 1,\n offset: 0\n }),\n end: point(events.length > 0 ? events[events.length - 2][1].end : {\n line: 1,\n column: 1,\n offset: 0\n })\n };\n\n // Call transforms.\n index = -1;\n while (++index < config.transforms.length) {\n tree = config.transforms[index](tree) || tree;\n }\n return tree;\n }\n\n /**\n * @param {Array<Event>} events\n * @param {number} start\n * @param {number} length\n * @returns {number}\n */\n function prepareList(events, start, length) {\n let index = start - 1;\n let containerBalance = -1;\n let listSpread = false;\n /** @type {Token | undefined} */\n let listItem;\n /** @type {number | undefined} */\n let lineIndex;\n /** @type {number | undefined} */\n let firstBlankLineIndex;\n /** @type {boolean | undefined} */\n let atMarker;\n while (++index <= length) {\n const event = events[index];\n switch (event[1].type) {\n case \"listUnordered\":\n case \"listOrdered\":\n case \"blockQuote\":\n {\n if (event[0] === 'enter') {\n containerBalance++;\n } else {\n containerBalance--;\n }\n atMarker = undefined;\n break;\n }\n case \"lineEndingBlank\":\n {\n if (event[0] === 'enter') {\n if (listItem && !atMarker && !containerBalance && !firstBlankLineIndex) {\n firstBlankLineIndex = index;\n }\n atMarker = undefined;\n }\n break;\n }\n case \"linePrefix\":\n case \"listItemValue\":\n case \"listItemMarker\":\n case \"listItemPrefix\":\n case \"listItemPrefixWhitespace\":\n {\n // Empty.\n\n break;\n }\n default:\n {\n atMarker = undefined;\n }\n }\n if (!containerBalance && event[0] === 'enter' && event[1].type === \"listItemPrefix\" || containerBalance === -1 && event[0] === 'exit' && (event[1].type === \"listUnordered\" || event[1].type === \"listOrdered\")) {\n if (listItem) {\n let tailIndex = index;\n lineIndex = undefined;\n while (tailIndex--) {\n const tailEvent = events[tailIndex];\n if (tailEvent[1].type === \"lineEnding\" || tailEvent[1].type === \"lineEndingBlank\") {\n if (tailEvent[0] === 'exit') continue;\n if (lineIndex) {\n events[lineIndex][1].type = \"lineEndingBlank\";\n listSpread = true;\n }\n tailEvent[1].type = \"lineEnding\";\n lineIndex = tailIndex;\n } else if (tailEvent[1].type === \"linePrefix\" || tailEvent[1].type === \"blockQuotePrefix\" || tailEvent[1].type === \"blockQuotePrefixWhitespace\" || tailEvent[1].type === \"blockQuoteMarker\" || tailEvent[1].type === \"listItemIndent\") {\n // Empty\n } else {\n break;\n }\n }\n if (firstBlankLineIndex && (!lineIndex || firstBlankLineIndex < lineIndex)) {\n listItem._spread = true;\n }\n\n // Fix position.\n listItem.end = Object.assign({}, lineIndex ? events[lineIndex][1].start : event[1].end);\n events.splice(lineIndex || index, 0, ['exit', listItem, event[2]]);\n index++;\n length++;\n }\n\n // Create a new list item.\n if (event[1].type === \"listItemPrefix\") {\n /** @type {Token} */\n const item = {\n type: 'listItem',\n _spread: false,\n start: Object.assign({}, event[1].start),\n // @ts-expect-error: we’ll add `end` in a second.\n end: undefined\n };\n listItem = item;\n events.splice(index, 0, ['enter', item, event[2]]);\n index++;\n length++;\n firstBlankLineIndex = undefined;\n atMarker = true;\n }\n }\n }\n events[start][1]._spread = listSpread;\n return length;\n }\n\n /**\n * Create an opener handle.\n *\n * @param {(token: Token) => Nodes} create\n * Create a node.\n * @param {Handle | undefined} [and]\n * Optional function to also run.\n * @returns {Handle}\n * Handle.\n */\n function opener(create, and) {\n return open;\n\n /**\n * @this {CompileContext}\n * @param {Token} token\n * @returns {undefined}\n */\n function open(token) {\n enter.call(this, create(token), token);\n if (and) and.call(this, token);\n }\n }\n\n /**\n * @type {CompileContext['buffer']}\n */\n function buffer() {\n this.stack.push({\n type: 'fragment',\n children: []\n });\n }\n\n /**\n * @type {CompileContext['enter']}\n */\n function enter(node, token, errorHandler) {\n const parent = this.stack[this.stack.length - 1];\n /** @type {Array<Nodes>} */\n const siblings = parent.children;\n siblings.push(node);\n this.stack.push(node);\n this.tokenStack.push([token, errorHandler || undefined]);\n node.position = {\n start: point(token.start),\n // @ts-expect-error: `end` will be patched later.\n end: undefined\n };\n }\n\n /**\n * Create a closer handle.\n *\n * @param {Handle | undefined} [and]\n * Optional function to also run.\n * @returns {Handle}\n * Handle.\n */\n function closer(and) {\n return close;\n\n /**\n * @this {CompileContext}\n * @param {Token} token\n * @returns {undefined}\n */\n function close(token) {\n if (and) and.call(this, token);\n exit.call(this, token);\n }\n }\n\n /**\n * @type {CompileContext['exit']}\n */\n function exit(token, onExitError) {\n const node = this.stack.pop();\n const open = this.tokenStack.pop();\n if (!open) {\n throw new Error('Cannot close `' + token.type + '` (' + stringifyPosition({\n start: token.start,\n end: token.end\n }) + '): it’s not open');\n } else if (open[0].type !== token.type) {\n if (onExitError) {\n onExitError.call(this, token, open[0]);\n } else {\n const handler = open[1] || defaultOnError;\n handler.call(this, token, open[0]);\n }\n }\n node.position.end = point(token.end);\n }\n\n /**\n * @type {CompileContext['resume']}\n */\n function resume() {\n return toString(this.stack.pop());\n }\n\n //\n // Handlers.\n //\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterlistordered() {\n this.data.expectingFirstListItemValue = true;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterlistitemvalue(token) {\n if (this.data.expectingFirstListItemValue) {\n const ancestor = this.stack[this.stack.length - 2];\n ancestor.start = Number.parseInt(this.sliceSerialize(token), 10);\n this.data.expectingFirstListItemValue = undefined;\n }\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefencedfenceinfo() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.lang = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefencedfencemeta() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.meta = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefencedfence() {\n // Exit if this is the closing fence.\n if (this.data.flowCodeInside) return;\n this.buffer();\n this.data.flowCodeInside = true;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefenced() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.value = data.replace(/^(\\r?\\n|\\r)|(\\r?\\n|\\r)$/g, '');\n this.data.flowCodeInside = undefined;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodeindented() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.value = data.replace(/(\\r?\\n|\\r)$/g, '');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitionlabelstring(token) {\n const label = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.label = label;\n node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitiontitlestring() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.title = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitiondestinationstring() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.url = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitatxheadingsequence(token) {\n const node = this.stack[this.stack.length - 1];\n if (!node.depth) {\n const depth = this.sliceSerialize(token).length;\n node.depth = depth;\n }\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheadingtext() {\n this.data.setextHeadingSlurpLineEnding = true;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheadinglinesequence(token) {\n const node = this.stack[this.stack.length - 1];\n node.depth = this.sliceSerialize(token).codePointAt(0) === 61 ? 1 : 2;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheading() {\n this.data.setextHeadingSlurpLineEnding = undefined;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onenterdata(token) {\n const node = this.stack[this.stack.length - 1];\n /** @type {Array<Nodes>} */\n const siblings = node.children;\n let tail = siblings[siblings.length - 1];\n if (!tail || tail.type !== 'text') {\n // Add a new text node.\n tail = text();\n tail.position = {\n start: point(token.start),\n // @ts-expect-error: we’ll add `end` later.\n end: undefined\n };\n siblings.push(tail);\n }\n this.stack.push(tail);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitdata(token) {\n const tail = this.stack.pop();\n tail.value += this.sliceSerialize(token);\n tail.position.end = point(token.end);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitlineending(token) {\n const context = this.stack[this.stack.length - 1];\n // If we’re at a hard break, include the line ending in there.\n if (this.data.atHardBreak) {\n const tail = context.children[context.children.length - 1];\n tail.position.end = point(token.end);\n this.data.atHardBreak = undefined;\n return;\n }\n if (!this.data.setextHeadingSlurpLineEnding && config.canContainEols.includes(context.type)) {\n onenterdata.call(this, token);\n onexitdata.call(this, token);\n }\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexithardbreak() {\n this.data.atHardBreak = true;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexithtmlflow() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.value = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexithtmltext() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.value = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitcodetext() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.value = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitlink() {\n const node = this.stack[this.stack.length - 1];\n // Note: there are also `identifier` and `label` fields on this link node!\n // These are used / cleaned here.\n\n // To do: clean.\n if (this.data.inReference) {\n /** @type {ReferenceType} */\n const referenceType = this.data.referenceType || 'shortcut';\n node.type += 'Reference';\n // @ts-expect-error: mutate.\n node.referenceType = referenceType;\n // @ts-expect-error: mutate.\n delete node.url;\n delete node.title;\n } else {\n // @ts-expect-error: mutate.\n delete node.identifier;\n // @ts-expect-error: mutate.\n delete node.label;\n }\n this.data.referenceType = undefined;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitimage() {\n const node = this.stack[this.stack.length - 1];\n // Note: there are also `identifier` and `label` fields on this link node!\n // These are used / cleaned here.\n\n // To do: clean.\n if (this.data.inReference) {\n /** @type {ReferenceType} */\n const referenceType = this.data.referenceType || 'shortcut';\n node.type += 'Reference';\n // @ts-expect-error: mutate.\n node.referenceType = referenceType;\n // @ts-expect-error: mutate.\n delete node.url;\n delete node.title;\n } else {\n // @ts-expect-error: mutate.\n delete node.identifier;\n // @ts-expect-error: mutate.\n delete node.label;\n }\n this.data.referenceType = undefined;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitlabeltext(token) {\n const string = this.sliceSerialize(token);\n const ancestor = this.stack[this.stack.length - 2];\n // @ts-expect-error: stash this on the node, as it might become a reference\n // later.\n ancestor.label = decodeString(string);\n // @ts-expect-error: same as above.\n ancestor.identifier = normalizeIdentifier(string).toLowerCase();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitlabel() {\n const fragment = this.stack[this.stack.length - 1];\n const value = this.resume();\n const node = this.stack[this.stack.length - 1];\n // Assume a reference.\n this.data.inReference = true;\n if (node.type === 'link') {\n /** @type {Array<PhrasingContent>} */\n const children = fragment.children;\n node.children = children;\n } else {\n node.alt = value;\n }\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitresourcedestinationstring() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.url = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitresourcetitlestring() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.title = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitresource() {\n this.data.inReference = undefined;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onenterreference() {\n this.data.referenceType = 'collapsed';\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitreferencestring(token) {\n const label = this.resume();\n const node = this.stack[this.stack.length - 1];\n // @ts-expect-error: stash this on the node, as it might become a reference\n // later.\n node.label = label;\n // @ts-expect-error: same as above.\n node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();\n this.data.referenceType = 'full';\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitcharacterreferencemarker(token) {\n this.data.characterReferenceType = token.type;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcharacterreferencevalue(token) {\n const data = this.sliceSerialize(token);\n const type = this.data.characterReferenceType;\n /** @type {string} */\n let value;\n if (type) {\n value = decodeNumericCharacterReference(data, type === \"characterReferenceMarkerNumeric\" ? 10 : 16);\n this.data.characterReferenceType = undefined;\n } else {\n const result = decodeNamedCharacterReference(data);\n value = result;\n }\n const tail = this.stack[this.stack.length - 1];\n tail.value += value;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcharacterreference(token) {\n const tail = this.stack.pop();\n tail.position.end = point(token.end);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitautolinkprotocol(token) {\n onexitdata.call(this, token);\n const node = this.stack[this.stack.length - 1];\n node.url = this.sliceSerialize(token);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitautolinkemail(token) {\n onexitdata.call(this, token);\n const node = this.stack[this.stack.length - 1];\n node.url = 'mailto:' + this.sliceSerialize(token);\n }\n\n //\n // Creaters.\n //\n\n /** @returns {Blockquote} */\n function blockQuote() {\n return {\n type: 'blockquote',\n children: []\n };\n }\n\n /** @returns {Code} */\n function codeFlow() {\n return {\n type: 'code',\n lang: null,\n meta: null,\n value: ''\n };\n }\n\n /** @returns {InlineCode} */\n function codeText() {\n return {\n type: 'inlineCode',\n value: ''\n };\n }\n\n /** @returns {Definition} */\n function definition() {\n return {\n type: 'definition',\n identifier: '',\n label: null,\n title: null,\n url: ''\n };\n }\n\n /** @returns {Emphasis} */\n function emphasis() {\n return {\n type: 'emphasis',\n children: []\n };\n }\n\n /** @returns {Heading} */\n function heading() {\n return {\n type: 'heading',\n // @ts-expect-error `depth` will be set later.\n depth: 0,\n children: []\n };\n }\n\n /** @returns {Break} */\n function hardBreak() {\n return {\n type: 'break'\n };\n }\n\n /** @returns {Html} */\n function html() {\n return {\n type: 'html',\n value: ''\n };\n }\n\n /** @returns {Image} */\n function image() {\n return {\n type: 'image',\n title: null,\n url: '',\n alt: null\n };\n }\n\n /** @returns {Link} */\n function link() {\n return {\n type: 'link',\n title: null,\n url: '',\n children: []\n };\n }\n\n /**\n * @param {Token} token\n * @returns {List}\n */\n function list(token) {\n return {\n type: 'list',\n ordered: token.type === 'listOrdered',\n start: null,\n spread: token._spread,\n children: []\n };\n }\n\n /**\n * @param {Token} token\n * @returns {ListItem}\n */\n function listItem(token) {\n return {\n type: 'listItem',\n spread: token._spread,\n checked: null,\n children: []\n };\n }\n\n /** @returns {Paragraph} */\n function paragraph() {\n return {\n type: 'paragraph',\n children: []\n };\n }\n\n /** @returns {Strong} */\n function strong() {\n return {\n type: 'strong',\n children: []\n };\n }\n\n /** @returns {Text} */\n function text() {\n return {\n type: 'text',\n value: ''\n };\n }\n\n /** @returns {ThematicBreak} */\n function thematicBreak() {\n return {\n type: 'thematicBreak'\n };\n }\n}\n\n/**\n * Copy a point-like value.\n *\n * @param {Point} d\n * Point-like value.\n * @returns {Point}\n * unist point.\n */\nfunction point(d) {\n return {\n line: d.line,\n column: d.column,\n offset: d.offset\n };\n}\n\n/**\n * @param {Config} combined\n * @param {Array<Array<Extension> | Extension>} extensions\n * @returns {undefined}\n */\nfunction configure(combined, extensions) {\n let index = -1;\n while (++index < extensions.length) {\n const value = extensions[index];\n if (Array.isArray(value)) {\n configure(combined, value);\n } else {\n extension(combined, value);\n }\n }\n}\n\n/**\n * @param {Config} combined\n * @param {Extension} extension\n * @returns {undefined}\n */\nfunction extension(combined, extension) {\n /** @type {keyof Extension} */\n let key;\n for (key in extension) {\n if (own.call(extension, key)) {\n switch (key) {\n case 'canContainEols':\n {\n const right = extension[key];\n if (right) {\n combined[key].push(...right);\n }\n break;\n }\n case 'transforms':\n {\n const right = extension[key];\n if (right) {\n combined[key].push(...right);\n }\n break;\n }\n case 'enter':\n case 'exit':\n {\n const right = extension[key];\n if (right) {\n Object.assign(combined[key], right);\n }\n break;\n }\n // No default\n }\n }\n }\n}\n\n/** @type {OnEnterError} */\nfunction defaultOnError(left, right) {\n if (left) {\n throw new Error('Cannot close `' + left.type + '` (' + stringifyPosition({\n start: left.start,\n end: left.end\n }) + '): a different token (`' + right.type + '`, ' + stringifyPosition({\n start: right.start,\n end: right.end\n }) + ') is open');\n } else {\n throw new Error('Cannot close document, a token (`' + right.type + '`, ' + stringifyPosition({\n start: right.start,\n end: right.end\n }) + ') is still open');\n }\n}","/**\n * @typedef {import('mdast').Delete} Delete\n *\n * @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext\n * @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension\n * @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle\n *\n * @typedef {import('mdast-util-to-markdown').ConstructName} ConstructName\n * @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle\n * @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension\n */\n\n/**\n * List of constructs that occur in phrasing (paragraphs, headings), but cannot\n * contain strikethrough.\n * So they sort of cancel each other out.\n * Note: could use a better name.\n *\n * Note: keep in sync with: <https://github.com/syntax-tree/mdast-util-to-markdown/blob/8ce8dbf/lib/unsafe.js#L14>\n *\n * @type {Array<ConstructName>}\n */\nconst constructsWithoutStrikethrough = [\n 'autolink',\n 'destinationLiteral',\n 'destinationRaw',\n 'reference',\n 'titleQuote',\n 'titleApostrophe'\n]\n\nhandleDelete.peek = peekDelete\n\n/**\n * Create an extension for `mdast-util-from-markdown` to enable GFM\n * strikethrough in markdown.\n *\n * @returns {FromMarkdownExtension}\n * Extension for `mdast-util-from-markdown` to enable GFM strikethrough.\n */\nexport function gfmStrikethroughFromMarkdown() {\n return {\n canContainEols: ['delete'],\n enter: {strikethrough: enterStrikethrough},\n exit: {strikethrough: exitStrikethrough}\n }\n}\n\n/**\n * Create an extension for `mdast-util-to-markdown` to enable GFM\n * strikethrough in markdown.\n *\n * @returns {ToMarkdownExtension}\n * Extension for `mdast-util-to-markdown` to enable GFM strikethrough.\n */\nexport function gfmStrikethroughToMarkdown() {\n return {\n unsafe: [\n {\n character: '~',\n inConstruct: 'phrasing',\n notInConstruct: constructsWithoutStrikethrough\n }\n ],\n handlers: {delete: handleDelete}\n }\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterStrikethrough(token) {\n this.enter({type: 'delete', children: []}, token)\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitStrikethrough(token) {\n this.exit(token)\n}\n\n/**\n * @type {ToMarkdownHandle}\n * @param {Delete} node\n */\nfunction handleDelete(node, _, state, info) {\n const tracker = state.createTracker(info)\n const exit = state.enter('strikethrough')\n let value = tracker.move('~~')\n value += state.containerPhrasing(node, {\n ...tracker.current(),\n before: value,\n after: '~'\n })\n value += tracker.move('~~')\n exit()\n return value\n}\n\n/** @type {ToMarkdownHandle} */\nfunction peekDelete() {\n return '~'\n}\n","/**\n * @import {Node, Parent} from 'unist'\n */\n\n/**\n * @template Fn\n * @template Fallback\n * @typedef {Fn extends (value: any) => value is infer Thing ? Thing : Fallback} Predicate\n */\n\n/**\n * @callback Check\n * Check that an arbitrary value is a node.\n * @param {unknown} this\n * The given context.\n * @param {unknown} [node]\n * Anything (typically a node).\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {boolean}\n * Whether this is a node and passes a test.\n *\n * @typedef {Record<string, unknown> | Node} Props\n * Object to check for equivalence.\n *\n * Note: `Node` is included as it is common but is not indexable.\n *\n * @typedef {Array<Props | TestFunction | string> | ReadonlyArray<Props | TestFunction | string> | Props | TestFunction | string | null | undefined} Test\n * Check for an arbitrary node.\n *\n * @callback TestFunction\n * Check if a node passes a test.\n * @param {unknown} this\n * The given context.\n * @param {Node} node\n * A node.\n * @param {number | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | undefined} [parent]\n * The node’s parent.\n * @returns {boolean | undefined | void}\n * Whether this node passes the test.\n *\n * Note: `void` is included until TS sees no return as `undefined`.\n */\n\n/**\n * Check if `node` is a `Node` and whether it passes the given test.\n *\n * @param {unknown} node\n * Thing to check, typically `Node`.\n * @param {Test} test\n * A check for a specific node.\n * @param {number | null | undefined} index\n * The node’s position in its parent.\n * @param {Parent | null | undefined} parent\n * The node’s parent.\n * @param {unknown} context\n * Context object (`this`) to pass to `test` functions.\n * @returns {boolean}\n * Whether `node` is a node and passes a test.\n */\nexport const is =\n // Note: overloads in JSDoc can’t yet use different `@template`s.\n /**\n * @type {(\n * (<Condition extends ReadonlyArray<string>>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition[number]}) &\n * (<Condition extends Array<string>>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition[number]}) &\n * (<Condition extends string>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &\n * (<Condition extends Props>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &\n * (<Condition extends TestFunction>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &\n * ((node?: null | undefined) => false) &\n * ((node: unknown, test?: null | undefined, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &\n * ((node: unknown, test?: Test, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => boolean)\n * )}\n */\n (\n /**\n * @param {unknown} [node]\n * @param {Test} [test]\n * @param {number | null | undefined} [index]\n * @param {Parent | null | undefined} [parent]\n * @param {unknown} [context]\n * @returns {boolean}\n */\n // eslint-disable-next-line max-params\n function (node, test, index, parent, context) {\n const check = convert(test)\n\n if (\n index !== undefined &&\n index !== null &&\n (typeof index !== 'number' ||\n index < 0 ||\n index === Number.POSITIVE_INFINITY)\n ) {\n throw new Error('Expected positive finite index')\n }\n\n if (\n parent !== undefined &&\n parent !== null &&\n (!is(parent) || !parent.children)\n ) {\n throw new Error('Expected parent node')\n }\n\n if (\n (parent === undefined || parent === null) !==\n (index === undefined || index === null)\n ) {\n throw new Error('Expected both parent and index')\n }\n\n return looksLikeANode(node)\n ? check.call(context, node, index, parent)\n : false\n }\n )\n\n/**\n * Generate an assertion from a test.\n *\n * Useful if you’re going to test many nodes, for example when creating a\n * utility where something else passes a compatible test.\n *\n * The created function is a bit faster because it expects valid input only:\n * a `node`, `index`, and `parent`.\n *\n * @param {Test} test\n * * when nullish, checks if `node` is a `Node`.\n * * when `string`, works like passing `(node) => node.type === test`.\n * * when `function` checks if function passed the node is true.\n * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.\n * * when `array`, checks if any one of the subtests pass.\n * @returns {Check}\n * An assertion.\n */\nexport const convert =\n // Note: overloads in JSDoc can’t yet use different `@template`s.\n /**\n * @type {(\n * (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &\n * (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &\n * (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &\n * ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &\n * ((test?: Test) => Check)\n * )}\n */\n (\n /**\n * @param {Test} [test]\n * @returns {Check}\n */\n function (test) {\n if (test === null || test === undefined) {\n return ok\n }\n\n if (typeof test === 'function') {\n return castFactory(test)\n }\n\n if (typeof test === 'object') {\n return Array.isArray(test)\n ? anyFactory(test)\n : // Cast because `ReadonlyArray` goes into the above but `isArray`\n // narrows to `Array`.\n propertiesFactory(/** @type {Props} */ (test))\n }\n\n if (typeof test === 'string') {\n return typeFactory(test)\n }\n\n throw new Error('Expected function, string, or object as test')\n }\n )\n\n/**\n * @param {Array<Props | TestFunction | string>} tests\n * @returns {Check}\n */\nfunction anyFactory(tests) {\n /** @type {Array<Check>} */\n const checks = []\n let index = -1\n\n while (++index < tests.length) {\n checks[index] = convert(tests[index])\n }\n\n return castFactory(any)\n\n /**\n * @this {unknown}\n * @type {TestFunction}\n */\n function any(...parameters) {\n let index = -1\n\n while (++index < checks.length) {\n if (checks[index].apply(this, parameters)) return true\n }\n\n return false\n }\n}\n\n/**\n * Turn an object into a test for a node with a certain fields.\n *\n * @param {Props} check\n * @returns {Check}\n */\nfunction propertiesFactory(check) {\n const checkAsRecord = /** @type {Record<string, unknown>} */ (check)\n\n return castFactory(all)\n\n /**\n * @param {Node} node\n * @returns {boolean}\n */\n function all(node) {\n const nodeAsRecord = /** @type {Record<string, unknown>} */ (\n /** @type {unknown} */ (node)\n )\n\n /** @type {string} */\n let key\n\n for (key in check) {\n if (nodeAsRecord[key] !== checkAsRecord[key]) return false\n }\n\n return true\n }\n}\n\n/**\n * Turn a string into a test for a node with a certain type.\n *\n * @param {string} check\n * @returns {Check}\n */\nfunction typeFactory(check) {\n return castFactory(type)\n\n /**\n * @param {Node} node\n */\n function type(node) {\n return node && node.type === check\n }\n}\n\n/**\n * Turn a custom test into a test for a node that passes that test.\n *\n * @param {TestFunction} testFunction\n * @returns {Check}\n */\nfunction castFactory(testFunction) {\n return check\n\n /**\n * @this {unknown}\n * @type {Check}\n */\n function check(value, index, parent) {\n return Boolean(\n looksLikeANode(value) &&\n testFunction.call(\n this,\n value,\n typeof index === 'number' ? index : undefined,\n parent || undefined\n )\n )\n }\n}\n\nfunction ok() {\n return true\n}\n\n/**\n * @param {unknown} value\n * @returns {value is Node}\n */\nfunction looksLikeANode(value) {\n return value !== null && typeof value === 'object' && 'type' in value\n}\n","/**\n * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n/**\n * @typedef {(\n * Fn extends (value: any) => value is infer Thing\n * ? Thing\n * : Fallback\n * )} Predicate\n * Get the value of a type guard `Fn`.\n * @template Fn\n * Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n * Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n * Check extends null | undefined // No test.\n * ? Value\n * : Value extends {type: Check} // String (type) test.\n * ? Value\n * : Value extends Check // Partial test.\n * ? Value\n * : Check extends Function // Function test.\n * ? Predicate<Check, Value> extends Value\n * ? Predicate<Check, Value>\n * : never\n * : never // Some other test?\n * )} MatchesOne\n * Check whether a node matches a primitive check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n * Check extends ReadonlyArray<infer T>\n * ? MatchesOne<Value, T>\n * : Check extends Array<infer T>\n * ? MatchesOne<Value, T>\n * : MatchesOne<Value, Check>\n * )} Matches\n * Check whether a node matches a check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n * Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n * Increment a number in the type system.\n * @template {Uint} [I=0]\n * Index.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array<infer Children>}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Depth extends Max\n * ? never\n * :\n * | InternalParent<Node, Child>\n * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>\n * )} InternalAncestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {InternalAncestor<InclusiveDescendant<Tree>, Child>} Ancestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Tree extends UnistParent\n * ? Depth extends Max\n * ? Tree\n * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>\n * : Tree\n * )} InclusiveDescendant\n * Collect all (inclusive) descendants of `Tree`.\n *\n * > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n * > recurse without actually running into an infinite loop, which the\n * > previous version did.\n * >\n * > Practically, a max of `2` is typically enough assuming a `Root` is\n * > passed, but it doesn’t improve performance.\n * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n * > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n * Tree type.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {'skip' | boolean} Action\n * Union of the action types.\n *\n * @typedef {number} Index\n * Move to the sibling at `index` next (after node itself is completely\n * traversed).\n *\n * Useful if mutating the tree, such as removing the node the visitor is\n * currently on, or any of its previous siblings.\n * Results less than 0 or greater than or equal to `children.length` stop\n * traversing the parent.\n *\n * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple\n * List with one or two values, the first an action, the second an index.\n *\n * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult\n * Any value that can be returned from a visitor.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform the parent of node (the last of `ancestors`).\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of an ancestor still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Array<VisitedParents>} ancestors\n * Ancestors of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [VisitedParents=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @typedef {Visitor<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parents`.\n * @template {UnistNode} [Tree=UnistNode]\n * Tree type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {convert} from 'unist-util-is'\nimport {color} from 'unist-util-visit-parents/do-not-use-color'\n\n/** @type {Readonly<ActionTuple>} */\nconst empty = []\n\n/**\n * Continue traversing as normal.\n */\nexport const CONTINUE = true\n\n/**\n * Stop traversing immediately.\n */\nexport const EXIT = false\n\n/**\n * Do not traverse this node’s children.\n */\nexport const SKIP = 'skip'\n\n/**\n * Visit nodes, with ancestral information.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor<Tree, Check>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor<Tree>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Test} test\n * `unist-util-is`-compatible test\n * @param {Visitor | boolean | null | undefined} [visitor]\n * Handle each node.\n * @param {boolean | null | undefined} [reverse]\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visitParents(tree, test, visitor, reverse) {\n /** @type {Test} */\n let check\n\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n // @ts-expect-error no visitor given, so `visitor` is test.\n visitor = test\n } else {\n // @ts-expect-error visitor given, so `test` isn’t a visitor.\n check = test\n }\n\n const is = convert(check)\n const step = reverse ? -1 : 1\n\n factory(tree, undefined, [])()\n\n /**\n * @param {UnistNode} node\n * @param {number | undefined} index\n * @param {Array<UnistParent>} parents\n */\n function factory(node, index, parents) {\n const value = /** @type {Record<string, unknown>} */ (\n node && typeof node === 'object' ? node : {}\n )\n\n if (typeof value.type === 'string') {\n const name =\n // `hast`\n typeof value.tagName === 'string'\n ? value.tagName\n : // `xast`\n typeof value.name === 'string'\n ? value.name\n : undefined\n\n Object.defineProperty(visit, 'name', {\n value:\n 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'\n })\n }\n\n return visit\n\n function visit() {\n /** @type {Readonly<ActionTuple>} */\n let result = empty\n /** @type {Readonly<ActionTuple>} */\n let subresult\n /** @type {number} */\n let offset\n /** @type {Array<UnistParent>} */\n let grandparents\n\n if (!test || is(node, index, parents[parents.length - 1] || undefined)) {\n // @ts-expect-error: `visitor` is now a visitor.\n result = toResult(visitor(node, parents))\n\n if (result[0] === EXIT) {\n return result\n }\n }\n\n if ('children' in node && node.children) {\n const nodeAsParent = /** @type {UnistParent} */ (node)\n\n if (nodeAsParent.children && result[0] !== SKIP) {\n offset = (reverse ? nodeAsParent.children.length : -1) + step\n grandparents = parents.concat(nodeAsParent)\n\n while (offset > -1 && offset < nodeAsParent.children.length) {\n const child = nodeAsParent.children[offset]\n\n subresult = factory(child, offset, grandparents)()\n\n if (subresult[0] === EXIT) {\n return subresult\n }\n\n offset =\n typeof subresult[1] === 'number' ? subresult[1] : offset + step\n }\n }\n }\n\n return result\n }\n }\n}\n\n/**\n * Turn a return value into a clean result.\n *\n * @param {VisitorResult} value\n * Valid return values from visitors.\n * @returns {Readonly<ActionTuple>}\n * Clean result.\n */\nfunction toResult(value) {\n if (Array.isArray(value)) {\n return value\n }\n\n if (typeof value === 'number') {\n return [CONTINUE, value]\n }\n\n return value === null || value === undefined ? empty : [value]\n}\n","/**\n * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n * @import {VisitorResult} from 'unist-util-visit-parents'\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n// To do: use types from `unist-util-visit-parents` when it’s released.\n\n/**\n * @typedef {(\n * Fn extends (value: any) => value is infer Thing\n * ? Thing\n * : Fallback\n * )} Predicate\n * Get the value of a type guard `Fn`.\n * @template Fn\n * Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n * Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n * Check extends null | undefined // No test.\n * ? Value\n * : Value extends {type: Check} // String (type) test.\n * ? Value\n * : Value extends Check // Partial test.\n * ? Value\n * : Check extends Function // Function test.\n * ? Predicate<Check, Value> extends Value\n * ? Predicate<Check, Value>\n * : never\n * : never // Some other test?\n * )} MatchesOne\n * Check whether a node matches a primitive check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n * Check extends ReadonlyArray<any>\n * ? MatchesOne<Value, Check[number]>\n * : MatchesOne<Value, Check>\n * )} Matches\n * Check whether a node matches a check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n * Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n * Increment a number in the type system.\n * @template {Uint} [I=0]\n * Index.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array<infer Children>}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Depth extends Max\n * ? never\n * :\n * | InternalParent<Node, Child>\n * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>\n * )} InternalAncestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {(\n * Tree extends UnistParent\n * ? Depth extends Max\n * ? Tree\n * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>\n * : Tree\n * )} InclusiveDescendant\n * Collect all (inclusive) descendants of `Tree`.\n *\n * > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n * > recurse without actually running into an infinite loop, which the\n * > previous version did.\n * >\n * > Practically, a max of `2` is typically enough assuming a `Root` is\n * > passed, but it doesn’t improve performance.\n * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n * > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n * Tree type.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform `parent`.\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of `parent` still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends UnistNode ? number | undefined : never} index\n * Index of `node` in `parent`.\n * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent\n * Parent of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch\n * Build a typed `Visitor` function from a node and all possible parents.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Visited\n * Node type.\n * @template {UnistParent} Ancestor\n * Parent type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromMatch<\n * Matches<Descendant, Check>,\n * Extract<Descendant, UnistParent>\n * >\n * )} BuildVisitorFromDescendants\n * Build a typed `Visitor` function from a list of descendants and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Descendant\n * Node type.\n * @template {Test} Check\n * Test type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromDescendants<\n * InclusiveDescendant<Tree>,\n * Check\n * >\n * )} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} [Tree=UnistNode]\n * Node type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n\n/**\n * Visit nodes.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor<Tree, Check>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor<Tree>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Test} testOrVisitor\n * `unist-util-is`-compatible test (optional, omit to pass a visitor).\n * @param {Visitor | boolean | null | undefined} [visitorOrReverse]\n * Handle each node (when test is omitted, pass `reverse`).\n * @param {boolean | null | undefined} [maybeReverse=false]\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {\n /** @type {boolean | null | undefined} */\n let reverse\n /** @type {Test} */\n let test\n /** @type {Visitor} */\n let visitor\n\n if (\n typeof testOrVisitor === 'function' &&\n typeof visitorOrReverse !== 'function'\n ) {\n test = undefined\n visitor = testOrVisitor\n reverse = visitorOrReverse\n } else {\n // @ts-expect-error: assume the overload with test was given.\n test = testOrVisitor\n // @ts-expect-error: assume the overload with test was given.\n visitor = visitorOrReverse\n reverse = maybeReverse\n }\n\n visitParents(tree, test, overload, reverse)\n\n /**\n * @param {UnistNode} node\n * @param {Array<UnistParent>} parents\n */\n function overload(node, parents) {\n const parent = parents[parents.length - 1]\n const index = parent ? parent.children.indexOf(node) : undefined\n return visitor(node, index, parent)\n }\n}\n","import type { Decoration } from '@rcarls/rc-textarea';\n\nimport type { ActiveFormats, HeadingLevel } from './types.ts';\n\n\n/**\n * Replaces the language token on the opening fence of the code block containing\n * `selectionStart`. Returns the updated string, or `null` if the cursor is not\n * inside a fenced code block.\n *\n * @param value - Full source editor value.\n * @param selectionStart - Cursor offset used to locate the containing fence.\n * @param language - Language string to write (empty string removes the token).\n */\nexport function setCodeBlockLanguage(\n value: string,\n selectionStart: number,\n language: string,\n): string | null {\n const before = value.slice(0, selectionStart);\n const fencePattern = /^```[^\\n]*(?:\\n|$)/gm;\n let openingFence: RegExpExecArray | null = null;\n let fenceMatch: RegExpExecArray | null;\n\n while ((fenceMatch = fencePattern.exec(before)) !== null) {\n openingFence = openingFence === null ? fenceMatch : null;\n }\n\n if (openingFence === null) {\n return null;\n }\n\n const fenceStart = openingFence.index;\n const newlineIndex = openingFence[0].indexOf('\\n');\n const fenceEnd = fenceStart + (newlineIndex === -1 ? openingFence[0].length : newlineIndex + 1);\n\n return value.slice(0, fenceStart) + '```' + language + '\\n' + value.slice(fenceEnd);\n}\n\n\n/**\n * Derives active inline and block formats from the decoration array at a given\n * selection range in the markdown source editor. Used for toolbar state sync in\n * source mode.\n */\nexport function getFormatsFromDecorations(\n decorations: readonly Decoration[],\n start: number,\n end: number,\n): Omit<ActiveFormats, 'codeLanguage'> {\n const marks = decorations.filter(\n (d): d is Extract<Decoration, { type: 'mark' }> =>\n d.type === 'mark' && d.from <= start && d.to >= end,\n );\n\n const headingMark = marks.find((d) => d.className?.startsWith('rme-heading-'));\n const headingLevel = headingMark?.className?.replace('rme-heading-', '') as HeadingLevel | undefined;\n\n return {\n bold: marks.some((d) => d.bold),\n italic: marks.some((d) => d.italic),\n underline: marks.some((d) => d.className === 'rme-underline'),\n strikethrough: marks.some((d) => d.className === 'rme-strikethrough'),\n code: marks.some((d) => d.className === 'rme-code'),\n link: marks.some((d) => d.className === 'rme-link'),\n heading: headingLevel ?? null,\n blockquote: marks.some((d) => d.className === 'rme-blockquote'),\n bulletList: marks.some((d) => d.className === 'rme-list-bullet'),\n orderedList: marks.some((d) => d.className === 'rme-list-ordered'),\n codeBlock: marks.some((d) => d.className === 'rme-code-block'),\n };\n}\n","import { css } from 'lit';\n\nexport const rmeStyles = css`\n :host {\n position: relative;\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n }\n\n #rich-view {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n box-sizing: border-box;\n outline: none;\n /* Consumer themes via CSS custom properties */\n font-family: var(--rme-font-family, inherit);\n font-size: var(--rme-font-size, inherit);\n line-height: var(--rme-line-height, 1.6);\n padding: var(--rme-padding, 0.75em 1em);\n background: var(--rme-background, Canvas);\n color: var(--rme-color, CanvasText);\n border: var(--rme-border, 1px solid ButtonBorder);\n border-top: none;\n border-radius: var(--rme-border-radius, 0 0 4px 4px);\n }\n\n #rich-view:focus {\n outline: var(--rme-focus-outline, 2px solid Highlight);\n outline-offset: -2px;\n }\n\n #rich-view[hidden] {\n display: none;\n }\n\n /* Block-level spacing within the rich view */\n #rich-view > :first-child {\n margin-top: 0;\n }\n #rich-view > :last-child {\n margin-bottom: 0;\n }\n\n /* Source mode wrapper */\n #source-wrapper {\n flex: 1 1 auto;\n min-height: 0;\n display: flex;\n flex-direction: column;\n }\n\n #source-wrapper[hidden] {\n display: none;\n }\n\n #source-editor {\n flex: 1 1 auto;\n display: block;\n font-family: var(--rme-src-font-family, 'Cascadia Code', 'Fira Code', ui-monospace, monospace);\n --rc-textarea-border-radius: 0 0 4px 4px;\n --rc-textarea-border-top: none;\n }\n\n rc-editor-toolbar rc-toolbar {\n display: block;\n inline-size: 100%;\n --rc-toolbar-flex-wrap: wrap;\n --rc-toolbar-gap-inline: var(--rme-toolbar-gap, 1px);\n --rc-toolbar-padding-block: var(--rme-toolbar-padding, 4px);\n --rc-toolbar-padding-inline: var(--rme-toolbar-padding, 4px);\n --rc-toolbar-radius: var(--rme-toolbar-radius, 4px 4px 0 0);\n }\n\n rc-editor-toolbar rc-toolbar::part(root) {\n border: var(--rme-toolbar-border, 1px solid ButtonBorder);\n background: var(--rme-toolbar-background, Canvas);\n color: var(--rme-toolbar-color, CanvasText);\n }\n\n rc-editor-toolbar rc-button {\n --rc-button-bg: var(--rme-toolbar-button-background, transparent);\n --rc-button-color: var(--rme-toolbar-button-color, ButtonText);\n --rc-button-border: var(--rme-toolbar-button-border, 1px solid transparent);\n --rc-button-radius: var(--rme-toolbar-button-radius, 3px);\n --rc-button-block-size: var(--rme-toolbar-button-size, 2rem);\n --rc-button-icon-size: var(--rme-toolbar-button-size, 2rem);\n --rc-button-padding-block: 0;\n --rc-button-padding-inline: 0;\n --rc-button-font: inherit;\n --rc-button-state-layer-bg: currentColor;\n --rc-button-hover-state-layer-opacity: var(--rme-toolbar-button-hover-opacity, 0.08);\n --rc-button-focus-state-layer-opacity: var(--rme-toolbar-button-focus-opacity, 0.12);\n --rc-button-pressed-state-layer-opacity: var(--rme-toolbar-button-pressed-opacity, 0.12);\n }\n\n rc-editor-toolbar rc-button.toolbar-active {\n --rc-button-bg: var(--rme-toolbar-button-active-background, Highlight);\n --rc-button-color: var(--rme-toolbar-button-active-color, HighlightText);\n --rc-button-border: var(--rme-toolbar-button-active-border, 1px solid Highlight);\n }\n\n rc-editor-toolbar rc-button > button:focus-visible {\n outline: var(--rme-toolbar-focus-outline, 2px solid Highlight);\n outline-offset: var(--rme-toolbar-focus-outline-offset, 1px);\n }\n\n rc-editor-toolbar [data-rc-button-icon] svg {\n inline-size: 1.15em;\n block-size: 1.15em;\n flex-shrink: 0;\n }\n\n /* Heading select */\n rc-editor-toolbar rc-select {\n font-size: 0.8125em;\n --rc-select-padding-block: 0.25em;\n --rc-select-padding-inline: 0.35em;\n --rc-select-border: var(--rme-toolbar-select-border, 1px solid ButtonBorder);\n --rc-select-radius: var(--rme-toolbar-select-radius, 3px);\n }\n\n rc-editor-toolbar rc-select::part(trigger) {\n min-width: 0;\n background: var(--rme-toolbar-select-background, ButtonFace);\n color: var(--rme-toolbar-select-color, ButtonText);\n cursor: pointer;\n }\n\n rc-editor-toolbar rc-select::part(listbox) {\n border-radius: 3px;\n }\n\n rc-editor-toolbar rc-select.toolbar-active::part(trigger) {\n background: var(--rme-toolbar-select-active-background, Highlight);\n color: var(--rme-toolbar-select-active-color, HighlightText);\n border-color: var(--rme-toolbar-select-active-border-color, Highlight);\n }\n\n /* Code block language input */\n rc-editor-toolbar .lang-input {\n padding: 0.25em 0.5em;\n border: var(--rme-toolbar-input-border, 1px solid ButtonBorder);\n border-radius: var(--rme-toolbar-input-radius, 3px);\n background: var(--rme-toolbar-input-background, Field);\n color: var(--rme-toolbar-input-color, FieldText);\n font: inherit;\n font-size: 0.8125em;\n width: 8em;\n }\n\n rc-editor-toolbar .lang-input:focus {\n outline: var(--rme-toolbar-focus-outline, 2px solid Highlight);\n outline-offset: var(--rme-toolbar-focus-outline-offset, 1px);\n }\n\n rc-editor-toolbar .lang-input::placeholder {\n color: GrayText;\n }\n\n #rich-view a {\n cursor: pointer;\n text-decoration: underline;\n }\n\n #rich-view blockquote {\n margin: 0.5em 0;\n padding-left: 1em;\n border-left: 3px solid ButtonBorder;\n color: GrayText;\n }\n\n #rich-view pre {\n margin: 0.5em 0;\n padding: 0.65em 0.85em;\n background: Field;\n border: 1px solid ButtonBorder;\n border-radius: 4px;\n overflow-x: auto;\n }\n\n #rich-view pre code {\n font-family: 'Cascadia Code', 'Fira Code', ui-monospace, monospace;\n font-size: 0.875em;\n }\n\n #rich-view ul,\n #rich-view ol {\n margin: 0.5em 0;\n padding-left: 1.75em;\n }\n\n #rich-view li {\n margin: 0.2em 0;\n }\n\n .link-popover {\n position: absolute;\n z-index: 10;\n display: flex;\n align-items: center;\n gap: 2px;\n padding: 4px;\n background: Canvas;\n border: 1px solid ButtonBorder;\n border-radius: 4px;\n box-shadow: 0 2px 8px color-mix(in srgb, CanvasText 15%, transparent);\n }\n\n .link-popover-input {\n min-inline-size: 16em;\n padding: 0.25em 0.4em;\n border: 1px solid ButtonBorder;\n border-radius: 3px;\n background: Field;\n color: FieldText;\n font: inherit;\n font-size: 0.875em;\n }\n\n .link-popover-input:focus {\n outline: 2px solid Highlight;\n outline-offset: 1px;\n }\n\n .link-popover-btn {\n appearance: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-inline-size: 1.75rem;\n min-block-size: 1.75rem;\n padding: 0.15em;\n border: 1px solid transparent;\n border-radius: 3px;\n background: transparent;\n color: ButtonText;\n font: inherit;\n font-size: 0.875em;\n cursor: pointer;\n line-height: 1;\n }\n\n .link-popover-btn:hover:not(:disabled) {\n background: ButtonFace;\n border-color: ButtonBorder;\n }\n\n .link-popover-btn:focus-visible {\n outline: 2px solid Highlight;\n outline-offset: 1px;\n }\n\n .link-popover-btn:disabled {\n opacity: 0.4;\n cursor: default;\n }\n\n ::slotted(textarea) {\n display: none !important;\n }\n\n ::slotted(label) {\n display: block;\n margin-bottom: 0.25em;\n font-size: 0.875em;\n }\n`;\n","import { LitElement, html, nothing } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { micromark } from 'micromark';\nimport { gfmStrikethrough } from 'micromark-extension-gfm-strikethrough';\nimport TurndownService from 'turndown';\nimport { fromMarkdown } from 'mdast-util-from-markdown';\nimport { gfmStrikethroughFromMarkdown } from 'mdast-util-gfm-strikethrough';\nimport { visit } from 'unist-util-visit';\n\nimport type { RCTextarea, RCTextareaPluginAPI, DecorationInput } from '@rcarls/rc-textarea';\nimport type {\n ActiveFormats,\n EditorMode,\n EditorToolbarAction,\n EditorToolbarActionDetail,\n HeadingLevel,\n} from './types.ts';\nimport { getFormatsFromDecorations, setCodeBlockLanguage } from './formatting.ts';\n\nimport { rmeStyles } from './rc-markdown-editor.styles.ts';\n\n// Syntax-highlight stylesheet for the source editor, injected into rc-textarea's\n// shadow via adoptStyleSheet. CSS custom properties inherit through the shadow\n// boundary so consumers can override individual colors.\nconst _sourceHighlightSheet = new CSSStyleSheet();\n\n_sourceHighlightSheet.replaceSync(`\n .rme-heading-h1,\n .rme-heading-h2,\n .rme-heading-h3,\n .rme-heading-h4,\n .rme-heading-h5,\n .rme-heading-h6 {\n color: var(--rme-src-heading-color, light-dark(#1d6fc4, #82b4f5));\n }\n\n .rme-code,\n .rme-code-block {\n color: var(--rme-src-code-color, light-dark(#c94a1a, #f09060));\n }\n\n .rme-link {\n color: var(--rme-src-link-color, light-dark(#0370b0, #60b8e8));\n }\n\n .rme-blockquote {\n color: var(--rme-src-blockquote-color, light-dark(#2d7a42, #70b880));\n }\n\n .rme-list-bullet,\n .rme-list-ordered {\n color: var(--rme-src-list-color, light-dark(#7a5c0a, #d4ac48));\n }\n\n .rme-strikethrough {\n text-decoration: line-through;\n color: var(--rme-src-dim-color, GrayText);\n }\n\n .rme-underline {\n text-decoration: underline;\n }\n`);\n\n// preserves <u> underline passthrough; renders ~~text~~ as <del>\nconst MICROMARK_OPTIONS = {\n allowDangerousHtml: true,\n extensions: [gfmStrikethrough()],\n};\n\nconst MDAST_OPTIONS = {\n extensions: [gfmStrikethrough()],\n mdastExtensions: [gfmStrikethroughFromMarkdown()],\n};\n\nconst SAFE_RICH_ELEMENTS = new Set([\n 'A',\n 'BLOCKQUOTE',\n 'BR',\n 'CODE',\n 'DEL',\n 'EM',\n 'H1',\n 'H2',\n 'H3',\n 'H4',\n 'H5',\n 'H6',\n 'HR',\n 'LI',\n 'OL',\n 'P',\n 'PRE',\n 'S',\n 'STRONG',\n 'U',\n 'UL',\n]);\n\nfunction isSafeLinkHref(href: string): boolean {\n const trimmed = href.trim();\n\n if (/^(?:#|\\/|\\.\\/|\\.\\.\\/)/.test(trimmed)) {\n return true;\n }\n\n try {\n const url = new URL(trimmed, document.baseURI);\n\n return url.protocol === 'http:' || url.protocol === 'https:' || url.protocol === 'mailto:';\n } catch {\n return false;\n }\n}\n\nfunction sanitizeRichMarkup(markup: string): string {\n const doc = new DOMParser().parseFromString(markup, 'text/html');\n\n for (const element of [...doc.body.querySelectorAll('*')]) {\n if (!SAFE_RICH_ELEMENTS.has(element.tagName)) {\n element.replaceWith(doc.createTextNode(element.textContent ?? ''));\n\n continue;\n }\n\n for (const attribute of [...element.attributes]) {\n const keepAttribute =\n (element.tagName === 'A' && attribute.name === 'href' && isSafeLinkHref(attribute.value)) ||\n (element.tagName === 'A' && attribute.name === 'title') ||\n (element.tagName === 'PRE' && attribute.name === 'data-lang');\n\n if (!keepAttribute) {\n element.removeAttribute(attribute.name);\n }\n }\n }\n\n return doc.body.innerHTML;\n}\n\nconst _turndown = new TurndownService({\n headingStyle: 'atx',\n bulletListMarker: '-',\n codeBlockStyle: 'fenced',\n fence: '```',\n emDelimiter: '*',\n strongDelimiter: '**',\n});\n\n_turndown.addRule('inlineCode', {\n filter: (node) => node.nodeName === 'CODE' && node.parentElement?.nodeName !== 'PRE',\n replacement: (content) => '`' + content + '`',\n});\n\n// Underline: preserve <u> as HTML (no markdown equivalent)\n_turndown.addRule('underline', {\n filter: ['u'],\n replacement: (content) => '<u>' + content + '</u>',\n});\n\n_turndown.addRule('strikethrough', {\n filter: (node) => ['S', 'DEL', 'STRIKE'].includes(node.nodeName),\n replacement: (content) => '~~' + content + '~~',\n});\n\n// Code blocks with language: read data-lang from <pre>, emit fenced block\n_turndown.addRule('codeBlockWithLang', {\n filter: (node) => node.nodeName === 'PRE' && !!node.querySelector('code'),\n replacement: (_content, node) => {\n const $pre = node as HTMLElement;\n const $code = $pre.querySelector('code');\n const lang = $pre.dataset['lang'] ?? '';\n\n return '\\n\\n```' + lang + '\\n' + ($code?.textContent ?? '') + '\\n```\\n\\n';\n },\n});\n\ntype PartialDecoration = Partial<Omit<DecorationInput, 'type' | 'from' | 'to'>>;\n\nconst DECORATION_MAP: Record<string, PartialDecoration> = {\n // className applied per depth in _setupSourcePlugin, not here\n heading: { bold: true },\n\n emphasis: { italic: true },\n strong: { bold: true },\n inlineCode: { className: 'rme-code' },\n link: { underline: 'solid', className: 'rme-link' },\n blockquote: { className: 'rme-blockquote' },\n\n // fenced code block (AST node.type === 'code')\n code: { className: 'rme-code-block' },\n\n // GFM ~~text~~ (AST node.type === 'delete')\n delete: { className: 'rme-strikethrough' },\n\n // list and html (underline) nodes are handled dynamically in _setupSourcePlugin\n};\n\n/**\n * Rich/source Markdown editor with a formatting toolbar, backed by rc-textarea.\n *\n * - **Rich mode (default)**: A `contenteditable` div shows micromark-rendered\n * HTML. DOM mutations are converted back to markdown via turndown and\n * written to the backing `<textarea>` for form participation.\n * - **Source mode**: An `<rc-textarea>` instance shows the markdown source\n * with live decorations. Toggle via `source-mode` attribute or Ctrl+Shift+S.\n *\n * Consumer markup follows the same progressive-enhancement contract as\n * `<rc-textarea>`:\n *\n * ```html\n * <rc-markdown-editor>\n * <label for=\"body\">Content</label>\n * <textarea id=\"body\" name=\"body\"></textarea>\n * </rc-markdown-editor>\n * ```\n *\n * @see {@link https://richardcarls.github.io/rc-webcomponents/components/rc-markdown-editor rc-markdown-editor docs}\n *\n * @slot - Accepts a native `<textarea>` element (and optional `<label>`) for form wiring.\n *\n * @fires rc-change - Value changed. Detail: `{ value: string }`.\n * @fires rc-mode-change - Mode toggled. Detail: `{ mode: EditorMode }`.\n * @fires rc-formatting-change - Active formats at cursor changed. Detail: `ActiveFormats`.\n *\n * @csspart toolbar - The `<rc-editor-toolbar>` element.\n * @csspart rich-view - The contenteditable rich-text view.\n *\n * @attr toolbar - Show the formatting toolbar.\n * @attr source-mode - Controlled: show the markdown source editor.\n * @attr default-source-mode - Uncontrolled initial source-mode state.\n * @attr read-only - Make the editor read-only.\n * @attr value - Current Markdown value.\n * @attr default-value - Initial uncontrolled Markdown value.\n *\n * @cssprop [--rme-font-family=inherit] - Font family of the rich-text view\n * @cssprop [--rme-font-size=inherit] - Font size of the rich-text view\n * @cssprop [--rme-line-height=1.6] - Line height of the rich-text view\n * @cssprop [--rme-padding=0.75em 1em] - Padding inside the rich-text view\n * @cssprop [--rme-background=Canvas] - Background color of the rich-text view\n * @cssprop [--rme-color=CanvasText] - Text color of the rich-text view\n * @cssprop [--rme-border=1px solid ButtonBorder] - Border around the rich-text view\n * @cssprop [--rme-border-radius=0 0 4px 4px] - Border radius of the rich-text view\n * @cssprop [--rme-focus-outline=2px solid Highlight] - Focus ring outline on the rich-text view\n * @cssprop [--rme-src-font-family='Cascadia Code', 'Fira Code', ui-monospace, monospace] - Font family of the source editor\n * @cssprop [--rme-toolbar-gap=1px] - Gap between toolbar buttons\n * @cssprop [--rme-toolbar-button-size=2rem] - Minimum inline and block size of toolbar buttons\n * @cssprop [--rme-src-heading-color=light-dark(#1d6fc4, #82b4f5)] - Source-mode heading token color\n * @cssprop [--rme-src-code-color=light-dark(#c94a1a, #f09060)] - Source-mode inline/fenced code token color\n * @cssprop [--rme-src-link-color=light-dark(#0370b0, #60b8e8)] - Source-mode link token color\n * @cssprop [--rme-src-blockquote-color=light-dark(#2d7a42, #70b880)] - Source-mode blockquote token color\n * @cssprop [--rme-src-list-color=light-dark(#7a5c0a, #d4ac48)] - Source-mode list marker token color\n * @cssprop [--rme-src-dim-color=GrayText] - Source-mode strikethrough token color\n */\nexport class RcMarkdownEditor extends LitElement {\n static override styles = rmeStyles;\n\n private _value: string | undefined;\n private _defaultValue = '';\n private _valueInitialized = false;\n\n /** Initial uncontrolled Markdown value. */\n @property({ type: String, attribute: 'default-value' })\n get defaultValue(): string {\n return this._defaultValue;\n }\n\n set defaultValue(v: string) {\n this._defaultValue = v;\n\n if (!this._valueInitialized) {\n this.requestUpdate('defaultValue');\n }\n }\n\n /** Current Markdown value. Host writes are silent. */\n @property({ type: String })\n get value(): string {\n return this._value ?? this._defaultValue;\n }\n\n set value(v: string) {\n const old = this._value;\n\n this._value = v;\n this._valueInitialized = true;\n\n if (old !== v) {\n this._syncNativeTextarea();\n this.requestUpdate('value', old);\n }\n }\n\n private _sourceMode: boolean | undefined;\n private _defaultSourceMode = false;\n private _sourceModeInitialized = false;\n\n /** Initial uncontrolled source-mode state. */\n @property({ type: Boolean, attribute: 'default-source-mode' })\n get defaultSourceMode(): boolean {\n return this._defaultSourceMode;\n }\n\n set defaultSourceMode(v: boolean) {\n const old = this._defaultSourceMode;\n\n this._defaultSourceMode = v;\n\n if (!this._sourceModeInitialized && this._sourceMode === undefined) {\n this.requestUpdate('defaultSourceMode', old);\n }\n }\n\n /**\n * Controlled: show the markdown source editor instead of the rich view.\n * Host writes are silent; toolbar/keyboard toggles dispatch `rc-mode-change`.\n */\n @property({ type: Boolean, reflect: true, attribute: 'source-mode' })\n get sourceMode(): boolean {\n return this._sourceMode ?? this._defaultSourceMode;\n }\n\n set sourceMode(v: boolean) {\n const old = this._sourceMode;\n\n this._sourceMode = v;\n this._sourceModeInitialized = true;\n this.requestUpdate('sourceMode', old);\n }\n\n /** Show the formatting toolbar. */\n @property({ type: Boolean, reflect: true }) toolbar = true;\n\n /** Make the editor read-only. */\n @property({ type: Boolean, reflect: true, attribute: 'read-only' }) readOnly = false;\n\n @query('#rich-view')\n protected _$richView!: HTMLDivElement;\n\n @query('#source-editor')\n protected _$sourceEditor!: RCTextarea;\n\n @query('rc-editor-toolbar')\n protected _$toolbar?: HTMLElement;\n\n protected _observer: MutationObserver | null = null;\n protected _$savedRange: Range | null = null;\n protected _activeFormats: ActiveFormats = {};\n protected _syncTimer: ReturnType<typeof setTimeout> | null = null;\n protected _pluginApi: RCTextareaPluginAPI | null = null;\n protected _ignoreRichMutations = false;\n protected _richViewRendered = false;\n protected _cachedTree: ReturnType<typeof fromMarkdown> | null = null;\n protected _renderedMode: EditorMode | null = null;\n\n // Lit calls updated() before firstUpdated() on the first cycle — guard\n // against mode switches before the initial content setup is done.\n protected _firstUpdatedDone = false;\n\n @query('.link-popover')\n protected _$linkPopover?: HTMLDivElement;\n\n @query('.link-popover-input')\n protected _$linkPopoverInput?: HTMLInputElement;\n\n @state()\n protected _linkPopoverOpen = false;\n\n @state()\n protected _linkPopoverHref = '';\n\n override connectedCallback() {\n super.connectedCallback();\n document.addEventListener('selectionchange', this._onSelectionChange);\n document.addEventListener('click', this._onDocumentClick);\n this.addEventListener('keydown', this._onKeyDown);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n document.removeEventListener('selectionchange', this._onSelectionChange);\n document.removeEventListener('click', this._onDocumentClick);\n this.removeEventListener('keydown', this._onKeyDown);\n this._$richView?.removeEventListener('click', this._onRichViewClick);\n this._observer?.disconnect();\n\n if (this._syncTimer !== null) {\n clearTimeout(this._syncTimer);\n }\n }\n\n override firstUpdated() {\n // Read initial value from the slotted textarea BEFORE syncing it back.\n // Without this, _syncNativeTextarea() overwrites the authored content\n // with an empty string (the unset defaultValue).\n if (!this._valueInitialized) {\n const $textarea = this.querySelector<HTMLTextAreaElement>('textarea');\n\n if ($textarea?.value) {\n this._defaultValue = $textarea.value;\n }\n }\n\n this._observer = new MutationObserver(() => {\n if (!this._ignoreRichMutations) {\n this._scheduleMarkdownSync();\n }\n });\n\n this._observer.observe(this._$richView, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n\n this._$richView.addEventListener('click', this._onRichViewClick);\n this._setupSourcePlugin();\n\n // firstUpdated() handles the initial mode directly so updated() does not\n // switch modes on the first cycle.\n if (this.sourceMode) {\n this._$sourceEditor.value = this.value;\n } else {\n this._setRichViewContent(this.value);\n }\n\n this._renderedMode = this.sourceMode ? 'source' : 'rich';\n\n this._syncNativeTextarea();\n this._connectLabel();\n this._firstUpdatedDone = true;\n }\n\n override updated(changed: Map<string, unknown>) {\n if (changed.has('sourceMode') || changed.has('defaultSourceMode')) {\n if (this._firstUpdatedDone) {\n const nextMode: EditorMode = this.sourceMode ? 'source' : 'rich';\n\n if (nextMode !== this._renderedMode) {\n if (nextMode === 'source') {\n this._switchToSource();\n } else {\n this._switchToRich();\n }\n\n this._renderedMode = nextMode;\n }\n }\n\n // Keep source-button aria-pressed in sync for programmatic mode changes.\n this._pushToolbarState();\n }\n\n if (changed.has('value') && !this.sourceMode && this._richViewRendered) {\n this._setRichViewContent(this.value);\n }\n\n if (changed.has('_linkPopoverOpen') && this._linkPopoverOpen) {\n this._positionLinkPopover();\n this._$linkPopoverInput?.focus();\n this._$linkPopoverInput?.select();\n }\n }\n\n override render() {\n return html`\n <slot></slot>\n\n ${this.toolbar\n ? html`<rc-editor-toolbar\n part=\"toolbar\"\n @rc-toolbar-action=${this._onToolbarAction}\n ></rc-editor-toolbar>`\n : nothing}\n\n <div\n id=\"rich-view\"\n part=\"rich-view\"\n contenteditable=${this.readOnly ? 'false' : 'true'}\n role=\"textbox\"\n aria-multiline=\"true\"\n spellcheck=\"true\"\n ?hidden=${this.sourceMode}\n ></div>\n\n <div id=\"source-wrapper\" ?hidden=${!this.sourceMode}>\n <rc-textarea\n id=\"source-editor\"\n word-wrap\n ?read-only=${this.readOnly}\n @rc-change=${this._onSourceChange}\n ></rc-textarea>\n </div>\n\n ${this._linkPopoverOpen\n ? html`\n <div class=\"link-popover\" role=\"dialog\" aria-label=\"Link\">\n <input\n type=\"url\"\n class=\"link-popover-input\"\n .value=${this._linkPopoverHref}\n placeholder=\"https://\"\n aria-label=\"URL\"\n @input=${(e: Event) => {\n this._linkPopoverHref = (e.target as HTMLInputElement).value;\n }}\n @keydown=${this._onLinkPopoverKeyDown}\n />\n <button\n type=\"button\"\n class=\"link-popover-btn\"\n title=\"Apply (Enter)\"\n @click=${this._applyLink}\n >\n ↵\n </button>\n <button\n type=\"button\"\n class=\"link-popover-btn\"\n title=\"Open link\"\n ?disabled=${!this._linkPopoverHref}\n @click=${this._openLinkHref}\n >\n ↗\n </button>\n <button\n type=\"button\"\n class=\"link-popover-btn\"\n title=\"Remove link\"\n @click=${this._removeLink}\n >\n ✕\n </button>\n </div>\n `\n : nothing}\n `;\n }\n\n protected _setRichViewContent(markdown: string) {\n if (!this._$richView) {\n return;\n }\n\n this._ignoreRichMutations = true;\n this._$richView.innerHTML = this._renderMarkdown(markdown);\n this._ignoreRichMutations = false;\n this._richViewRendered = true;\n }\n\n protected _renderMarkdown(markdown: string): string {\n const markup = micromark(markdown, MICROMARK_OPTIONS);\n const tree = fromMarkdown(markdown, MDAST_OPTIONS);\n const langs: (string | null)[] = [];\n\n visit(tree, 'code', (node: { lang?: string | null }) => {\n langs.push(node.lang ?? null);\n });\n\n if (langs.length === 0) {\n return sanitizeRichMarkup(markup);\n }\n\n const doc = new DOMParser().parseFromString(markup, 'text/html');\n const $pres = doc.querySelectorAll('pre');\n\n langs.forEach((lang, i) => {\n if ($pres[i] && lang) {\n $pres[i].dataset['lang'] = lang;\n }\n });\n\n return sanitizeRichMarkup(doc.body.innerHTML);\n }\n\n protected _scheduleMarkdownSync() {\n if (this.sourceMode) {\n return;\n }\n\n if (this._syncTimer !== null) {\n clearTimeout(this._syncTimer);\n }\n\n this._syncTimer = setTimeout(() => {\n this._syncMarkdownFromRichView();\n this._syncTimer = null;\n }, 150);\n }\n\n protected _syncMarkdownFromRichView() {\n if (!this._$richView || this.sourceMode) {\n return;\n }\n\n const md = _turndown.turndown(this._$richView.innerHTML);\n\n if (md === this.value) {\n return;\n }\n\n this._value = md;\n this._syncNativeTextarea();\n this._dispatchChange(md);\n }\n\n protected _switchToSource() {\n if (!this._$richView || !this._$sourceEditor) {\n return;\n }\n\n // Flush any pending rich-view sync. _syncMarkdownFromRichView() guards on\n // `this.sourceMode`, which is already `true` by the time updated() calls\n // this method, so it would bail immediately — inline the flush instead.\n if (this._syncTimer !== null) {\n clearTimeout(this._syncTimer);\n this._syncTimer = null;\n\n const md = _turndown.turndown(this._$richView.innerHTML);\n\n if (md !== this.value) {\n this._value = md;\n this._syncNativeTextarea();\n this._dispatchChange(md);\n }\n }\n\n this._$sourceEditor.value = this.value;\n // Reset undo history so the first Ctrl+Z undoes to the pre-edit state\n // rather than to the end of a previous source-mode session.\n this._$sourceEditor.clearHistory();\n }\n\n protected _switchToRich() {\n if (!this._$richView) {\n return;\n }\n\n const md = this._$sourceEditor?.value ?? this.value;\n\n this._value = md;\n this._setRichViewContent(md);\n this._syncNativeTextarea();\n }\n\n protected _setupSourcePlugin() {\n this._$sourceEditor.usePlugin({\n mount: (api: RCTextareaPluginAPI) => {\n this._pluginApi = api;\n api.adoptStyleSheet(_sourceHighlightSheet);\n\n api.onCursorMove((start: number, end: number) => {\n if (!this.sourceMode) {\n return;\n }\n\n const formats = getFormatsFromDecorations(api.getDecorations(), start, end);\n const lang =\n formats.codeBlock && this._cachedTree\n ? this._getCodeBlockLanguage(this._cachedTree, start)\n : null;\n\n this._activeFormats = { ...formats, codeLanguage: lang };\n this._pushToolbarState();\n });\n },\n destroy: () => {\n this._pluginApi = null;\n this._cachedTree = null;\n },\n update: (value: string, api: RCTextareaPluginAPI) => {\n const tree = fromMarkdown(value, MDAST_OPTIONS);\n const decorations: DecorationInput[] = [];\n\n this._cachedTree = tree;\n\n visit(\n tree,\n (node: {\n type: string;\n depth?: number;\n ordered?: boolean | null;\n position?: { start: { offset?: number }; end: { offset?: number } };\n }) => {\n const from = node.position?.start.offset;\n const to = node.position?.end.offset;\n\n if (from === undefined || to === undefined) {\n return;\n }\n\n if (node.type === 'list') {\n decorations.push({\n type: 'mark',\n from,\n to,\n className: node.ordered ? 'rme-list-ordered' : 'rme-list-bullet',\n } as DecorationInput);\n\n return;\n }\n\n const style = DECORATION_MAP[node.type];\n\n if (!style) {\n return;\n }\n\n const dec: DecorationInput = { type: 'mark', from, to, ...style };\n\n if (node.type === 'heading' && node.depth) {\n dec.className = `rme-heading-h${node.depth}`;\n }\n\n decorations.push(dec);\n },\n );\n\n api.setDecorations(decorations);\n },\n });\n }\n\n protected _getCodeBlockLanguage(\n tree: ReturnType<typeof fromMarkdown>,\n offset: number,\n ): string | null {\n let lang: string | null = null;\n\n visit(\n tree,\n 'code',\n (node: {\n lang?: string | null;\n position?: { start: { offset?: number }; end: { offset?: number } };\n }) => {\n const from = node.position?.start.offset;\n const to = node.position?.end.offset;\n\n if (from !== undefined && to !== undefined && from <= offset && to >= offset) {\n lang = node.lang ?? '';\n }\n },\n );\n\n return lang;\n }\n\n protected _onSourceChange = (_e: Event) => {\n // The hidden source editor may emit while it initializes. Only the active\n // source surface is allowed to become the Markdown value; otherwise an\n // empty initialization event can erase controlled rich-view content.\n if (!this.sourceMode) {\n return;\n }\n\n const md = this._$sourceEditor?.value ?? '';\n\n if (md === this.value) {\n return;\n }\n\n this._value = md;\n this._syncNativeTextarea();\n this._dispatchChange(md);\n };\n\n protected _onToolbarAction = (e: CustomEvent<EditorToolbarActionDetail>) => {\n const { action, headingLevel, codeLanguage } = e.detail;\n\n if (action === 'source') {\n const nextSourceMode = !this.sourceMode;\n\n this.sourceMode = nextSourceMode;\n this._dispatchModeChange(nextSourceMode ? 'source' : 'rich');\n\n return;\n }\n\n if (action === 'code-block-language') {\n if (this.sourceMode) {\n this._setSourceCodeBlockLanguage(codeLanguage ?? '');\n } else {\n this._setRichCodeBlockLanguage(codeLanguage ?? '');\n }\n\n return;\n }\n\n if (action === 'heading' && headingLevel !== undefined) {\n if (this.sourceMode) {\n this._setSourceHeadingLevel(headingLevel);\n } else {\n document.execCommand('formatBlock', false, headingLevel ?? 'p');\n }\n\n return;\n }\n\n if (this.sourceMode) {\n this._applySourceFormat(action);\n } else {\n this._applyRichFormat(action);\n }\n };\n\n protected _applyRichFormat(action: EditorToolbarAction) {\n if (this.readOnly || !this._$richView) {\n return;\n }\n\n // Restore saved selection before applying command (toolbar click stole focus)\n this._$richView.focus();\n\n if (this._$savedRange) {\n const sel = window.getSelection();\n\n if (sel) {\n sel.removeAllRanges();\n sel.addRange(this._$savedRange.cloneRange());\n }\n }\n\n // For character-scope actions, expand a collapsed cursor to the word at cursor\n const CHAR_SCOPE = new Set<EditorToolbarAction>([\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n 'code',\n 'link',\n ]);\n\n if (CHAR_SCOPE.has(action)) {\n this._expandRichSelectionToWord();\n\n const sel = window.getSelection();\n\n if (sel?.rangeCount) {\n this._$savedRange = sel.getRangeAt(0).cloneRange();\n }\n }\n\n switch (action) {\n case 'bold':\n document.execCommand('bold');\n break;\n case 'italic':\n document.execCommand('italic');\n break;\n case 'underline':\n document.execCommand('underline');\n break;\n case 'strikethrough':\n this._wrapRichSelection('s');\n break;\n case 'code':\n this._wrapRichSelection('code');\n break;\n\n case 'blockquote': {\n const newTag = this._activeFormats.blockquote ? 'p' : 'blockquote';\n\n document.execCommand('formatBlock', false, newTag);\n break;\n }\n\n case 'bullet-list':\n document.execCommand('insertUnorderedList');\n break;\n case 'ordered-list':\n document.execCommand('insertOrderedList');\n break;\n case 'code-block':\n this._toggleRichCodeBlock();\n break;\n\n case 'link': {\n const sel = window.getSelection();\n const $anchor = sel?.rangeCount ? sel.getRangeAt(0).commonAncestorContainer : null;\n const $el = $anchor\n ? $anchor.nodeType === Node.TEXT_NODE\n ? ($anchor as Text).parentElement\n : ($anchor as Element)\n : null;\n\n this._linkPopoverHref = $el?.closest<HTMLAnchorElement>('a[href]')?.href ?? '';\n this._linkPopoverOpen = true;\n break;\n }\n }\n }\n\n protected _applySourceFormat(action: EditorToolbarAction) {\n const editor = this._$sourceEditor;\n const api = this._pluginApi;\n\n if (!editor) {\n return;\n }\n\n // For character-scope wraps with a collapsed cursor, expand to word at cursor\n const WORD_WRAP: Partial<Record<EditorToolbarAction, [string, string]>> = {\n bold: ['**', '**'],\n italic: ['*', '*'],\n strikethrough: ['~~', '~~'],\n code: ['`', '`'],\n };\n const wrap = WORD_WRAP[action];\n\n if (wrap && api && api.selectionStart === api.selectionEnd) {\n const wordInfo = api.getWordAtCursor();\n\n if (wordInfo) {\n const [pre, suf] = wrap;\n\n editor.value =\n api.value.slice(0, wordInfo.from) +\n pre +\n wordInfo.word +\n suf +\n api.value.slice(wordInfo.to);\n\n return;\n }\n }\n\n switch (action) {\n case 'bold':\n editor.wrapSelection('**', '**');\n break;\n case 'italic':\n editor.wrapSelection('*', '*');\n break;\n case 'underline':\n editor.wrapSelection('<u>', '</u>');\n break;\n case 'strikethrough':\n editor.wrapSelection('~~', '~~');\n break;\n case 'code':\n editor.wrapSelection('`', '`');\n break;\n case 'link':\n editor.replaceSelection('[](url)');\n break;\n case 'blockquote':\n this._toggleLinePrefix('> ');\n break;\n case 'bullet-list':\n this._toggleLinePrefix('- ');\n break;\n case 'ordered-list':\n this._toggleLinePrefix('1. ');\n break;\n case 'code-block':\n this._toggleSourceCodeFence();\n break;\n }\n }\n\n /** Sets the heading level on the cursor's line in source mode. null = paragraph. */\n protected _setSourceHeadingLevel(level: HeadingLevel | null) {\n const api = this._pluginApi;\n const editor = this._$sourceEditor;\n\n if (!api || !editor) {\n return;\n }\n\n const { value, selectionStart } = api;\n const lineStart = value.lastIndexOf('\\n', selectionStart - 1) + 1;\n\n const stripped = value.slice(lineStart).replace(/^#{1,6} /, '');\n const prefix = level ? '#'.repeat(parseInt(level[1]!)) + ' ' : '';\n\n editor.value =\n value.slice(0, lineStart) +\n prefix +\n stripped +\n value.slice(lineStart + (value.slice(lineStart).length - stripped.length));\n }\n\n /** Updates the language of the code block at the cursor in source mode. */\n protected _setSourceCodeBlockLanguage(lang: string) {\n const api = this._pluginApi;\n const editor = this._$sourceEditor;\n\n if (!api || !editor) {\n return;\n }\n\n const nextValue = setCodeBlockLanguage(api.value, api.selectionStart, lang);\n\n if (nextValue === null) {\n return;\n }\n\n editor.value = nextValue;\n }\n\n /** Updates the `data-lang` attribute on the `<pre>` at the cursor in rich mode. */\n protected _setRichCodeBlockLanguage(lang: string) {\n const sel = window.getSelection();\n\n if (!sel || sel.rangeCount === 0) {\n return;\n }\n\n const $anchor = sel.getRangeAt(0).commonAncestorContainer;\n const $el: Element | null =\n $anchor.nodeType === Node.TEXT_NODE ? ($anchor as Text).parentElement : ($anchor as Element);\n\n const $pre = $el?.closest('pre');\n\n if (!$pre) {\n return;\n }\n\n if (lang) {\n $pre.dataset['lang'] = lang;\n } else {\n delete $pre.dataset['lang'];\n }\n }\n\n /** Toggles a line prefix (e.g. `'> '`, `'- '`) on the cursor's line. */\n protected _toggleLinePrefix(prefix: string) {\n const api = this._pluginApi;\n const editor = this._$sourceEditor;\n\n if (!api || !editor) {\n return;\n }\n\n const { value, selectionStart } = api;\n const lineStart = value.lastIndexOf('\\n', selectionStart - 1) + 1;\n\n if (value.startsWith(prefix, lineStart)) {\n editor.value = value.slice(0, lineStart) + value.slice(lineStart + prefix.length);\n } else {\n editor.value = value.slice(0, lineStart) + prefix + value.slice(lineStart);\n }\n }\n\n /** Wraps the current selection (or cursor line) with a fenced code block. */\n protected _toggleSourceCodeFence() {\n const api = this._pluginApi;\n const editor = this._$sourceEditor;\n\n if (!api || !editor) {\n return;\n }\n\n const { value, selectionStart, selectionEnd } = api;\n const fence = '```';\n\n const lineStart = value.lastIndexOf('\\n', selectionStart - 1) + 1;\n const lineEndIdx = value.indexOf('\\n', selectionEnd);\n const lineEnd = lineEndIdx === -1 ? value.length : lineEndIdx;\n\n const prevNewline = value.lastIndexOf('\\n', lineStart - 2);\n const prevLine = prevNewline === -1 ? '' : value.slice(prevNewline + 1, lineStart - 1);\n const afterEnd = lineEnd + 1;\n const nextNewline = value.indexOf('\\n', afterEnd);\n const nextLine = value.slice(afterEnd, nextNewline === -1 ? undefined : nextNewline);\n\n if (prevLine.trim() === fence && nextLine.trim() === fence) {\n const unwrapStart = prevNewline === -1 ? 0 : prevNewline + 1;\n const unwrapEnd = nextNewline === -1 ? value.length : nextNewline + 1;\n const inner = value.slice(lineStart, lineEnd);\n\n editor.value = value.slice(0, unwrapStart) + inner + '\\n' + value.slice(unwrapEnd);\n\n return;\n }\n\n const selected = value.slice(lineStart, lineEnd);\n\n editor.value =\n value.slice(0, lineStart) + fence + '\\n' + selected + '\\n' + fence + value.slice(lineEnd);\n }\n\n protected _wrapRichSelection(tag: string) {\n const sel = window.getSelection();\n\n if (!sel || sel.rangeCount === 0) {\n return;\n }\n\n const range = sel.getRangeAt(0);\n\n if (range.collapsed) {\n return;\n }\n\n const $el = document.createElement(tag);\n\n try {\n range.surroundContents($el);\n } catch {\n // surroundContents fails when the range partially overlaps existing elements\n const fragment = range.extractContents();\n\n $el.appendChild(fragment);\n range.insertNode($el);\n }\n\n sel.removeAllRanges();\n sel.addRange(range);\n }\n\n protected _toggleRichCodeBlock() {\n const sel = window.getSelection();\n\n if (!sel || sel.rangeCount === 0) {\n return;\n }\n\n const range = sel.getRangeAt(0);\n const $anchor = range.commonAncestorContainer;\n const $el: Element | null =\n $anchor.nodeType === Node.TEXT_NODE ? ($anchor as Text).parentElement : ($anchor as Element);\n\n const $existingPre = $el?.closest('pre');\n\n if ($existingPre) {\n const $p = document.createElement('p');\n\n $p.textContent = $existingPre.textContent ?? '';\n $existingPre.replaceWith($p);\n\n const unwrapRange = document.createRange();\n\n unwrapRange.selectNodeContents($p);\n unwrapRange.collapse(false);\n sel.removeAllRanges();\n sel.addRange(unwrapRange);\n\n return;\n }\n\n const $pre = document.createElement('pre');\n const $code = document.createElement('code');\n\n $pre.appendChild($code);\n\n try {\n const fragment = range.extractContents();\n\n $code.appendChild(fragment);\n range.insertNode($pre);\n } catch {\n if ($el && $el !== this._$richView) {\n $code.textContent = $el.textContent ?? '';\n $el.replaceWith($pre);\n }\n }\n\n // insertNode leaves the selection spanning <pre>; collapse cursor into <code>\n // so the next keystroke types inside the block rather than replacing it.\n const innerRange = document.createRange();\n\n innerRange.selectNodeContents($code);\n innerRange.collapse(false);\n sel.removeAllRanges();\n sel.addRange(innerRange);\n }\n\n protected _onKeyDown = (e: KeyboardEvent) => {\n if (!e.ctrlKey && !e.metaKey) {\n return;\n }\n\n if (e.shiftKey && e.key === 'S') {\n e.preventDefault();\n\n const nextSourceMode = !this.sourceMode;\n\n this.sourceMode = nextSourceMode;\n this._dispatchModeChange(nextSourceMode ? 'source' : 'rich');\n\n return;\n }\n\n if (e.shiftKey) {\n return;\n }\n\n let action: EditorToolbarAction | null = null;\n\n switch (e.key) {\n case 'b':\n action = 'bold';\n break;\n case 'i':\n action = 'italic';\n break;\n case 'u':\n action = 'underline';\n break;\n case '`':\n action = 'code';\n break;\n case 'k':\n action = 'link';\n break;\n }\n\n if (action) {\n e.preventDefault();\n\n if (this.sourceMode) {\n this._applySourceFormat(action);\n } else {\n this._applyRichFormat(action);\n }\n }\n };\n\n protected _onSelectionChange = () => {\n // Chrome shadow-adjusts window.getSelection() to the nearest light-DOM ancestor\n // for selections inside a shadow root — use shadowRoot.getSelection() when available.\n const sel =\n (this.shadowRoot as unknown as { getSelection?: () => Selection | null }).getSelection?.() ??\n window.getSelection();\n\n if (!sel || sel.rangeCount === 0) {\n return;\n }\n\n const range = sel.getRangeAt(0);\n const $anchor = range.commonAncestorContainer;\n const $el: Element | null =\n $anchor.nodeType === Node.TEXT_NODE ? ($anchor as Text).parentElement : ($anchor as Element);\n\n if (!this._$richView?.contains($el)) {\n return;\n }\n\n this._$savedRange = range.cloneRange();\n\n if (this.sourceMode) {\n return;\n }\n\n const $pre = $el?.closest('pre');\n\n this._activeFormats = {\n bold: !!$el?.closest('strong, b'),\n italic: !!$el?.closest('em, i'),\n underline: !!$el?.closest('u'),\n strikethrough: !!$el?.closest('s, del, strike'),\n code: !$pre && !!$el?.closest('code'),\n link: !!$el?.closest('a'),\n heading: ($el?.closest('h1,h2,h3,h4,h5,h6')?.tagName.toLowerCase() ??\n null) as HeadingLevel | null,\n blockquote: !!$el?.closest('blockquote'),\n bulletList: !!$el?.closest('ul'),\n orderedList: !!$el?.closest('ol'),\n codeBlock: !!$pre,\n codeLanguage: $pre ? ($pre.dataset['lang'] ?? '') : null,\n };\n\n this._pushToolbarState();\n };\n\n protected _pushToolbarState() {\n const $toolbar = this._$toolbar as\n | (HTMLElement & {\n activeBold?: boolean;\n activeItalic?: boolean;\n activeUnderline?: boolean;\n activeStrikethrough?: boolean;\n activeCode?: boolean;\n activeLink?: boolean;\n activeHeading?: HeadingLevel | null;\n activeBlockquote?: boolean;\n activeBulletList?: boolean;\n activeOrderedList?: boolean;\n activeCodeBlock?: boolean;\n codeLanguage?: string | null;\n sourceMode?: boolean;\n })\n | undefined;\n\n if ($toolbar) {\n $toolbar.activeBold = !!this._activeFormats.bold;\n $toolbar.activeItalic = !!this._activeFormats.italic;\n $toolbar.activeUnderline = !!this._activeFormats.underline;\n $toolbar.activeStrikethrough = !!this._activeFormats.strikethrough;\n $toolbar.activeCode = !!this._activeFormats.code;\n $toolbar.activeLink = !!this._activeFormats.link;\n $toolbar.activeHeading = this._activeFormats.heading ?? null;\n $toolbar.activeBlockquote = !!this._activeFormats.blockquote;\n $toolbar.activeBulletList = !!this._activeFormats.bulletList;\n $toolbar.activeOrderedList = !!this._activeFormats.orderedList;\n $toolbar.activeCodeBlock = !!this._activeFormats.codeBlock;\n $toolbar.codeLanguage = this._activeFormats.codeLanguage ?? null;\n $toolbar.sourceMode = this.sourceMode;\n }\n\n this.dispatchEvent(\n new CustomEvent<ActiveFormats>('rc-formatting-change', {\n bubbles: true,\n composed: true,\n detail: { ...this._activeFormats },\n }),\n );\n }\n\n protected _syncNativeTextarea() {\n const $textarea = this.querySelector<HTMLTextAreaElement>('textarea');\n\n if ($textarea) {\n $textarea.value = this.value;\n }\n }\n\n protected _connectLabel() {\n const $textarea = this.querySelector<HTMLTextAreaElement>('textarea');\n\n if (!$textarea) {\n return;\n }\n\n // Mirror label text to the rich view for accessibility\n const $label = $textarea.id\n ? this.querySelector<HTMLLabelElement>(`label[for=\"${CSS.escape($textarea.id)}\"]`)\n : null;\n\n if ($label && this._$richView) {\n this._$richView.setAttribute('aria-label', $label.textContent?.trim() ?? '');\n }\n\n // Forward label click to the active editor surface\n $label?.addEventListener('click', () => {\n if (this.sourceMode) {\n this._$sourceEditor?.focus();\n } else {\n this._$richView?.focus();\n }\n });\n }\n\n protected _onRichViewClick = (e: MouseEvent) => {\n if (!e.ctrlKey && !e.metaKey) {\n return;\n }\n\n const $a = (e.target as Element).closest<HTMLAnchorElement>('a[href]');\n\n if (!$a) {\n return;\n }\n\n e.preventDefault();\n window.open($a.href, '_blank', 'noopener,noreferrer');\n };\n\n protected _onDocumentClick = (e: MouseEvent) => {\n if (!this._linkPopoverOpen) {\n return;\n }\n\n const $popover = this.shadowRoot?.querySelector('.link-popover');\n\n if ($popover && e.composedPath().includes($popover)) {\n return;\n }\n\n this._linkPopoverOpen = false;\n };\n\n protected _expandRichSelectionToWord(): void {\n const sel = window.getSelection();\n\n if (!sel?.isCollapsed) {\n return;\n }\n\n const modify = (\n sel as unknown as { modify?: (alter: string, dir: string, unit: string) => void }\n ).modify;\n\n if (typeof modify !== 'function') {\n return;\n }\n\n modify.call(sel, 'move', 'backward', 'word');\n modify.call(sel, 'extend', 'forward', 'word');\n }\n\n protected _positionLinkPopover(): void {\n if (!this._$savedRange || !this._$linkPopover) {\n return;\n }\n\n const rangeRect = this._$savedRange.getBoundingClientRect();\n const hostRect = this.getBoundingClientRect();\n\n this._$linkPopover.style.top = `${rangeRect.bottom - hostRect.top + 4}px`;\n this._$linkPopover.style.left = `${Math.max(0, rangeRect.left - hostRect.left)}px`;\n }\n\n protected _applyLink = () => {\n this._linkPopoverOpen = false;\n\n if (!this._linkPopoverHref) {\n return;\n }\n\n this._$richView?.focus();\n\n if (this._$savedRange) {\n const sel = window.getSelection();\n\n if (sel) {\n sel.removeAllRanges();\n sel.addRange(this._$savedRange.cloneRange());\n }\n }\n\n document.execCommand('createLink', false, this._linkPopoverHref);\n };\n\n protected _removeLink = () => {\n this._linkPopoverOpen = false;\n this._$richView?.focus();\n\n if (this._$savedRange) {\n const sel = window.getSelection();\n\n if (sel) {\n sel.removeAllRanges();\n sel.addRange(this._$savedRange.cloneRange());\n }\n }\n\n document.execCommand('unlink');\n };\n\n protected _openLinkHref = () => {\n if (this._linkPopoverHref) {\n window.open(this._linkPopoverHref, '_blank', 'noopener,noreferrer');\n }\n };\n\n protected _onLinkPopoverKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n this._applyLink();\n } else if (e.key === 'Escape') {\n this._linkPopoverOpen = false;\n this._$richView?.focus();\n }\n };\n\n protected _dispatchChange(value: string) {\n this.dispatchEvent(\n new CustomEvent<{ value: string }>('rc-change', {\n bubbles: true,\n composed: true,\n detail: { value },\n }),\n );\n }\n\n protected _dispatchModeChange(mode: EditorMode) {\n this.dispatchEvent(\n new CustomEvent<{ mode: EditorMode }>('rc-mode-change', {\n bubbles: true,\n composed: true,\n detail: { mode },\n }),\n );\n }\n}\n","/**\n * Bootstrap Icons v1.x (MIT) used for `<rc-editor-toolbar>`.\n * Icons source: https://icons.getbootstrap.com/\n * License: MIT — https://github.com/twbs/icons/blob/main/LICENSE\n *\n * All icons use `currentColor` so they inherit button text colour,\n * including forced-colours mode. ViewBox is 0 0 16 16; rendered at\n * 1em so they scale with the button's font-size.\n */\n\nimport { svg, type SVGTemplateResult } from 'lit';\n\nconst icon = (content: SVGTemplateResult) => svg`\n <svg\n viewBox=\"0 0 16 16\"\n width=\"1em\"\n height=\"1em\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >${content}</svg>\n`;\n\nexport const icons = {\n\n bold: icon(svg`\n <path fill=\"currentColor\" d=\"M8.21 13c2.106 0 3.412-1.087 3.412-2.823c0-1.306-.984-2.283-2.324-2.386v-.055a2.176 2.176 0 0 0 1.852-2.14c0-1.51-1.162-2.46-3.014-2.46H3.843V13zM5.908 4.674h1.696c.963 0 1.517.451 1.517 1.244c0 .834-.629 1.32-1.73 1.32H5.908V4.673zm0 6.788V8.598h1.73c1.217 0 1.88.492 1.88 1.415c0 .943-.643 1.449-1.832 1.449H5.907z\"/>\n `),\n\n italic: icon(svg`\n <path fill=\"currentColor\" d=\"M7.991 11.674L9.53 4.455c.123-.595.246-.71 1.347-.807l.11-.52H7.211l-.11.52c1.06.096 1.128.212 1.005.807L6.57 11.674c-.123.595-.246.71-1.346.806l-.11.52h3.774l.11-.52c-1.06-.095-1.129-.211-1.006-.806z\"/>\n `),\n\n underline: icon(svg`\n <path fill=\"currentColor\" d=\"M5.313 3.136h-1.23V9.54c0 2.105 1.47 3.623 3.917 3.623s3.917-1.518 3.917-3.623V3.136h-1.23v6.323c0 1.49-.978 2.57-2.687 2.57s-2.687-1.08-2.687-2.57zM12.5 15h-9v-1h9z\"/>\n `),\n\n strikethrough: icon(svg`\n <path fill=\"currentColor\" d=\"M6.333 5.686c0 .31.083.581.27.814H5.166a2.8 2.8 0 0 1-.099-.76c0-1.627 1.436-2.768 3.48-2.768c1.969 0 3.39 1.175 3.445 2.85h-1.23c-.11-1.08-.964-1.743-2.25-1.743c-1.23 0-2.18.602-2.18 1.607zm2.194 7.478c-2.153 0-3.589-1.107-3.705-2.81h1.23c.144 1.06 1.129 1.703 2.544 1.703c1.34 0 2.31-.705 2.31-1.675c0-.827-.547-1.374-1.914-1.675L8.046 8.5H1v-1h14v1h-3.504c.468.437.675.994.675 1.697c0 1.826-1.436 2.967-3.644 2.967\"/>\n `),\n\n code: icon(svg`\n <path fill=\"currentColor\" d=\"M5.854 4.854a.5.5 0 1 0-.708-.708l-3.5 3.5a.5.5 0 0 0 0 .708l3.5 3.5a.5.5 0 0 0 .708-.708L2.707 8zm4.292 0a.5.5 0 0 1 .708-.708l3.5 3.5a.5.5 0 0 1 0 .708l-3.5 3.5a.5.5 0 0 1-.708-.708L13.293 8z\"/>\n `),\n\n link: icon(svg`\n <g fill=\"currentColor\">\n <path d=\"M4.715 6.542L3.343 7.914a3 3 0 1 0 4.243 4.243l1.828-1.829A3 3 0 0 0 8.586 5.5L8 6.086a1 1 0 0 0-.154.199a2 2 0 0 1 .861 3.337L6.88 11.45a2 2 0 1 1-2.83-2.83l.793-.792a4 4 0 0 1-.128-1.287z\"/>\n <path d=\"M6.586 4.672A3 3 0 0 0 7.414 9.5l.775-.776a2 2 0 0 1-.896-3.346L9.12 3.55a2 2 0 1 1 2.83 2.83l-.793.792c.112.42.155.855.128 1.287l1.372-1.372a3 3 0 1 0-4.243-4.243z\"/>\n </g>\n `),\n\n blockquote: icon(svg`\n <path fill=\"currentColor\" d=\"M2.5 3a.5.5 0 0 0 0 1h11a.5.5 0 0 0 0-1zm5 3a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm0 3a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm-5 3a.5.5 0 0 0 0 1h11a.5.5 0 0 0 0-1zm.79-5.373q.168-.117.444-.275L3.524 6q-.183.111-.452.287q-.27.176-.51.428a2.4 2.4 0 0 0-.398.562Q2 7.587 2 7.969q0 .54.217.873q.217.328.72.328q.322 0 .504-.211a.7.7 0 0 0 .188-.463q0-.345-.211-.521q-.205-.182-.568-.182h-.282q.036-.305.123-.498a1.4 1.4 0 0 1 .252-.37a2 2 0 0 1 .346-.298zm2.167 0q.17-.117.445-.275L5.692 6q-.183.111-.452.287q-.27.176-.51.428a2.4 2.4 0 0 0-.398.562q-.165.31-.164.692q0 .54.217.873q.217.328.72.328q.322 0 .504-.211a.7.7 0 0 0 .188-.463q0-.345-.211-.521q-.205-.182-.568-.182h-.282a1.8 1.8 0 0 1 .118-.492q.087-.194.257-.375a2 2 0 0 1 .346-.3z\"/>\n `),\n\n bulletList: icon(svg`\n <path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m-3 1a1 1 0 1 0 0-2a1 1 0 0 0 0 2m0 4a1 1 0 1 0 0-2a1 1 0 0 0 0 2m0 4a1 1 0 1 0 0-2a1 1 0 0 0 0 2\"/>\n `),\n\n orderedList: icon(svg`\n <g fill=\"currentColor\">\n <path fill-rule=\"evenodd\" d=\"M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5\"/>\n <path d=\"M1.713 11.865v-.474H2c.217 0 .363-.137.363-.317c0-.185-.158-.31-.361-.31c-.223 0-.367.152-.373.31h-.59c.016-.467.373-.787.986-.787c.588-.002.954.291.957.703a.595.595 0 0 1-.492.594v.033a.615.615 0 0 1 .569.631c.003.533-.502.8-1.051.8c-.656 0-1-.37-1.008-.794h.582c.008.178.186.306.422.309c.254 0 .424-.145.422-.35c-.002-.195-.155-.348-.414-.348h-.3zm-.004-4.699h-.604v-.035c0-.408.295-.844.958-.844c.583 0 .96.326.96.756c0 .389-.257.617-.476.848l-.537.572v.03h1.054V9H1.143v-.395l.957-.99c.138-.142.293-.304.293-.508c0-.18-.147-.32-.342-.32a.33.33 0 0 0-.342.338zM2.564 5h-.635V2.924h-.031l-.598.42v-.567l.629-.443h.635z\"/>\n </g>\n `),\n\n codeBlock: icon(svg`\n <path fill=\"currentColor\" d=\"M2.114 8.063V7.9c1.005-.102 1.497-.615 1.497-1.6V4.503c0-1.094.39-1.538 1.354-1.538h.273V2h-.376C3.25 2 2.49 2.759 2.49 4.352v1.524c0 1.094-.376 1.456-1.49 1.456v1.299c1.114 0 1.49.362 1.49 1.456v1.524c0 1.593.759 2.352 2.372 2.352h.376v-.964h-.273c-.964 0-1.354-.444-1.354-1.538V9.663c0-.984-.492-1.497-1.497-1.6M13.886 7.9v.163c-1.005.103-1.497.616-1.497 1.6v1.798c0 1.094-.39 1.538-1.354 1.538h-.273v.964h.376c1.613 0 2.372-.759 2.372-2.352v-1.524c0-1.094.376-1.456 1.49-1.456V7.332c-1.114 0-1.49-.362-1.49-1.456V4.352C13.51 2.759 12.75 2 11.138 2h-.376v.964h.273c.964 0 1.354.444 1.354 1.538V6.3c0 .984.492 1.497 1.497 1.6\"/>\n `),\n\n source: icon(svg`\n <g fill=\"currentColor\">\n <path d=\"M14 3a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM2 2a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2z\"/>\n <path fill-rule=\"evenodd\" d=\"M9.146 8.146a.5.5 0 0 1 .708 0L11.5 9.793l1.646-1.647a.5.5 0 0 1 .708.708l-2 2a.5.5 0 0 1-.708 0l-2-2a.5.5 0 0 1 0-.708\"/>\n <path fill-rule=\"evenodd\" d=\"M11.5 5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0v-4a.5.5 0 0 1 .5-.5\"/>\n <path d=\"M3.56 11V7.01h.056l1.428 3.239h.774l1.42-3.24h.056V11h1.073V5.001h-1.2l-1.71 3.894h-.039l-1.71-3.894H2.5V11z\"/>\n </g>\n `),\n\n};\n","import { LitElement, html, nothing, type SVGTemplateResult, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport '@rcarls/rc-button/define';\nimport '@rcarls/rc-select/define';\nimport '@rcarls/rc-toolbar/define';\nimport { icons } from './icons.ts';\nimport type { EditorToolbarAction, EditorToolbarActionDetail, HeadingLevel } from './types.ts';\n\nconst HEADING_OPTIONS: Array<{ value: HeadingLevel | 'p'; label: string }> = [\n { value: 'p', label: 'Paragraph' },\n { value: 'h1', label: 'Heading 1' },\n { value: 'h2', label: 'Heading 2' },\n { value: 'h3', label: 'Heading 3' },\n { value: 'h4', label: 'Heading 4' },\n { value: 'h5', label: 'Heading 5' },\n { value: 'h6', label: 'Heading 6' },\n];\n\n/**\n * Formatting toolbar for `<rc-markdown-editor>`. Renders themed `rc-button`,\n * `rc-select`, and `rc-toolbar` controls into its own light DOM so the parent\n * editor can provide their shared appearance.\n *\n * Active-format properties are set by the parent editor and reflected as\n * `aria-pressed` on the corresponding buttons. Heading level is shown via an\n * `<rc-select>`. Code-block language is shown via a `<input>` when active.\n *\n * @see {@link https://richardcarls.github.io/rc-webcomponents/components/rc-markdown-editor rc-markdown-editor docs}\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/ WAI-ARIA Toolbar pattern}\n *\n * @fires rc-toolbar-action - When a formatting button or select is activated.\n *\n * @attr label - Accessible label applied to the `rc-toolbar` container.\n * @attr active-bold - Reflects Bold as active at the cursor.\n * @attr active-italic - Reflects Italic as active at the cursor.\n * @attr active-underline - Reflects Underline as active at the cursor.\n * @attr active-strikethrough - Reflects Strikethrough as active at the cursor.\n * @attr active-code - Reflects inline Code as active at the cursor.\n * @attr active-link - Reflects Link as active at the cursor.\n * @attr active-heading - Heading level active at the cursor, or absent for paragraph text.\n * @attr active-blockquote - Reflects Blockquote as active at the cursor.\n * @attr active-bullet-list - Reflects Bullet List as active at the cursor.\n * @attr active-ordered-list - Reflects Ordered List as active at the cursor.\n * @attr active-code-block - Reflects Code Block as active at the cursor.\n * @attr code-language - Language of the code block at the cursor; absent when not in a code block.\n * @attr source-mode - Whether the parent editor is in source mode.\n */\nexport class RcEditorToolbar extends LitElement {\n /** Accessible label applied to the `rc-toolbar` container. */\n @property({ type: String })\n label = 'Formatting';\n\n /** Whether Bold formatting is active at the cursor. */\n @property({ type: Boolean, reflect: true, attribute: 'active-bold' })\n activeBold = false;\n\n /** Whether Italic formatting is active at the cursor. */\n @property({ type: Boolean, reflect: true, attribute: 'active-italic' })\n activeItalic = false;\n\n /** Whether Underline formatting is active at the cursor. */\n @property({ type: Boolean, reflect: true, attribute: 'active-underline' })\n activeUnderline = false;\n\n /** Whether Strikethrough formatting is active at the cursor. */\n @property({ type: Boolean, reflect: true, attribute: 'active-strikethrough' })\n activeStrikethrough = false;\n\n /** Whether inline Code formatting is active at the cursor. */\n @property({ type: Boolean, reflect: true, attribute: 'active-code' })\n activeCode = false;\n\n /** Whether the cursor is inside a Link. */\n @property({ type: Boolean, reflect: true, attribute: 'active-link' })\n activeLink = false;\n\n /** Heading level active at the cursor, or `null` for paragraph text. */\n @property({ attribute: 'active-heading' })\n activeHeading: HeadingLevel | null = null;\n\n /** Whether the cursor is inside a Blockquote. */\n @property({ type: Boolean, reflect: true, attribute: 'active-blockquote' })\n activeBlockquote = false;\n\n /** Whether the cursor is inside a Bullet List. */\n @property({ type: Boolean, reflect: true, attribute: 'active-bullet-list' })\n activeBulletList = false;\n\n /** Whether the cursor is inside an Ordered List. */\n @property({ type: Boolean, reflect: true, attribute: 'active-ordered-list' })\n activeOrderedList = false;\n\n /** Whether the cursor is inside a Code Block. */\n @property({ type: Boolean, reflect: true, attribute: 'active-code-block' })\n activeCodeBlock = false;\n\n /**\n * Language of the code block at the cursor. `null` means not in a code block\n * (hides the language input). `''` means no language is set.\n */\n @property({ attribute: 'code-language' })\n codeLanguage: string | null = null;\n\n /** Whether the editor is in source mode. */\n @property({ type: Boolean, reflect: true, attribute: 'source-mode' })\n sourceMode = false;\n\n @state()\n protected _langInputValue = '';\n\n override createRenderRoot(): HTMLElement {\n return this;\n }\n\n override updated(changed: Map<string, unknown>): void {\n if (changed.has('codeLanguage') && this.codeLanguage !== null) {\n this._langInputValue = this.codeLanguage;\n }\n }\n\n protected _dispatch(\n action: EditorToolbarAction,\n extra?: Partial<EditorToolbarActionDetail>,\n ): void {\n this.dispatchEvent(\n new CustomEvent<EditorToolbarActionDetail>('rc-toolbar-action', {\n bubbles: true,\n composed: true,\n detail: { action, ...extra },\n }),\n );\n }\n\n protected _onClick = (e: MouseEvent) => {\n const $btn = (e.target as Element).closest<HTMLButtonElement>('button[data-action]');\n\n if (!$btn) {\n return;\n }\n\n this._dispatch($btn.dataset['action'] as EditorToolbarAction);\n };\n\n protected _onHeadingChange = (e: Event) => {\n const value = (e as CustomEvent<{ value: string }>).detail.value as HeadingLevel | 'p';\n\n this._dispatch('heading', { headingLevel: value === 'p' ? null : value });\n };\n\n protected _onLangInput = (e: Event) => {\n this._langInputValue = (e.target as HTMLInputElement).value;\n };\n\n protected _onLangCommit = () => {\n this._dispatch('code-block-language', { codeLanguage: this._langInputValue.trim() });\n };\n\n protected _onLangKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n this._onLangCommit();\n }\n };\n\n protected _renderActionButton(\n action: EditorToolbarAction,\n label: string,\n title: string,\n active: boolean,\n icon: SVGTemplateResult,\n ): TemplateResult {\n return html`\n <rc-button icon-only class=${active ? 'toolbar-active' : nothing}>\n <button\n type=\"button\"\n data-action=${action}\n title=${title}\n aria-label=${label}\n aria-pressed=${String(active)}\n >\n <span data-rc-button-icon>${icon}</span>\n </button>\n </rc-button>\n `;\n }\n\n override render() {\n return html`\n <rc-toolbar label=${this.label} @click=${this._onClick}>\n ${this._renderActionButton('bold', 'Bold', 'Bold (Ctrl+B)', this.activeBold, icons.bold)}\n ${this._renderActionButton(\n 'italic',\n 'Italic',\n 'Italic (Ctrl+I)',\n this.activeItalic,\n icons.italic,\n )}\n ${this._renderActionButton(\n 'underline',\n 'Underline',\n 'Underline (Ctrl+U)',\n this.activeUnderline,\n icons.underline,\n )}\n ${this._renderActionButton(\n 'strikethrough',\n 'Strikethrough',\n 'Strikethrough',\n this.activeStrikethrough,\n icons.strikethrough,\n )}\n ${this._renderActionButton(\n 'code',\n 'Inline Code',\n 'Inline Code (Ctrl+`)',\n this.activeCode,\n icons.code,\n )}\n ${this._renderActionButton('link', 'Link', 'Link (Ctrl+K)', this.activeLink, icons.link)}\n\n <rc-select\n title=\"Heading level\"\n placeholder=\"Heading level\"\n class=${this.activeHeading ? 'toolbar-active' : ''}\n .value=${this.activeHeading ?? 'p'}\n @rc-select-change=${this._onHeadingChange}\n >\n <select aria-label=\"Heading level\">\n ${HEADING_OPTIONS.map(\n ({ value, label }) => html` <option value=${value}>${label}</option> `,\n )}\n </select>\n </rc-select>\n\n ${this._renderActionButton(\n 'blockquote',\n 'Blockquote',\n 'Blockquote',\n this.activeBlockquote,\n icons.blockquote,\n )}\n ${this._renderActionButton(\n 'bullet-list',\n 'Bullet List',\n 'Bullet List',\n this.activeBulletList,\n icons.bulletList,\n )}\n ${this._renderActionButton(\n 'ordered-list',\n 'Ordered List',\n 'Ordered List',\n this.activeOrderedList,\n icons.orderedList,\n )}\n ${this._renderActionButton(\n 'code-block',\n 'Code Block',\n 'Code Block',\n this.activeCodeBlock,\n icons.codeBlock,\n )}\n ${this.activeCodeBlock && this.codeLanguage !== null\n ? html`\n <input\n type=\"text\"\n class=\"lang-input\"\n aria-label=\"Code block language\"\n placeholder=\"Language\"\n title=\"Syntax language (e.g. TypeScript, Rust)\"\n .value=${this._langInputValue}\n @input=${this._onLangInput}\n @blur=${this._onLangCommit}\n @keydown=${this._onLangKeyDown}\n @click=${(e: Event) => e.stopPropagation()}\n />\n `\n : nothing}\n ${this._renderActionButton(\n 'source',\n 'Source Mode',\n 'Toggle Markdown Source (Ctrl+Shift+S)',\n this.sourceMode,\n icons.source,\n )}\n </rc-toolbar>\n `;\n }\n}\n"],"names":["element","decodeNamedCharacterReference","value","characterReference","character","splice","list","start","remove","items","end","chunkStart","parameters","push","hasOwnProperty","combineExtensions","extensions","all","index","syntaxExtension","extension","hook","left","right","code","constructs","existing","before","combineHtmlExtensions","htmlExtensions","handlers","htmlExtension","type","decodeNumericCharacterReference","base","characterReferences","encode","replace","normalizeIdentifier","asciiAlpha","regexCheck","asciiAlphanumeric","asciiAtext","asciiControl","asciiDigit","asciiHexDigit","asciiPunctuation","markdownLineEnding","markdownLineEndingOrSpace","markdownSpace","unicodePunctuation","unicodeWhitespace","regex","check","sanitizeUri","url","protocol","normalizeUri","colon","questionMark","numberSign","slash","result","skip","next","protocolHref","protocolSource","compile","options","settings","tags","definitions","buffers","mediaStack","tightStack","onenterblockquote","onentercodefenced","buffer","onentercodeindented","onentercodetext","onentercontent","onenterdefinition","onenterdefinitiondestinationstring","onenteremphasis","onenterhtmlflow","onenterhtml","onenterimage","onenterlink","onenterlistitemmarker","onenterlistitemvalue","onenterlistordered","onenterlistunordered","onenterparagraph","onenterresource","onenterresourcedestinationstring","onentersetextheading","onenterstrong","onexitatxheading","onexitatxheadingsequence","onexitautolinkemail","onexitautolinkprotocol","onexitblockquote","onexitdata","onexitcharacterreferencemarker","onexitcharacterreferencevalue","onexitflowcode","onexitcodefencedfence","onexitcodefencedfenceinfo","onresumedrop","onexitcodeflowvalue","onexitcodetext","onexitdefinition","onexitdefinitiondestinationstring","onexitdefinitionlabelstring","onexitdefinitiontitlestring","onexitemphasis","onexithardbreak","onexithtml","onexitmedia","onexitlabel","onexitlabeltext","onexitlineending","onexitlistordered","onexitlistunordered","onexitparagraph","onexitreferencestring","onexitresourcedestinationstring","onexitresourcetitlestring","onexitsetextheading","onexitsetextheadinglinesequence","onexitsetextheadingtext","onexitstrong","onexitthematicbreak","data","context","getData","lineEndingIfNeeded","raw","resume","setData","tag","lineEndingStyle","events","listStack","head","body","prepareList","handles","kind","handle","slice","length","containerBalance","loose","atMarker","event","key","lineEnding","previous","_encode","token","onexitlistitem","count","media","id","decoded","uri","factorySpace","effects","ok","max","limit","size","prefix","content","initializeContent","contentStart","afterContentStartConstruct","paragraphInitial","lineStart","document","initializeDocument","containerConstruct","tokenizeContainer","self","stack","continued","childFlow","childToken","lineStartOffset","item","documentContinue","checkNewContainers","closeFlow","indexBeforeExits","indexBeforeFlow","point","exitContainers","documentContinued","flowStart","thereIsANewContainer","thereIsNoNewContainer","containerContinue","flowContinue","writeToChild","endOfFile","stream","seen","entry","nok","classifyCharacter","resolveAll","called","resolve","attention","resolveAllAttention","tokenizeAttention","open","group","text","openingSequence","closingSequence","use","nextEvents","offset","movePoint","attentionMarkers","marker","inside","after","close","autolink","tokenizeAutolink","schemeOrEmailAtext","emailAtext","schemeInsideOrEmailAtext","urlInside","emailAtSignOrDot","emailLabel","emailValue","blankLine","tokenizeBlankLine","blockQuote","tokenizeBlockQuoteContinuation","exit","tokenizeBlockQuoteStart","state","contStart","contBefore","characterEscape","tokenizeCharacterEscape","tokenizeCharacterReference","test","numeric","nonLazyContinuation","tokenizeNonLazyContinuation","codeFenced","tokenizeCodeFenced","closeStart","tokenizeCloseStart","initialPrefix","sizeOpen","beforeSequenceOpen","tail","sequenceOpen","infoBefore","atNonLazyBreak","info","metaBefore","meta","contentBefore","beforeContentChunk","contentChunk","startBefore","beforeSequenceClose","sequenceClose","sequenceCloseAfter","codeIndented","tokenizeCodeIndented","furtherStart","tokenizeFurtherStart","afterPrefix","atBreak","codeText","resolveCodeText","tokenizeCodeText","tailExitIndex","headEnterIndex","enter","between","SpliceBuffer","initial","stop","deleteCount","removed","chunkedPush","n","subtokenize","eventsArray","jumps","lineIndex","otherIndex","otherEvent","subevents","more","subcontent","eventIndex","startPosition","startPositions","tokenizer","childEvents","gaps","current","adjust","breaks","resolveContent","tokenizeContent","continuationConstruct","tokenizeContinuation","chunkInside","contentEnd","contentContinue","startLookahead","prefixed","factoryDestination","literalType","literalMarkerType","rawType","stringType","balance","enclosedBefore","enclosed","enclosedEscape","rawEscape","factoryLabel","markerType","labelInside","labelEscape","factoryTitle","begin","escape","factoryWhitespace","definition","tokenizeDefinition","titleBefore","tokenizeTitleBefore","identifier","labelAfter","markerAfter","destinationBefore","destinationAfter","afterWhitespace","beforeMarker","titleAfter","titleAfterOptionalWhitespace","hardBreakEscape","tokenizeHardBreakEscape","headingAtx","resolveHeadingAtx","tokenizeHeadingAtx","sequenceFurther","htmlBlockNames","htmlRawNames","htmlFlow","resolveToHtmlFlow","tokenizeHtmlFlow","blankLineBefore","tokenizeBlankLineBefore","nonLazyContinuationStart","tokenizeNonLazyContinuationStart","closingTag","markerB","declarationOpen","tagCloseStart","continuationDeclarationInside","tagName","commentOpenInside","cdataOpenInside","continuation","name","basicSelfClosing","completeClosingTagAfter","completeAttributeNameBefore","completeEnd","completeAttributeName","completeAttributeNameAfter","completeAttributeValueBefore","completeAttributeValueQuoted","completeAttributeValueUnquoted","completeAttributeValueQuotedAfter","completeAfter","continuationCommentInside","continuationRawTagOpen","continuationClose","continuationCdataInside","continuationAfter","continuationStart","continuationStartNonLazy","continuationBefore","continuationRawEndTag","htmlText","tokenizeHtmlText","returnState","instruction","tagOpen","declaration","commentEnd","comment","commentClose","lineEndingBefore","cdata","cdataClose","cdataEnd","instructionClose","tagClose","tagCloseBetween","tagOpenBetween","tagOpenAttributeName","tagOpenAttributeNameAfter","tagOpenAttributeValueBefore","tagOpenAttributeValueQuoted","tagOpenAttributeValueUnquoted","tagOpenAttributeValueQuotedAfter","lineEndingAfter","lineEndingAfterPrefix","labelEnd","resolveAllLabelEnd","resolveToLabelEnd","tokenizeLabelEnd","resourceConstruct","tokenizeResource","referenceFullConstruct","tokenizeReferenceFull","referenceCollapsedConstruct","tokenizeReferenceCollapsed","newEvents","label","labelStart","defined","labelEndNok","labelEndOk","referenceNotFull","resourceStart","resourceBefore","resourceOpen","resourceEnd","resourceDestinationAfter","resourceDestinationMissing","resourceBetween","resourceTitleAfter","referenceFull","referenceFullAfter","referenceFullMissing","referenceCollapsedStart","referenceCollapsedOpen","labelStartImage","tokenizeLabelStartImage","labelStartLink","tokenizeLabelStartLink","tokenizeLineEnding","thematicBreak","tokenizeThematicBreak","sequence","tokenizeListContinuation","tokenizeListEnd","tokenizeListStart","listItemPrefixWhitespaceConstruct","tokenizeListItemPrefixWhitespace","indentConstruct","tokenizeIndent","initialSize","onBlank","endOfPrefix","otherPrefix","notBlank","notInCurrentItem","setextUnderline","resolveToSetextUnderline","tokenizeSetextUnderline","heading","paragraph","flow","initializeFlow","atBlankEnding","afterConstruct","resolver","createResolver","string","initializeFactory","field","resolveAllLineSuffixes","initializeText","notText","extraResolver","resolveAllText","chunks","bufferIndex","tabs","chunk","contentInitial","flowInitial","insideSpan","resolveText","disable","createTokenizer","parser","initialize","from","columnStart","resolveAllConstructs","constructFactory","onsuccessfulconstruct","onsuccessfulcheck","consume","defineSkip","now","sliceSerialize","sliceStream","write","main","addResult","expandTabs","serializeChunks","sliceChunks","_bufferIndex","_index","line","column","accountForPotentialSkip","chunkIndex","go","fields","construct","_","onreturn","bogusState","listOfConstructs","constructIndex","currentConstruct","handleListOfConstructs","handleMapOfConstructs","map","handleConstruct","store","startPoint","startPrevious","startCurrentConstruct","startEventsIndex","startStack","restore","startIndex","startBufferIndex","endIndex","endBufferIndex","view","atTab","parse","defaultConstructs","create","creator","postprocess","search","preprocess","atCarriageReturn","preprocessor","encoding","match","endPosition","micromark","gfmStrikethrough","single","tokenizeStrikethrough","resolveAllStrikethrough","strikethrough","extend","destination","i","source","repeat","trimLeadingNewlines","trimTrailingNewlines","indexEnd","trimNewlines","blockElements","isBlock","node","is","voidElements","isVoid","hasVoid","has","meaningfulWhenBlankElements","isMeaningfulWhenBlank","hasMeaningfulWhenBlank","tagNames","markdownEscapes","escapeMarkdown","accumulator","rules","hLevel","underline","parent","isParagraph","className","language","fenceChar","fenceSize","fenceInCodeRegex","fence","href","escapeLinkDestination","title","escapeLinkTitle","cleanAttribute","titlePart","replacement","reference","references","hasSiblings","isCodeBlock","extraSpace","delimiter","matches","alt","src","attribute","escaped","Rules","rule","filter","findRule","fn","filterValue","collapseWhitespace","isPre","prevText","keepLeadingWs","prev","nextNode","root","canParseHTMLNatively","Parser","canParse","createHTMLParser","shouldUseActiveX","doc","useActiveX","HTMLParser","RootNode","input","htmlParser","isPreOrCode","_htmlParser","Node","isBlank","flankingWhitespace","edges","edgeWhitespace","isFlankedByWhitespace","m","side","sibling","regExp","isFlanked","reduce","TurndownService","defaults","canConvert","output","process","postProcess","plugin","parentNode","replacementForNode","join","whitespace","s1","s2","nls","separator","emptyOptions","toString","includeImageAlt","includeHtml","one","values","characterEscapeOrReference","decodeString","decode","$0","$1","$2","hex","stringifyPosition","position","pos","own","fromMarkdown","compiler","config","opener","link","onenterdata","codeFlow","emphasis","hardBreak","html","image","listItem","onenterreference","strong","closer","onexitcharacterreference","onexitcodefenced","onexitcodefencedfencemeta","onexitcodeindented","onexithtmlflow","onexithtmltext","onexitimage","onexitlink","onexitresource","configure","tree","handler","defaultOnError","listSpread","firstBlankLineIndex","tailIndex","tailEvent","and","errorHandler","onExitError","ancestor","depth","siblings","referenceType","fragment","children","d","combined","gfmStrikethroughFromMarkdown","enterStrikethrough","exitStrikethrough","convert","castFactory","anyFactory","propertiesFactory","typeFactory","tests","checks","any","checkAsRecord","nodeAsRecord","testFunction","looksLikeANode","empty","CONTINUE","EXIT","SKIP","visitParents","visitor","reverse","step","factory","parents","visit","subresult","grandparents","toResult","nodeAsParent","child","testOrVisitor","visitorOrReverse","maybeReverse","overload","setCodeBlockLanguage","selectionStart","fencePattern","openingFence","fenceMatch","fenceStart","newlineIndex","fenceEnd","getFormatsFromDecorations","decorations","marks","headingLevel","rmeStyles","css","_sourceHighlightSheet","MICROMARK_OPTIONS","MDAST_OPTIONS","SAFE_RICH_ELEMENTS","isSafeLinkHref","trimmed","sanitizeRichMarkup","markup","_turndown","_content","$pre","$code","DECORATION_MAP","_RcMarkdownEditor","LitElement","_e","md","e","action","codeLanguage","nextSourceMode","sel","range","$anchor","$el","$a","$popover","v","old","$textarea","changed","nextMode","nothing","markdown","langs","$pres","lang","api","formats","to","style","dec","newTag","editor","wrap","wordInfo","pre","suf","level","stripped","nextValue","selectionEnd","lineEndIdx","lineEnd","prevNewline","prevLine","afterEnd","nextNewline","nextLine","unwrapStart","unwrapEnd","inner","selected","$existingPre","$p","unwrapRange","innerRange","$toolbar","$label","modify","rangeRect","hostRect","mode","RcMarkdownEditor","__decorateClass","property","query","icon","svg","icons","HEADING_OPTIONS","RcEditorToolbar","$btn","extra","active"],"mappings":";;;;;AAIA,MAAMA,KAAU,SAAS,cAAc,GAAG;AAMnC,SAASC,GAA8BC,GAAO;AACnD,QAAMC,IAAqB,MAAMD,IAAQ;AACzC,EAAAF,GAAQ,YAAYG;AACpB,QAAMC,IAAYJ,GAAQ;AAQ1B,SACEI,EAAU,WAAWA,EAAU,SAAS,CAAC,MAAM,MAC/CF,MAAU,UAOLE,MAAcD,IALZ,KAKyCC;AACpD;ACTO,SAASC,GAAOC,GAAMC,GAAOC,GAAQC,GAAO;AACjD,QAAMC,IAAMJ,EAAK;AACjB,MAAIK,IAAa,GAEbC;AAWJ,MARIL,IAAQ,IACVA,IAAQ,CAACA,IAAQG,IAAM,IAAIA,IAAMH,IAEjCA,IAAQA,IAAQG,IAAMA,IAAMH,GAE9BC,IAASA,IAAS,IAAIA,IAAS,GAG3BC,EAAM,SAAS;AACjB,IAAAG,IAAa,MAAM,KAAKH,CAAK,GAC7BG,EAAW,QAAQL,GAAOC,CAAM,GAEhCF,EAAK,OAAO,GAAGM,CAAU;AAAA;AAMzB,SAHIJ,KAAQF,EAAK,OAAOC,GAAOC,CAAM,GAG9BG,IAAaF,EAAM;AACxB,MAAAG,IAAaH,EAAM,MAAME,GAAYA,IAAa,GAAK,GACvDC,EAAW,QAAQL,GAAO,CAAC,GAE3BD,EAAK,OAAO,GAAGM,CAAU,GACzBD,KAAc,KACdJ,KAAS;AAGf;AAkBO,SAASM,EAAKP,GAAMG,GAAO;AAChC,SAAIH,EAAK,SAAS,KAChBD,GAAOC,GAAMA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AS,EAAE,WAAW,iBAAA,CAAkB;AAAA,GA9B9BM,GA+BX,WAAA,eAAA;AAIAP,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM,WAAW,qBAAqB;AAAA,GAlC/DM,GAmCX,WAAA,kBAAA;AAIAP,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM,WAAW,sBAAsB;AAAA,GAtChEM,GAuCX,WAAA,kBAAA;AAIAP,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM,WAAW,uBAAuB;AAAA,GA1CjEM,GA2CX,WAAA,mBAAA;AAIAP,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM,WAAW,qBAAqB;AAAA,GA9C/DM,GA+CX,WAAA,iBAAA;AAOAP,EAAA;AAAA,EADCC,EAAS,EAAE,WAAW,gBAAA,CAAiB;AAAA,GArD7BM,GAsDX,WAAA,cAAA;AAIAP,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM,WAAW,eAAe;AAAA,GAzDzDM,GA0DX,WAAA,YAAA;AAGUP,EAAA;AAAA,EADTzmB,GAAA;AAAM,GA5DIgnB,GA6DD,WAAA,iBAAA;","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60]}
1
+ {"version":3,"file":"rc-editor-toolbar-QnCEnJ2R.js","sources":["../../../node_modules/decode-named-character-reference/index.dom.js","../../../node_modules/micromark-util-chunked/index.js","../../../node_modules/micromark-util-combine-extensions/index.js","../../../node_modules/micromark-util-decode-numeric-character-reference/index.js","../../../node_modules/micromark-util-encode/index.js","../../../node_modules/micromark-util-normalize-identifier/index.js","../../../node_modules/micromark-util-character/index.js","../../../node_modules/micromark-util-sanitize-uri/index.js","../../../node_modules/micromark/lib/compile.js","../../../node_modules/micromark-factory-space/index.js","../../../node_modules/micromark/lib/initialize/content.js","../../../node_modules/micromark/lib/initialize/document.js","../../../node_modules/micromark-util-classify-character/index.js","../../../node_modules/micromark-util-resolve-all/index.js","../../../node_modules/micromark-core-commonmark/lib/attention.js","../../../node_modules/micromark-core-commonmark/lib/autolink.js","../../../node_modules/micromark-core-commonmark/lib/blank-line.js","../../../node_modules/micromark-core-commonmark/lib/block-quote.js","../../../node_modules/micromark-core-commonmark/lib/character-escape.js","../../../node_modules/micromark-core-commonmark/lib/character-reference.js","../../../node_modules/micromark-core-commonmark/lib/code-fenced.js","../../../node_modules/micromark-core-commonmark/lib/code-indented.js","../../../node_modules/micromark-core-commonmark/lib/code-text.js","../../../node_modules/micromark-util-subtokenize/lib/splice-buffer.js","../../../node_modules/micromark-util-subtokenize/index.js","../../../node_modules/micromark-core-commonmark/lib/content.js","../../../node_modules/micromark-factory-destination/index.js","../../../node_modules/micromark-factory-label/index.js","../../../node_modules/micromark-factory-title/index.js","../../../node_modules/micromark-factory-whitespace/index.js","../../../node_modules/micromark-core-commonmark/lib/definition.js","../../../node_modules/micromark-core-commonmark/lib/hard-break-escape.js","../../../node_modules/micromark-core-commonmark/lib/heading-atx.js","../../../node_modules/micromark-util-html-tag-name/index.js","../../../node_modules/micromark-core-commonmark/lib/html-flow.js","../../../node_modules/micromark-core-commonmark/lib/html-text.js","../../../node_modules/micromark-core-commonmark/lib/label-end.js","../../../node_modules/micromark-core-commonmark/lib/label-start-image.js","../../../node_modules/micromark-core-commonmark/lib/label-start-link.js","../../../node_modules/micromark-core-commonmark/lib/line-ending.js","../../../node_modules/micromark-core-commonmark/lib/thematic-break.js","../../../node_modules/micromark-core-commonmark/lib/list.js","../../../node_modules/micromark-core-commonmark/lib/setext-underline.js","../../../node_modules/micromark/lib/initialize/flow.js","../../../node_modules/micromark/lib/initialize/text.js","../../../node_modules/micromark/lib/constructs.js","../../../node_modules/micromark/lib/create-tokenizer.js","../../../node_modules/micromark/lib/parse.js","../../../node_modules/micromark/lib/postprocess.js","../../../node_modules/micromark/lib/preprocess.js","../../../node_modules/micromark/index.js","../../../node_modules/micromark-extension-gfm-strikethrough/lib/syntax.js","../../../node_modules/turndown/lib/turndown.browser.es.js","../../../node_modules/mdast-util-to-string/lib/index.js","../../../node_modules/micromark-util-decode-string/index.js","../../../node_modules/unist-util-stringify-position/lib/index.js","../../../node_modules/mdast-util-from-markdown/lib/index.js","../../../node_modules/mdast-util-gfm-strikethrough/lib/index.js","../../../node_modules/unist-util-is/lib/index.js","../../../node_modules/unist-util-visit-parents/lib/index.js","../../../node_modules/unist-util-visit/lib/index.js","../src/formatting.ts","../src/rc-markdown-editor.styles.ts","../src/rc-markdown-editor.ts","../src/icons.ts","../src/rc-editor-toolbar.ts"],"sourcesContent":["/// <reference lib=\"dom\" />\n\n/* global document */\n\nconst element = document.createElement('i')\n\n/**\n * @param {string} value\n * @returns {string | false}\n */\nexport function decodeNamedCharacterReference(value) {\n const characterReference = '&' + value + ';'\n element.innerHTML = characterReference\n const character = element.textContent\n\n // Some named character references do not require the closing semicolon\n // (`&not`, for instance), which leads to situations where parsing the assumed\n // named reference of `&notit;` will result in the string `¬it;`.\n // When we encounter a trailing semicolon after parsing, and the character\n // reference to decode was not a semicolon (`&semi;`), we can assume that the\n // matching was not complete.\n if (\n character.charCodeAt(character.length - 1) === 59 /* `;` */ &&\n value !== 'semi'\n ) {\n return false\n }\n\n // If the decoded string is equal to the input, the character reference was\n // not valid.\n return character === characterReference ? false : character\n}\n","/**\n * Like `Array#splice`, but smarter for giant arrays.\n *\n * `Array#splice` takes all items to be inserted as individual argument which\n * causes a stack overflow in V8 when trying to insert 100k items for instance.\n *\n * Otherwise, this does not return the removed items, and takes `items` as an\n * array instead of rest parameters.\n *\n * @template {unknown} T\n * Item type.\n * @param {Array<T>} list\n * List to operate on.\n * @param {number} start\n * Index to remove/insert at (can be negative).\n * @param {number} remove\n * Number of items to remove.\n * @param {Array<T>} items\n * Items to inject into `list`.\n * @returns {undefined}\n * Nothing.\n */\nexport function splice(list, start, remove, items) {\n const end = list.length;\n let chunkStart = 0;\n /** @type {Array<unknown>} */\n let parameters;\n\n // Make start between zero and `end` (included).\n if (start < 0) {\n start = -start > end ? 0 : end + start;\n } else {\n start = start > end ? end : start;\n }\n remove = remove > 0 ? remove : 0;\n\n // No need to chunk the items if there’s only a couple (10k) items.\n if (items.length < 10000) {\n parameters = Array.from(items);\n parameters.unshift(start, remove);\n // @ts-expect-error Hush, it’s fine.\n list.splice(...parameters);\n } else {\n // Delete `remove` items starting from `start`\n if (remove) list.splice(start, remove);\n\n // Insert the items in chunks to not cause stack overflows.\n while (chunkStart < items.length) {\n parameters = items.slice(chunkStart, chunkStart + 10000);\n parameters.unshift(start, 0);\n // @ts-expect-error Hush, it’s fine.\n list.splice(...parameters);\n chunkStart += 10000;\n start += 10000;\n }\n }\n}\n\n/**\n * Append `items` (an array) at the end of `list` (another array).\n * When `list` was empty, returns `items` instead.\n *\n * This prevents a potentially expensive operation when `list` is empty,\n * and adds items in batches to prevent V8 from hanging.\n *\n * @template {unknown} T\n * Item type.\n * @param {Array<T>} list\n * List to operate on.\n * @param {Array<T>} items\n * Items to add to `list`.\n * @returns {Array<T>}\n * Either `list` or `items`.\n */\nexport function push(list, items) {\n if (list.length > 0) {\n splice(list, list.length, 0, items);\n return list;\n }\n return items;\n}","/**\n * @import {\n * Extension,\n * Handles,\n * HtmlExtension,\n * NormalizedExtension\n * } from 'micromark-util-types'\n */\n\nimport {splice} from 'micromark-util-chunked'\n\nconst hasOwnProperty = {}.hasOwnProperty\n\n/**\n * Combine multiple syntax extensions into one.\n *\n * @param {ReadonlyArray<Extension>} extensions\n * List of syntax extensions.\n * @returns {NormalizedExtension}\n * A single combined extension.\n */\nexport function combineExtensions(extensions) {\n /** @type {NormalizedExtension} */\n const all = {}\n let index = -1\n\n while (++index < extensions.length) {\n syntaxExtension(all, extensions[index])\n }\n\n return all\n}\n\n/**\n * Merge `extension` into `all`.\n *\n * @param {NormalizedExtension} all\n * Extension to merge into.\n * @param {Extension} extension\n * Extension to merge.\n * @returns {undefined}\n * Nothing.\n */\nfunction syntaxExtension(all, extension) {\n /** @type {keyof Extension} */\n let hook\n\n for (hook in extension) {\n const maybe = hasOwnProperty.call(all, hook) ? all[hook] : undefined\n /** @type {Record<string, unknown>} */\n const left = maybe || (all[hook] = {})\n /** @type {Record<string, unknown> | undefined} */\n const right = extension[hook]\n /** @type {string} */\n let code\n\n if (right) {\n for (code in right) {\n if (!hasOwnProperty.call(left, code)) left[code] = []\n const value = right[code]\n constructs(\n // @ts-expect-error Looks like a list.\n left[code],\n Array.isArray(value) ? value : value ? [value] : []\n )\n }\n }\n }\n}\n\n/**\n * Merge `list` into `existing` (both lists of constructs).\n * Mutates `existing`.\n *\n * @param {Array<unknown>} existing\n * List of constructs to merge into.\n * @param {Array<unknown>} list\n * List of constructs to merge.\n * @returns {undefined}\n * Nothing.\n */\nfunction constructs(existing, list) {\n let index = -1\n /** @type {Array<unknown>} */\n const before = []\n\n while (++index < list.length) {\n // @ts-expect-error Looks like an object.\n ;(list[index].add === 'after' ? existing : before).push(list[index])\n }\n\n splice(existing, 0, 0, before)\n}\n\n/**\n * Combine multiple HTML extensions into one.\n *\n * @param {ReadonlyArray<HtmlExtension>} htmlExtensions\n * List of HTML extensions.\n * @returns {HtmlExtension}\n * Single combined HTML extension.\n */\nexport function combineHtmlExtensions(htmlExtensions) {\n /** @type {HtmlExtension} */\n const handlers = {}\n let index = -1\n\n while (++index < htmlExtensions.length) {\n htmlExtension(handlers, htmlExtensions[index])\n }\n\n return handlers\n}\n\n/**\n * Merge `extension` into `all`.\n *\n * @param {HtmlExtension} all\n * Extension to merge into.\n * @param {HtmlExtension} extension\n * Extension to merge.\n * @returns {undefined}\n * Nothing.\n */\nfunction htmlExtension(all, extension) {\n /** @type {keyof HtmlExtension} */\n let hook\n\n for (hook in extension) {\n const maybe = hasOwnProperty.call(all, hook) ? all[hook] : undefined\n const left = maybe || (all[hook] = {})\n const right = extension[hook]\n /** @type {keyof Handles} */\n let type\n\n if (right) {\n for (type in right) {\n // @ts-expect-error assume document vs regular handler are managed correctly.\n left[type] = right[type]\n }\n }\n }\n}\n","/**\n * Turn the number (in string form as either hexa- or plain decimal) coming from\n * a numeric character reference into a character.\n *\n * Sort of like `String.fromCodePoint(Number.parseInt(value, base))`, but makes\n * non-characters and control characters safe.\n *\n * @param {string} value\n * Value to decode.\n * @param {number} base\n * Numeric base.\n * @returns {string}\n * Character.\n */\nexport function decodeNumericCharacterReference(value, base) {\n const code = Number.parseInt(value, base);\n if (\n // C0 except for HT, LF, FF, CR, space.\n code < 9 || code === 11 || code > 13 && code < 32 ||\n // Control character (DEL) of C0, and C1 controls.\n code > 126 && code < 160 ||\n // Lone high surrogates and low surrogates.\n code > 55_295 && code < 57_344 ||\n // Noncharacters.\n code > 64_975 && code < 65_008 || /* eslint-disable no-bitwise */\n (code & 65_535) === 65_535 || (code & 65_535) === 65_534 || /* eslint-enable no-bitwise */\n // Out of range\n code > 1_114_111) {\n return \"\\uFFFD\";\n }\n return String.fromCodePoint(code);\n}","const characterReferences = {'\"': 'quot', '&': 'amp', '<': 'lt', '>': 'gt'}\n\n/**\n * Encode only the dangerous HTML characters.\n *\n * This ensures that certain characters which have special meaning in HTML are\n * dealt with.\n * Technically, we can skip `>` and `\"` in many cases, but CM includes them.\n *\n * @param {string} value\n * Value to encode.\n * @returns {string}\n * Encoded value.\n */\nexport function encode(value) {\n return value.replace(/[\"&<>]/g, replace)\n\n /**\n * @param {string} value\n * Value to replace.\n * @returns {string}\n * Encoded value.\n */\n function replace(value) {\n return (\n '&' +\n characterReferences[\n /** @type {keyof typeof characterReferences} */ (value)\n ] +\n ';'\n )\n }\n}\n","/**\n * Normalize an identifier (as found in references, definitions).\n *\n * Collapses markdown whitespace, trim, and then lower- and uppercase.\n *\n * Some characters are considered “uppercase”, such as U+03F4 (`ϴ`), but if their\n * lowercase counterpart (U+03B8 (`θ`)) is uppercased will result in a different\n * uppercase character (U+0398 (`Θ`)).\n * So, to get a canonical form, we perform both lower- and uppercase.\n *\n * Using uppercase last makes sure keys will never interact with default\n * prototypal values (such as `constructor`): nothing in the prototype of\n * `Object` is uppercase.\n *\n * @param {string} value\n * Identifier to normalize.\n * @returns {string}\n * Normalized identifier.\n */\nexport function normalizeIdentifier(value) {\n return value\n // Collapse markdown whitespace.\n .replace(/[\\t\\n\\r ]+/g, \" \")\n // Trim.\n .replace(/^ | $/g, '')\n // Some characters are considered “uppercase”, but if their lowercase\n // counterpart is uppercased will result in a different uppercase\n // character.\n // Hence, to get that form, we perform both lower- and uppercase.\n // Upper case makes sure keys will not interact with default prototypal\n // methods: no method is uppercase.\n .toLowerCase().toUpperCase();\n}","/**\n * @import {Code} from 'micromark-util-types'\n */\n\n/**\n * Check whether the character code represents an ASCII alpha (`a` through `z`,\n * case insensitive).\n *\n * An **ASCII alpha** is an ASCII upper alpha or ASCII lower alpha.\n *\n * An **ASCII upper alpha** is a character in the inclusive range U+0041 (`A`)\n * to U+005A (`Z`).\n *\n * An **ASCII lower alpha** is a character in the inclusive range U+0061 (`a`)\n * to U+007A (`z`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiAlpha = regexCheck(/[A-Za-z]/);\n\n/**\n * Check whether the character code represents an ASCII alphanumeric (`a`\n * through `z`, case insensitive, or `0` through `9`).\n *\n * An **ASCII alphanumeric** is an ASCII digit (see `asciiDigit`) or ASCII alpha\n * (see `asciiAlpha`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiAlphanumeric = regexCheck(/[\\dA-Za-z]/);\n\n/**\n * Check whether the character code represents an ASCII atext.\n *\n * atext is an ASCII alphanumeric (see `asciiAlphanumeric`), or a character in\n * the inclusive ranges U+0023 NUMBER SIGN (`#`) to U+0027 APOSTROPHE (`'`),\n * U+002A ASTERISK (`*`), U+002B PLUS SIGN (`+`), U+002D DASH (`-`), U+002F\n * SLASH (`/`), U+003D EQUALS TO (`=`), U+003F QUESTION MARK (`?`), U+005E\n * CARET (`^`) to U+0060 GRAVE ACCENT (`` ` ``), or U+007B LEFT CURLY BRACE\n * (`{`) to U+007E TILDE (`~`).\n *\n * See:\n * **\\[RFC5322]**:\n * [Internet Message Format](https://tools.ietf.org/html/rfc5322).\n * P. Resnick.\n * IETF.\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiAtext = regexCheck(/[#-'*+\\--9=?A-Z^-~]/);\n\n/**\n * Check whether a character code is an ASCII control character.\n *\n * An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL)\n * to U+001F (US), or U+007F (DEL).\n *\n * @param {Code} code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport function asciiControl(code) {\n return (\n // Special whitespace codes (which have negative values), C0 and Control\n // character DEL\n code !== null && (code < 32 || code === 127)\n );\n}\n\n/**\n * Check whether the character code represents an ASCII digit (`0` through `9`).\n *\n * An **ASCII digit** is a character in the inclusive range U+0030 (`0`) to\n * U+0039 (`9`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiDigit = regexCheck(/\\d/);\n\n/**\n * Check whether the character code represents an ASCII hex digit (`a` through\n * `f`, case insensitive, or `0` through `9`).\n *\n * An **ASCII hex digit** is an ASCII digit (see `asciiDigit`), ASCII upper hex\n * digit, or an ASCII lower hex digit.\n *\n * An **ASCII upper hex digit** is a character in the inclusive range U+0041\n * (`A`) to U+0046 (`F`).\n *\n * An **ASCII lower hex digit** is a character in the inclusive range U+0061\n * (`a`) to U+0066 (`f`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiHexDigit = regexCheck(/[\\dA-Fa-f]/);\n\n/**\n * Check whether the character code represents ASCII punctuation.\n *\n * An **ASCII punctuation** is a character in the inclusive ranges U+0021\n * EXCLAMATION MARK (`!`) to U+002F SLASH (`/`), U+003A COLON (`:`) to U+0040 AT\n * SIGN (`@`), U+005B LEFT SQUARE BRACKET (`[`) to U+0060 GRAVE ACCENT\n * (`` ` ``), or U+007B LEFT CURLY BRACE (`{`) to U+007E TILDE (`~`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/);\n\n/**\n * Check whether a character code is a markdown line ending.\n *\n * A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN\n * LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR).\n *\n * In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE\n * RETURN (CR) are replaced by these virtual characters depending on whether\n * they occurred together.\n *\n * @param {Code} code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport function markdownLineEnding(code) {\n return code !== null && code < -2;\n}\n\n/**\n * Check whether a character code is a markdown line ending (see\n * `markdownLineEnding`) or markdown space (see `markdownSpace`).\n *\n * @param {Code} code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport function markdownLineEndingOrSpace(code) {\n return code !== null && (code < 0 || code === 32);\n}\n\n/**\n * Check whether a character code is a markdown space.\n *\n * A **markdown space** is the concrete character U+0020 SPACE (SP) and the\n * virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT).\n *\n * In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is\n * replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL\n * SPACE (VS) characters, depending on the column at which the tab occurred.\n *\n * @param {Code} code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport function markdownSpace(code) {\n return code === -2 || code === -1 || code === 32;\n}\n\n// Size note: removing ASCII from the regex and using `asciiPunctuation` here\n// In fact adds to the bundle size.\n/**\n * Check whether the character code represents Unicode punctuation.\n *\n * A **Unicode punctuation** is a character in the Unicode `Pc` (Punctuation,\n * Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf`\n * (Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po`\n * (Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an ASCII\n * punctuation (see `asciiPunctuation`).\n *\n * See:\n * **\\[UNICODE]**:\n * [The Unicode Standard](https://www.unicode.org/versions/).\n * Unicode Consortium.\n *\n * @param code\n * Code.\n * @returns\n * Whether it matches.\n */\nexport const unicodePunctuation = regexCheck(/\\p{P}|\\p{S}/u);\n\n/**\n * Check whether the character code represents Unicode whitespace.\n *\n * Note that this does handle micromark specific markdown whitespace characters.\n * See `markdownLineEndingOrSpace` to check that.\n *\n * A **Unicode whitespace** is a character in the Unicode `Zs` (Separator,\n * Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF),\n * U+000C (FF), or U+000D CARRIAGE RETURN (CR) (**\\[UNICODE]**).\n *\n * See:\n * **\\[UNICODE]**:\n * [The Unicode Standard](https://www.unicode.org/versions/).\n * Unicode Consortium.\n *\n * @param code\n * Code.\n * @returns\n * Whether it matches.\n */\nexport const unicodeWhitespace = regexCheck(/\\s/);\n\n/**\n * Create a code check from a regex.\n *\n * @param {RegExp} regex\n * Expression.\n * @returns {(code: Code) => boolean}\n * Check.\n */\nfunction regexCheck(regex) {\n return check;\n\n /**\n * Check whether a code matches the bound regex.\n *\n * @param {Code} code\n * Character code.\n * @returns {boolean}\n * Whether the character code matches the bound regex.\n */\n function check(code) {\n return code !== null && code > -1 && regex.test(String.fromCharCode(code));\n }\n}","import { asciiAlphanumeric } from 'micromark-util-character';\nimport { encode } from 'micromark-util-encode';\n/**\n * Make a value safe for injection as a URL.\n *\n * This encodes unsafe characters with percent-encoding and skips already\n * encoded sequences (see `normalizeUri`).\n * Further unsafe characters are encoded as character references (see\n * `micromark-util-encode`).\n *\n * A regex of allowed protocols can be given, in which case the URL is\n * sanitized.\n * For example, `/^(https?|ircs?|mailto|xmpp)$/i` can be used for `a[href]`, or\n * `/^https?$/i` for `img[src]` (this is what `github.com` allows).\n * If the URL includes an unknown protocol (one not matched by `protocol`, such\n * as a dangerous example, `javascript:`), the value is ignored.\n *\n * @param {string | null | undefined} url\n * URI to sanitize.\n * @param {RegExp | null | undefined} [protocol]\n * Allowed protocols.\n * @returns {string}\n * Sanitized URI.\n */\nexport function sanitizeUri(url, protocol) {\n const value = encode(normalizeUri(url || ''));\n if (!protocol) {\n return value;\n }\n const colon = value.indexOf(':');\n const questionMark = value.indexOf('?');\n const numberSign = value.indexOf('#');\n const slash = value.indexOf('/');\n if (\n // If there is no protocol, it’s relative.\n colon < 0 ||\n // If the first colon is after a `?`, `#`, or `/`, it’s not a protocol.\n slash > -1 && colon > slash || questionMark > -1 && colon > questionMark || numberSign > -1 && colon > numberSign ||\n // It is a protocol, it should be allowed.\n protocol.test(value.slice(0, colon))) {\n return value;\n }\n return '';\n}\n\n/**\n * Normalize a URL.\n *\n * Encode unsafe characters with percent-encoding, skipping already encoded\n * sequences.\n *\n * @param {string} value\n * URI to normalize.\n * @returns {string}\n * Normalized URI.\n */\nexport function normalizeUri(value) {\n /** @type {Array<string>} */\n const result = [];\n let index = -1;\n let start = 0;\n let skip = 0;\n while (++index < value.length) {\n const code = value.charCodeAt(index);\n /** @type {string} */\n let replace = '';\n\n // A correct percent encoded value.\n if (code === 37 && asciiAlphanumeric(value.charCodeAt(index + 1)) && asciiAlphanumeric(value.charCodeAt(index + 2))) {\n skip = 2;\n }\n // ASCII.\n else if (code < 128) {\n if (!/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code))) {\n replace = String.fromCharCode(code);\n }\n }\n // Astral.\n else if (code > 55_295 && code < 57_344) {\n const next = value.charCodeAt(index + 1);\n\n // A correct surrogate pair.\n if (code < 56_320 && next > 56_319 && next < 57_344) {\n replace = String.fromCharCode(code, next);\n skip = 1;\n }\n // Lone surrogate.\n else {\n replace = \"\\uFFFD\";\n }\n }\n // Unicode.\n else {\n replace = String.fromCharCode(code);\n }\n if (replace) {\n result.push(value.slice(start, index), encodeURIComponent(replace));\n start = index + skip + 1;\n replace = '';\n }\n if (skip) {\n index += skip;\n skip = 0;\n }\n }\n return result.join('') + value.slice(start);\n}","/**\n * While micromark is a lexer/tokenizer, the common case of going from markdown\n * to html is currently built in as this module, even though the parts can be\n * used separately to build ASTs, CSTs, or many other output formats.\n *\n * Having an HTML compiler built in is useful because it allows us to check for\n * compliancy to CommonMark, the de facto norm of markdown, specified in roughly\n * 600 input/output cases.\n *\n * This module has an interface that accepts lists of events instead of the\n * whole at once, however, because markdown can’t be truly streaming, we buffer\n * events before processing and outputting the final result.\n */\n\n/**\n * @import {\n * CompileContext,\n * CompileData,\n * CompileOptions,\n * Compile,\n * Definition,\n * Event,\n * Handle,\n * HtmlExtension,\n * LineEnding,\n * NormalizedHtmlExtension,\n * Token\n * } from 'micromark-util-types'\n */\n\n/**\n * @typedef Media\n * @property {boolean | undefined} [image]\n * @property {string | undefined} [labelId]\n * @property {string | undefined} [label]\n * @property {string | undefined} [referenceId]\n * @property {string | undefined} [destination]\n * @property {string | undefined} [title]\n */\n\nimport { decodeNamedCharacterReference } from 'decode-named-character-reference';\nimport { push } from 'micromark-util-chunked';\nimport { combineHtmlExtensions } from 'micromark-util-combine-extensions';\nimport { decodeNumericCharacterReference } from 'micromark-util-decode-numeric-character-reference';\nimport { encode as _encode } from 'micromark-util-encode';\nimport { normalizeIdentifier } from 'micromark-util-normalize-identifier';\nimport { sanitizeUri } from 'micromark-util-sanitize-uri';\nconst hasOwnProperty = {}.hasOwnProperty;\n\n/**\n * These two are allowlists of safe protocols for full URLs in respectively the\n * `href` (on `<a>`) and `src` (on `<img>`) attributes.\n * They are based on what is allowed on GitHub,\n * <https://github.com/syntax-tree/hast-util-sanitize/blob/9275b21/lib/github.json#L31>\n */\nconst protocolHref = /^(https?|ircs?|mailto|xmpp)$/i;\nconst protocolSource = /^https?$/i;\n\n/**\n * @param {CompileOptions | null | undefined} [options]\n * @returns {Compile}\n */\nexport function compile(options) {\n const settings = options || {};\n\n /**\n * Tags is needed because according to markdown, links and emphasis and\n * whatnot can exist in images, however, as HTML doesn’t allow content in\n * images, the tags are ignored in the `alt` attribute, but the content\n * remains.\n *\n * @type {boolean | undefined}\n */\n let tags = true;\n\n /**\n * An object to track identifiers to media (URLs and titles) defined with\n * definitions.\n *\n * @type {Record<string, Definition>}\n */\n const definitions = {};\n\n /**\n * A lot of the handlers need to capture some of the output data, modify it\n * somehow, and then deal with it.\n * We do that by tracking a stack of buffers, that can be opened (with\n * `buffer`) and closed (with `resume`) to access them.\n *\n * @type {Array<Array<string>>}\n */\n const buffers = [[]];\n\n /**\n * As we can have links in images and the other way around, where the deepest\n * ones are closed first, we need to track which one we’re in.\n *\n * @type {Array<Media>}\n */\n const mediaStack = [];\n\n /**\n * Same as `mediaStack` for tightness, which is specific to lists.\n * We need to track if we’re currently in a tight or loose container.\n *\n * @type {Array<boolean>}\n */\n const tightStack = [];\n\n /** @type {HtmlExtension} */\n const defaultHandlers = {\n enter: {\n blockQuote: onenterblockquote,\n codeFenced: onentercodefenced,\n codeFencedFenceInfo: buffer,\n codeFencedFenceMeta: buffer,\n codeIndented: onentercodeindented,\n codeText: onentercodetext,\n content: onentercontent,\n definition: onenterdefinition,\n definitionDestinationString: onenterdefinitiondestinationstring,\n definitionLabelString: buffer,\n definitionTitleString: buffer,\n emphasis: onenteremphasis,\n htmlFlow: onenterhtmlflow,\n htmlText: onenterhtml,\n image: onenterimage,\n label: buffer,\n link: onenterlink,\n listItemMarker: onenterlistitemmarker,\n listItemValue: onenterlistitemvalue,\n listOrdered: onenterlistordered,\n listUnordered: onenterlistunordered,\n paragraph: onenterparagraph,\n reference: buffer,\n resource: onenterresource,\n resourceDestinationString: onenterresourcedestinationstring,\n resourceTitleString: buffer,\n setextHeading: onentersetextheading,\n strong: onenterstrong\n },\n exit: {\n atxHeading: onexitatxheading,\n atxHeadingSequence: onexitatxheadingsequence,\n autolinkEmail: onexitautolinkemail,\n autolinkProtocol: onexitautolinkprotocol,\n blockQuote: onexitblockquote,\n characterEscapeValue: onexitdata,\n characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker,\n characterReferenceMarkerNumeric: onexitcharacterreferencemarker,\n characterReferenceValue: onexitcharacterreferencevalue,\n codeFenced: onexitflowcode,\n codeFencedFence: onexitcodefencedfence,\n codeFencedFenceInfo: onexitcodefencedfenceinfo,\n codeFencedFenceMeta: onresumedrop,\n codeFlowValue: onexitcodeflowvalue,\n codeIndented: onexitflowcode,\n codeText: onexitcodetext,\n codeTextData: onexitdata,\n data: onexitdata,\n definition: onexitdefinition,\n definitionDestinationString: onexitdefinitiondestinationstring,\n definitionLabelString: onexitdefinitionlabelstring,\n definitionTitleString: onexitdefinitiontitlestring,\n emphasis: onexitemphasis,\n hardBreakEscape: onexithardbreak,\n hardBreakTrailing: onexithardbreak,\n htmlFlow: onexithtml,\n htmlFlowData: onexitdata,\n htmlText: onexithtml,\n htmlTextData: onexitdata,\n image: onexitmedia,\n label: onexitlabel,\n labelText: onexitlabeltext,\n lineEnding: onexitlineending,\n link: onexitmedia,\n listOrdered: onexitlistordered,\n listUnordered: onexitlistunordered,\n paragraph: onexitparagraph,\n reference: onresumedrop,\n referenceString: onexitreferencestring,\n resource: onresumedrop,\n resourceDestinationString: onexitresourcedestinationstring,\n resourceTitleString: onexitresourcetitlestring,\n setextHeading: onexitsetextheading,\n setextHeadingLineSequence: onexitsetextheadinglinesequence,\n setextHeadingText: onexitsetextheadingtext,\n strong: onexitstrong,\n thematicBreak: onexitthematicbreak\n }\n };\n\n /**\n * Combine the HTML extensions with the default handlers.\n * An HTML extension is an object whose fields are either `enter` or `exit`\n * (reflecting whether a token is entered or exited).\n * The values at such objects are names of tokens mapping to handlers.\n * Handlers are called, respectively when a token is opener or closed, with\n * that token, and a context as `this`.\n */\n const handlers = /** @type {NormalizedHtmlExtension} */\n combineHtmlExtensions([defaultHandlers, ...(settings.htmlExtensions || [])]);\n\n /**\n * Handlers do often need to keep track of some state.\n * That state is provided here as a key-value store (an object).\n *\n * @type {CompileData}\n */\n const data = {\n definitions,\n tightStack\n };\n\n /**\n * The context for handlers references a couple of useful functions.\n * In handlers from extensions, those can be accessed at `this`.\n * For the handlers here, they can be accessed directly.\n *\n * @type {Omit<CompileContext, 'sliceSerialize'>}\n */\n const context = {\n buffer,\n encode,\n getData,\n lineEndingIfNeeded,\n options: settings,\n raw,\n resume,\n setData,\n tag\n };\n\n /**\n * Generally, micromark copies line endings (`'\\r'`, `'\\n'`, `'\\r\\n'`) in the\n * markdown document over to the compiled HTML.\n * In some cases, such as `> a`, CommonMark requires that extra line endings\n * are added: `<blockquote>\\n<p>a</p>\\n</blockquote>`.\n * This variable hold the default line ending when given (or `undefined`),\n * and in the latter case will be updated to the first found line ending if\n * there is one.\n */\n let lineEndingStyle = settings.defaultLineEnding;\n\n // Return the function that handles a slice of events.\n return compile;\n\n /**\n * Deal w/ a slice of events.\n * Return either the empty string if there’s nothing of note to return, or the\n * result when done.\n *\n * @param {ReadonlyArray<Event>} events\n * @returns {string}\n */\n function compile(events) {\n let index = -1;\n let start = 0;\n /** @type {Array<number>} */\n const listStack = [];\n // As definitions can come after references, we need to figure out the media\n // (urls and titles) defined by them before handling the references.\n // So, we do sort of what HTML does: put metadata at the start (in head), and\n // then put content after (`body`).\n /** @type {Array<Event>} */\n let head = [];\n /** @type {Array<Event>} */\n let body = [];\n while (++index < events.length) {\n // Figure out the line ending style used in the document.\n if (!lineEndingStyle && (events[index][1].type === \"lineEnding\" || events[index][1].type === \"lineEndingBlank\")) {\n lineEndingStyle = /** @type {LineEnding} */\n events[index][2].sliceSerialize(events[index][1]);\n }\n\n // Preprocess lists to infer whether the list is loose or not.\n if (events[index][1].type === \"listOrdered\" || events[index][1].type === \"listUnordered\") {\n if (events[index][0] === 'enter') {\n listStack.push(index);\n } else {\n prepareList(events.slice(listStack.pop(), index));\n }\n }\n\n // Move definitions to the front.\n if (events[index][1].type === \"definition\") {\n if (events[index][0] === 'enter') {\n body = push(body, events.slice(start, index));\n start = index;\n } else {\n head = push(head, events.slice(start, index + 1));\n start = index + 1;\n }\n }\n }\n head = push(head, body);\n head = push(head, events.slice(start));\n index = -1;\n const result = head;\n\n // Handle the start of the document, if defined.\n if (handlers.enter.null) {\n handlers.enter.null.call(context);\n }\n\n // Handle all events.\n while (++index < events.length) {\n const handles = handlers[result[index][0]];\n const kind = result[index][1].type;\n const handle = handles[kind];\n if (hasOwnProperty.call(handles, kind) && handle) {\n handle.call({\n sliceSerialize: result[index][2].sliceSerialize,\n ...context\n }, result[index][1]);\n }\n }\n\n // Handle the end of the document, if defined.\n if (handlers.exit.null) {\n handlers.exit.null.call(context);\n }\n return buffers[0].join('');\n }\n\n /**\n * Figure out whether lists are loose or not.\n *\n * @param {ReadonlyArray<Event>} slice\n * @returns {undefined}\n */\n function prepareList(slice) {\n const length = slice.length;\n let index = 0; // Skip open.\n let containerBalance = 0;\n let loose = false;\n /** @type {boolean | undefined} */\n let atMarker;\n while (++index < length) {\n const event = slice[index];\n if (event[1]._container) {\n atMarker = undefined;\n if (event[0] === 'enter') {\n containerBalance++;\n } else {\n containerBalance--;\n }\n } else switch (event[1].type) {\n case \"listItemPrefix\":\n {\n if (event[0] === 'exit') {\n atMarker = true;\n }\n break;\n }\n case \"linePrefix\":\n {\n // Ignore\n\n break;\n }\n case \"lineEndingBlank\":\n {\n if (event[0] === 'enter' && !containerBalance) {\n if (atMarker) {\n atMarker = undefined;\n } else {\n loose = true;\n }\n }\n break;\n }\n default:\n {\n atMarker = undefined;\n }\n }\n }\n slice[0][1]._loose = loose;\n }\n\n /**\n * @type {CompileContext['setData']}\n */\n function setData(key, value) {\n // @ts-expect-error: assume `value` is omitted (`undefined` is passed) only\n // if allowed.\n data[key] = value;\n }\n\n /**\n * @type {CompileContext['getData']}\n */\n function getData(key) {\n return data[key];\n }\n\n /** @type {CompileContext['buffer']} */\n function buffer() {\n buffers.push([]);\n }\n\n /** @type {CompileContext['resume']} */\n function resume() {\n const buf = buffers.pop();\n return buf.join('');\n }\n\n /** @type {CompileContext['tag']} */\n function tag(value) {\n if (!tags) return;\n setData('lastWasTag', true);\n buffers[buffers.length - 1].push(value);\n }\n\n /** @type {CompileContext['raw']} */\n function raw(value) {\n setData('lastWasTag');\n buffers[buffers.length - 1].push(value);\n }\n\n /**\n * Output an extra line ending.\n *\n * @returns {undefined}\n */\n function lineEnding() {\n raw(lineEndingStyle || '\\n');\n }\n\n /** @type {CompileContext['lineEndingIfNeeded']} */\n function lineEndingIfNeeded() {\n const buffer = buffers[buffers.length - 1];\n const slice = buffer[buffer.length - 1];\n const previous = slice ? slice.charCodeAt(slice.length - 1) : null;\n if (previous === 10 || previous === 13 || previous === null) {\n return;\n }\n lineEnding();\n }\n\n /** @type {CompileContext['encode']} */\n function encode(value) {\n return getData('ignoreEncode') ? value : _encode(value);\n }\n\n //\n // Handlers.\n //\n\n /**\n * @returns {undefined}\n */\n function onresumedrop() {\n resume();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterlistordered(token) {\n tightStack.push(!token._loose);\n lineEndingIfNeeded();\n tag('<ol');\n setData('expectFirstItem', true);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterlistunordered(token) {\n tightStack.push(!token._loose);\n lineEndingIfNeeded();\n tag('<ul');\n setData('expectFirstItem', true);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterlistitemvalue(token) {\n if (getData('expectFirstItem')) {\n const value = Number.parseInt(this.sliceSerialize(token), 10);\n if (value !== 1) {\n tag(' start=\"' + encode(String(value)) + '\"');\n }\n }\n }\n\n /**\n * @returns {undefined}\n */\n function onenterlistitemmarker() {\n if (getData('expectFirstItem')) {\n tag('>');\n } else {\n onexitlistitem();\n }\n lineEndingIfNeeded();\n tag('<li>');\n setData('expectFirstItem');\n // “Hack” to prevent a line ending from showing up if the item is empty.\n setData('lastWasTag');\n }\n\n /**\n * @returns {undefined}\n */\n function onexitlistordered() {\n onexitlistitem();\n tightStack.pop();\n lineEnding();\n tag('</ol>');\n }\n\n /**\n * @returns {undefined}\n */\n function onexitlistunordered() {\n onexitlistitem();\n tightStack.pop();\n lineEnding();\n tag('</ul>');\n }\n\n /**\n * @returns {undefined}\n */\n function onexitlistitem() {\n if (getData('lastWasTag') && !getData('slurpAllLineEndings')) {\n lineEndingIfNeeded();\n }\n tag('</li>');\n setData('slurpAllLineEndings');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterblockquote() {\n tightStack.push(false);\n lineEndingIfNeeded();\n tag('<blockquote>');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitblockquote() {\n tightStack.pop();\n lineEndingIfNeeded();\n tag('</blockquote>');\n setData('slurpAllLineEndings');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterparagraph() {\n if (!tightStack[tightStack.length - 1]) {\n lineEndingIfNeeded();\n tag('<p>');\n }\n setData('slurpAllLineEndings');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitparagraph() {\n if (tightStack[tightStack.length - 1]) {\n setData('slurpAllLineEndings', true);\n } else {\n tag('</p>');\n }\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onentercodefenced() {\n lineEndingIfNeeded();\n tag('<pre><code');\n setData('fencesCount', 0);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefencedfenceinfo() {\n const value = resume();\n tag(' class=\"language-' + value + '\"');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefencedfence() {\n const count = getData('fencesCount') || 0;\n if (!count) {\n tag('>');\n setData('slurpOneLineEnding', true);\n }\n setData('fencesCount', count + 1);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onentercodeindented() {\n lineEndingIfNeeded();\n tag('<pre><code>');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitflowcode() {\n const count = getData('fencesCount');\n\n // One special case is if we are inside a container, and the fenced code was\n // not closed (meaning it runs to the end).\n // In that case, the following line ending, is considered *outside* the\n // fenced code and block quote by micromark, but CM wants to treat that\n // ending as part of the code.\n if (count !== undefined && count < 2 && data.tightStack.length > 0 && !getData('lastWasTag')) {\n lineEnding();\n }\n\n // But in most cases, it’s simpler: when we’ve seen some data, emit an extra\n // line ending when needed.\n if (getData('flowCodeSeenData')) {\n lineEndingIfNeeded();\n }\n tag('</code></pre>');\n if (count !== undefined && count < 2) lineEndingIfNeeded();\n setData('flowCodeSeenData');\n setData('fencesCount');\n setData('slurpOneLineEnding');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterimage() {\n mediaStack.push({\n image: true\n });\n tags = undefined; // Disallow tags.\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterlink() {\n mediaStack.push({});\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitlabeltext(token) {\n mediaStack[mediaStack.length - 1].labelId = this.sliceSerialize(token);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitlabel() {\n mediaStack[mediaStack.length - 1].label = resume();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitreferencestring(token) {\n mediaStack[mediaStack.length - 1].referenceId = this.sliceSerialize(token);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterresource() {\n buffer(); // We can have line endings in the resource, ignore them.\n mediaStack[mediaStack.length - 1].destination = '';\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterresourcedestinationstring() {\n buffer();\n // Ignore encoding the result, as we’ll first percent encode the url and\n // encode manually after.\n setData('ignoreEncode', true);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitresourcedestinationstring() {\n mediaStack[mediaStack.length - 1].destination = resume();\n setData('ignoreEncode');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitresourcetitlestring() {\n mediaStack[mediaStack.length - 1].title = resume();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitmedia() {\n let index = mediaStack.length - 1; // Skip current.\n const media = mediaStack[index];\n const id = media.referenceId || media.labelId;\n const context = media.destination === undefined ? definitions[normalizeIdentifier(id)] : media;\n tags = true;\n while (index--) {\n if (mediaStack[index].image) {\n tags = undefined;\n break;\n }\n }\n if (media.image) {\n tag('<img src=\"' + sanitizeUri(context.destination, settings.allowDangerousProtocol ? undefined : protocolSource) + '\" alt=\"');\n raw(media.label);\n tag('\"');\n } else {\n tag('<a href=\"' + sanitizeUri(context.destination, settings.allowDangerousProtocol ? undefined : protocolHref) + '\"');\n }\n tag(context.title ? ' title=\"' + context.title + '\"' : '');\n if (media.image) {\n tag(' />');\n } else {\n tag('>');\n raw(media.label);\n tag('</a>');\n }\n mediaStack.pop();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterdefinition() {\n buffer();\n mediaStack.push({});\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitionlabelstring(token) {\n // Discard label, use the source content instead.\n resume();\n mediaStack[mediaStack.length - 1].labelId = this.sliceSerialize(token);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterdefinitiondestinationstring() {\n buffer();\n setData('ignoreEncode', true);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitiondestinationstring() {\n mediaStack[mediaStack.length - 1].destination = resume();\n setData('ignoreEncode');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitiontitlestring() {\n mediaStack[mediaStack.length - 1].title = resume();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinition() {\n const media = mediaStack[mediaStack.length - 1];\n const id = normalizeIdentifier(media.labelId);\n resume();\n if (!hasOwnProperty.call(definitions, id)) {\n definitions[id] = mediaStack[mediaStack.length - 1];\n }\n mediaStack.pop();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onentercontent() {\n setData('slurpAllLineEndings', true);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitatxheadingsequence(token) {\n // Exit for further sequences.\n if (getData('headingRank')) return;\n setData('headingRank', this.sliceSerialize(token).length);\n lineEndingIfNeeded();\n tag('<h' + getData('headingRank') + '>');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onentersetextheading() {\n buffer();\n setData('slurpAllLineEndings');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheadingtext() {\n setData('slurpAllLineEndings', true);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitatxheading() {\n tag('</h' + getData('headingRank') + '>');\n setData('headingRank');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheadinglinesequence(token) {\n setData('headingRank', this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheading() {\n const value = resume();\n lineEndingIfNeeded();\n tag('<h' + getData('headingRank') + '>');\n raw(value);\n tag('</h' + getData('headingRank') + '>');\n setData('slurpAllLineEndings');\n setData('headingRank');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdata(token) {\n raw(encode(this.sliceSerialize(token)));\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitlineending(token) {\n if (getData('slurpAllLineEndings')) {\n return;\n }\n if (getData('slurpOneLineEnding')) {\n setData('slurpOneLineEnding');\n return;\n }\n if (getData('inCodeText')) {\n raw(' ');\n return;\n }\n raw(encode(this.sliceSerialize(token)));\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodeflowvalue(token) {\n raw(encode(this.sliceSerialize(token)));\n setData('flowCodeSeenData', true);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexithardbreak() {\n tag('<br />');\n }\n\n /**\n * @returns {undefined}\n */\n function onenterhtmlflow() {\n lineEndingIfNeeded();\n onenterhtml();\n }\n\n /**\n * @returns {undefined}\n */\n function onexithtml() {\n setData('ignoreEncode');\n }\n\n /**\n * @returns {undefined}\n */\n function onenterhtml() {\n if (settings.allowDangerousHtml) {\n setData('ignoreEncode', true);\n }\n }\n\n /**\n * @returns {undefined}\n */\n function onenteremphasis() {\n tag('<em>');\n }\n\n /**\n * @returns {undefined}\n */\n function onenterstrong() {\n tag('<strong>');\n }\n\n /**\n * @returns {undefined}\n */\n function onentercodetext() {\n setData('inCodeText', true);\n tag('<code>');\n }\n\n /**\n * @returns {undefined}\n */\n function onexitcodetext() {\n setData('inCodeText');\n tag('</code>');\n }\n\n /**\n * @returns {undefined}\n */\n function onexitemphasis() {\n tag('</em>');\n }\n\n /**\n * @returns {undefined}\n */\n function onexitstrong() {\n tag('</strong>');\n }\n\n /**\n * @returns {undefined}\n */\n function onexitthematicbreak() {\n lineEndingIfNeeded();\n tag('<hr />');\n }\n\n /**\n * @this {CompileContext}\n * @param {Token} token\n * @returns {undefined}\n */\n function onexitcharacterreferencemarker(token) {\n setData('characterReferenceType', token.type);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcharacterreferencevalue(token) {\n const value = this.sliceSerialize(token);\n const decoded = getData('characterReferenceType') ? decodeNumericCharacterReference(value, getData('characterReferenceType') === \"characterReferenceMarkerNumeric\" ? 10 : 16) : decodeNamedCharacterReference(value);\n\n // `decodeNamedCharacterReference` can return `false` for invalid named\n // character references,\n // but everything we’ve tokenized is valid.\n raw(encode(/** @type {string} */decoded));\n setData('characterReferenceType');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitautolinkprotocol(token) {\n const uri = this.sliceSerialize(token);\n tag('<a href=\"' + sanitizeUri(uri, settings.allowDangerousProtocol ? undefined : protocolHref) + '\">');\n raw(encode(uri));\n tag('</a>');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitautolinkemail(token) {\n const uri = this.sliceSerialize(token);\n tag('<a href=\"' + sanitizeUri('mailto:' + uri) + '\">');\n raw(encode(uri));\n tag('</a>');\n }\n}","/**\n * @import {Effects, State, TokenType} from 'micromark-util-types'\n */\n\nimport { markdownSpace } from 'micromark-util-character';\n\n// To do: implement `spaceOrTab`, `spaceOrTabMinMax`, `spaceOrTabWithOptions`.\n\n/**\n * Parse spaces and tabs.\n *\n * There is no `nok` parameter:\n *\n * * spaces in markdown are often optional, in which case this factory can be\n * used and `ok` will be switched to whether spaces were found or not\n * * one line ending or space can be detected with `markdownSpace(code)` right\n * before using `factorySpace`\n *\n * ###### Examples\n *\n * Where `␉` represents a tab (plus how much it expands) and `␠` represents a\n * single space.\n *\n * ```markdown\n * ␉\n * ␠␠␠␠\n * ␉␠\n * ```\n *\n * @param {Effects} effects\n * Context.\n * @param {State} ok\n * State switched to when successful.\n * @param {TokenType} type\n * Type (`' \\t'`).\n * @param {number | undefined} [max=Infinity]\n * Max (exclusive).\n * @returns {State}\n * Start state.\n */\nexport function factorySpace(effects, ok, type, max) {\n const limit = max ? max - 1 : Number.POSITIVE_INFINITY;\n let size = 0;\n return start;\n\n /** @type {State} */\n function start(code) {\n if (markdownSpace(code)) {\n effects.enter(type);\n return prefix(code);\n }\n return ok(code);\n }\n\n /** @type {State} */\n function prefix(code) {\n if (markdownSpace(code) && size++ < limit) {\n effects.consume(code);\n return prefix;\n }\n effects.exit(type);\n return ok(code);\n }\n}","/**\n * @import {\n * InitialConstruct,\n * Initializer,\n * State,\n * TokenizeContext,\n * Token\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding } from 'micromark-util-character';\n/** @type {InitialConstruct} */\nexport const content = {\n tokenize: initializeContent\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Initializer}\n * Content.\n */\nfunction initializeContent(effects) {\n const contentStart = effects.attempt(this.parser.constructs.contentInitial, afterContentStartConstruct, paragraphInitial);\n /** @type {Token} */\n let previous;\n return contentStart;\n\n /** @type {State} */\n function afterContentStartConstruct(code) {\n if (code === null) {\n effects.consume(code);\n return;\n }\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return factorySpace(effects, contentStart, \"linePrefix\");\n }\n\n /** @type {State} */\n function paragraphInitial(code) {\n effects.enter(\"paragraph\");\n return lineStart(code);\n }\n\n /** @type {State} */\n function lineStart(code) {\n const token = effects.enter(\"chunkText\", {\n contentType: \"text\",\n previous\n });\n if (previous) {\n previous.next = token;\n }\n previous = token;\n return data(code);\n }\n\n /** @type {State} */\n function data(code) {\n if (code === null) {\n effects.exit(\"chunkText\");\n effects.exit(\"paragraph\");\n effects.consume(code);\n return;\n }\n if (markdownLineEnding(code)) {\n effects.consume(code);\n effects.exit(\"chunkText\");\n return lineStart;\n }\n\n // Data.\n effects.consume(code);\n return data;\n }\n}","/**\n * @import {\n * Construct,\n * ContainerState,\n * InitialConstruct,\n * Initializer,\n * Point,\n * State,\n * TokenizeContext,\n * Tokenizer,\n * Token\n * } from 'micromark-util-types'\n */\n\n/**\n * @typedef {[Construct, ContainerState]} StackItem\n * Construct and its state.\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding } from 'micromark-util-character';\nimport { splice } from 'micromark-util-chunked';\n/** @type {InitialConstruct} */\nexport const document = {\n tokenize: initializeDocument\n};\n\n/** @type {Construct} */\nconst containerConstruct = {\n tokenize: tokenizeContainer\n};\n\n/**\n * @this {TokenizeContext}\n * Self.\n * @type {Initializer}\n * Initializer.\n */\nfunction initializeDocument(effects) {\n const self = this;\n /** @type {Array<StackItem>} */\n const stack = [];\n let continued = 0;\n /** @type {TokenizeContext | undefined} */\n let childFlow;\n /** @type {Token | undefined} */\n let childToken;\n /** @type {number} */\n let lineStartOffset;\n return start;\n\n /** @type {State} */\n function start(code) {\n // First we iterate through the open blocks, starting with the root\n // document, and descending through last children down to the last open\n // block.\n // Each block imposes a condition that the line must satisfy if the block is\n // to remain open.\n // For example, a block quote requires a `>` character.\n // A paragraph requires a non-blank line.\n // In this phase we may match all or just some of the open blocks.\n // But we cannot close unmatched blocks yet, because we may have a lazy\n // continuation line.\n if (continued < stack.length) {\n const item = stack[continued];\n self.containerState = item[1];\n return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code);\n }\n\n // Done.\n return checkNewContainers(code);\n }\n\n /** @type {State} */\n function documentContinue(code) {\n continued++;\n\n // Note: this field is called `_closeFlow` but it also closes containers.\n // Perhaps a good idea to rename it but it’s already used in the wild by\n // extensions.\n if (self.containerState._closeFlow) {\n self.containerState._closeFlow = undefined;\n if (childFlow) {\n closeFlow();\n }\n\n // Note: this algorithm for moving events around is similar to the\n // algorithm when dealing with lazy lines in `writeToChild`.\n const indexBeforeExits = self.events.length;\n let indexBeforeFlow = indexBeforeExits;\n /** @type {Point | undefined} */\n let point;\n\n // Find the flow chunk.\n while (indexBeforeFlow--) {\n if (self.events[indexBeforeFlow][0] === 'exit' && self.events[indexBeforeFlow][1].type === \"chunkFlow\") {\n point = self.events[indexBeforeFlow][1].end;\n break;\n }\n }\n exitContainers(continued);\n\n // Fix positions.\n let index = indexBeforeExits;\n while (index < self.events.length) {\n self.events[index][1].end = {\n ...point\n };\n index++;\n }\n\n // Inject the exits earlier (they’re still also at the end).\n splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));\n\n // Discard the duplicate exits.\n self.events.length = index;\n return checkNewContainers(code);\n }\n return start(code);\n }\n\n /** @type {State} */\n function checkNewContainers(code) {\n // Next, after consuming the continuation markers for existing blocks, we\n // look for new block starts (e.g. `>` for a block quote).\n // If we encounter a new block start, we close any blocks unmatched in\n // step 1 before creating the new block as a child of the last matched\n // block.\n if (continued === stack.length) {\n // No need to `check` whether there’s a container, of `exitContainers`\n // would be moot.\n // We can instead immediately `attempt` to parse one.\n if (!childFlow) {\n return documentContinued(code);\n }\n\n // If we have concrete content, such as block HTML or fenced code,\n // we can’t have containers “pierce” into them, so we can immediately\n // start.\n if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) {\n return flowStart(code);\n }\n\n // If we do have flow, it could still be a blank line,\n // but we’d be interrupting it w/ a new container if there’s a current\n // construct.\n // To do: next major: remove `_gfmTableDynamicInterruptHack` (no longer\n // needed in micromark-extension-gfm-table@1.0.6).\n self.interrupt = Boolean(childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack);\n }\n\n // Check if there is a new container.\n self.containerState = {};\n return effects.check(containerConstruct, thereIsANewContainer, thereIsNoNewContainer)(code);\n }\n\n /** @type {State} */\n function thereIsANewContainer(code) {\n if (childFlow) closeFlow();\n exitContainers(continued);\n return documentContinued(code);\n }\n\n /** @type {State} */\n function thereIsNoNewContainer(code) {\n self.parser.lazy[self.now().line] = continued !== stack.length;\n lineStartOffset = self.now().offset;\n return flowStart(code);\n }\n\n /** @type {State} */\n function documentContinued(code) {\n // Try new containers.\n self.containerState = {};\n return effects.attempt(containerConstruct, containerContinue, flowStart)(code);\n }\n\n /** @type {State} */\n function containerContinue(code) {\n continued++;\n stack.push([self.currentConstruct, self.containerState]);\n // Try another.\n return documentContinued(code);\n }\n\n /** @type {State} */\n function flowStart(code) {\n if (code === null) {\n if (childFlow) closeFlow();\n exitContainers(0);\n effects.consume(code);\n return;\n }\n childFlow = childFlow || self.parser.flow(self.now());\n effects.enter(\"chunkFlow\", {\n _tokenizer: childFlow,\n contentType: \"flow\",\n previous: childToken\n });\n return flowContinue(code);\n }\n\n /** @type {State} */\n function flowContinue(code) {\n if (code === null) {\n writeToChild(effects.exit(\"chunkFlow\"), true);\n exitContainers(0);\n effects.consume(code);\n return;\n }\n if (markdownLineEnding(code)) {\n effects.consume(code);\n writeToChild(effects.exit(\"chunkFlow\"));\n // Get ready for the next line.\n continued = 0;\n self.interrupt = undefined;\n return start;\n }\n effects.consume(code);\n return flowContinue;\n }\n\n /**\n * @param {Token} token\n * Token.\n * @param {boolean | undefined} [endOfFile]\n * Whether the token is at the end of the file (default: `false`).\n * @returns {undefined}\n * Nothing.\n */\n function writeToChild(token, endOfFile) {\n const stream = self.sliceStream(token);\n if (endOfFile) stream.push(null);\n token.previous = childToken;\n if (childToken) childToken.next = token;\n childToken = token;\n childFlow.defineSkip(token.start);\n childFlow.write(stream);\n\n // Alright, so we just added a lazy line:\n //\n // ```markdown\n // > a\n // b.\n //\n // Or:\n //\n // > ~~~c\n // d\n //\n // Or:\n //\n // > | e |\n // f\n // ```\n //\n // The construct in the second example (fenced code) does not accept lazy\n // lines, so it marked itself as done at the end of its first line, and\n // then the content construct parses `d`.\n // Most constructs in markdown match on the first line: if the first line\n // forms a construct, a non-lazy line can’t “unmake” it.\n //\n // The construct in the third example is potentially a GFM table, and\n // those are *weird*.\n // It *could* be a table, from the first line, if the following line\n // matches a condition.\n // In this case, that second line is lazy, which “unmakes” the first line\n // and turns the whole into one content block.\n //\n // We’ve now parsed the non-lazy and the lazy line, and can figure out\n // whether the lazy line started a new flow block.\n // If it did, we exit the current containers between the two flow blocks.\n if (self.parser.lazy[token.start.line]) {\n let index = childFlow.events.length;\n while (index--) {\n if (\n // The token starts before the line ending…\n childFlow.events[index][1].start.offset < lineStartOffset && (\n // …and either is not ended yet…\n !childFlow.events[index][1].end ||\n // …or ends after it.\n childFlow.events[index][1].end.offset > lineStartOffset)) {\n // Exit: there’s still something open, which means it’s a lazy line\n // part of something.\n return;\n }\n }\n\n // Note: this algorithm for moving events around is similar to the\n // algorithm when closing flow in `documentContinue`.\n const indexBeforeExits = self.events.length;\n let indexBeforeFlow = indexBeforeExits;\n /** @type {boolean | undefined} */\n let seen;\n /** @type {Point | undefined} */\n let point;\n\n // Find the previous chunk (the one before the lazy line).\n while (indexBeforeFlow--) {\n if (self.events[indexBeforeFlow][0] === 'exit' && self.events[indexBeforeFlow][1].type === \"chunkFlow\") {\n if (seen) {\n point = self.events[indexBeforeFlow][1].end;\n break;\n }\n seen = true;\n }\n }\n exitContainers(continued);\n\n // Fix positions.\n index = indexBeforeExits;\n while (index < self.events.length) {\n self.events[index][1].end = {\n ...point\n };\n index++;\n }\n\n // Inject the exits earlier (they’re still also at the end).\n splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));\n\n // Discard the duplicate exits.\n self.events.length = index;\n }\n }\n\n /**\n * @param {number} size\n * Size.\n * @returns {undefined}\n * Nothing.\n */\n function exitContainers(size) {\n let index = stack.length;\n\n // Exit open containers.\n while (index-- > size) {\n const entry = stack[index];\n self.containerState = entry[1];\n entry[0].exit.call(self, effects);\n }\n stack.length = size;\n }\n function closeFlow() {\n childFlow.write([null]);\n childToken = undefined;\n childFlow = undefined;\n self.containerState._closeFlow = undefined;\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n * Tokenizer.\n */\nfunction tokenizeContainer(effects, ok, nok) {\n // Always populated by defaults.\n\n return factorySpace(effects, effects.attempt(this.parser.constructs.document, ok, nok), \"linePrefix\", this.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4);\n}","/**\n * @import {Code} from 'micromark-util-types'\n */\n\nimport { markdownLineEndingOrSpace, unicodePunctuation, unicodeWhitespace } from 'micromark-util-character';\n/**\n * Classify whether a code represents whitespace, punctuation, or something\n * else.\n *\n * Used for attention (emphasis, strong), whose sequences can open or close\n * based on the class of surrounding characters.\n *\n * > 👉 **Note**: eof (`null`) is seen as whitespace.\n *\n * @param {Code} code\n * Code.\n * @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined}\n * Group.\n */\nexport function classifyCharacter(code) {\n if (code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) {\n return 1;\n }\n if (unicodePunctuation(code)) {\n return 2;\n }\n}","/**\n * @import {Event, Resolver, TokenizeContext} from 'micromark-util-types'\n */\n\n/**\n * Call all `resolveAll`s.\n *\n * @param {ReadonlyArray<{resolveAll?: Resolver | undefined}>} constructs\n * List of constructs, optionally with `resolveAll`s.\n * @param {Array<Event>} events\n * List of events.\n * @param {TokenizeContext} context\n * Context used by `tokenize`.\n * @returns {Array<Event>}\n * Changed events.\n */\nexport function resolveAll(constructs, events, context) {\n /** @type {Array<Resolver>} */\n const called = []\n let index = -1\n\n while (++index < constructs.length) {\n const resolve = constructs[index].resolveAll\n\n if (resolve && !called.includes(resolve)) {\n events = resolve(events, context)\n called.push(resolve)\n }\n }\n\n return events\n}\n","/**\n * @import {\n * Code,\n * Construct,\n * Event,\n * Point,\n * Resolver,\n * State,\n * TokenizeContext,\n * Tokenizer,\n * Token\n * } from 'micromark-util-types'\n */\n\nimport { push, splice } from 'micromark-util-chunked';\nimport { classifyCharacter } from 'micromark-util-classify-character';\nimport { resolveAll } from 'micromark-util-resolve-all';\n/** @type {Construct} */\nexport const attention = {\n name: 'attention',\n resolveAll: resolveAllAttention,\n tokenize: tokenizeAttention\n};\n\n/**\n * Take all events and resolve attention to emphasis or strong.\n *\n * @type {Resolver}\n */\n// eslint-disable-next-line complexity\nfunction resolveAllAttention(events, context) {\n let index = -1;\n /** @type {number} */\n let open;\n /** @type {Token} */\n let group;\n /** @type {Token} */\n let text;\n /** @type {Token} */\n let openingSequence;\n /** @type {Token} */\n let closingSequence;\n /** @type {number} */\n let use;\n /** @type {Array<Event>} */\n let nextEvents;\n /** @type {number} */\n let offset;\n\n // Walk through all events.\n //\n // Note: performance of this is fine on an mb of normal markdown, but it’s\n // a bottleneck for malicious stuff.\n while (++index < events.length) {\n // Find a token that can close.\n if (events[index][0] === 'enter' && events[index][1].type === 'attentionSequence' && events[index][1]._close) {\n open = index;\n\n // Now walk back to find an opener.\n while (open--) {\n // Find a token that can open the closer.\n if (events[open][0] === 'exit' && events[open][1].type === 'attentionSequence' && events[open][1]._open &&\n // If the markers are the same:\n context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index][1]).charCodeAt(0)) {\n // If the opening can close or the closing can open,\n // and the close size *is not* a multiple of three,\n // but the sum of the opening and closing size *is* multiple of three,\n // then don’t match.\n if ((events[open][1]._close || events[index][1]._open) && (events[index][1].end.offset - events[index][1].start.offset) % 3 && !((events[open][1].end.offset - events[open][1].start.offset + events[index][1].end.offset - events[index][1].start.offset) % 3)) {\n continue;\n }\n\n // Number of markers to use from the sequence.\n use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index][1].end.offset - events[index][1].start.offset > 1 ? 2 : 1;\n const start = {\n ...events[open][1].end\n };\n const end = {\n ...events[index][1].start\n };\n movePoint(start, -use);\n movePoint(end, use);\n openingSequence = {\n type: use > 1 ? \"strongSequence\" : \"emphasisSequence\",\n start,\n end: {\n ...events[open][1].end\n }\n };\n closingSequence = {\n type: use > 1 ? \"strongSequence\" : \"emphasisSequence\",\n start: {\n ...events[index][1].start\n },\n end\n };\n text = {\n type: use > 1 ? \"strongText\" : \"emphasisText\",\n start: {\n ...events[open][1].end\n },\n end: {\n ...events[index][1].start\n }\n };\n group = {\n type: use > 1 ? \"strong\" : \"emphasis\",\n start: {\n ...openingSequence.start\n },\n end: {\n ...closingSequence.end\n }\n };\n events[open][1].end = {\n ...openingSequence.start\n };\n events[index][1].start = {\n ...closingSequence.end\n };\n nextEvents = [];\n\n // If there are more markers in the opening, add them before.\n if (events[open][1].end.offset - events[open][1].start.offset) {\n nextEvents = push(nextEvents, [['enter', events[open][1], context], ['exit', events[open][1], context]]);\n }\n\n // Opening.\n nextEvents = push(nextEvents, [['enter', group, context], ['enter', openingSequence, context], ['exit', openingSequence, context], ['enter', text, context]]);\n\n // Always populated by defaults.\n\n // Between.\n nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index), context));\n\n // Closing.\n nextEvents = push(nextEvents, [['exit', text, context], ['enter', closingSequence, context], ['exit', closingSequence, context], ['exit', group, context]]);\n\n // If there are more markers in the closing, add them after.\n if (events[index][1].end.offset - events[index][1].start.offset) {\n offset = 2;\n nextEvents = push(nextEvents, [['enter', events[index][1], context], ['exit', events[index][1], context]]);\n } else {\n offset = 0;\n }\n splice(events, open - 1, index - open + 3, nextEvents);\n index = open + nextEvents.length - offset - 2;\n break;\n }\n }\n }\n }\n\n // Remove remaining sequences.\n index = -1;\n while (++index < events.length) {\n if (events[index][1].type === 'attentionSequence') {\n events[index][1].type = 'data';\n }\n }\n return events;\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeAttention(effects, ok) {\n const attentionMarkers = this.parser.constructs.attentionMarkers.null;\n const previous = this.previous;\n const before = classifyCharacter(previous);\n\n /** @type {NonNullable<Code>} */\n let marker;\n return start;\n\n /**\n * Before a sequence.\n *\n * ```markdown\n * > | **\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n marker = code;\n effects.enter('attentionSequence');\n return inside(code);\n }\n\n /**\n * In a sequence.\n *\n * ```markdown\n * > | **\n * ^^\n * ```\n *\n * @type {State}\n */\n function inside(code) {\n if (code === marker) {\n effects.consume(code);\n return inside;\n }\n const token = effects.exit('attentionSequence');\n\n // To do: next major: move this to resolver, just like `markdown-rs`.\n const after = classifyCharacter(code);\n\n // Always populated by defaults.\n\n const open = !after || after === 2 && before || attentionMarkers.includes(code);\n const close = !before || before === 2 && after || attentionMarkers.includes(previous);\n token._open = Boolean(marker === 42 ? open : open && (before || !close));\n token._close = Boolean(marker === 42 ? close : close && (after || !open));\n return ok(code);\n }\n}\n\n/**\n * Move a point a bit.\n *\n * Note: `move` only works inside lines! It’s not possible to move past other\n * chunks (replacement characters, tabs, or line endings).\n *\n * @param {Point} point\n * Point.\n * @param {number} offset\n * Amount to move.\n * @returns {undefined}\n * Nothing.\n */\nfunction movePoint(point, offset) {\n point.column += offset;\n point.offset += offset;\n point._bufferIndex += offset;\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { asciiAlphanumeric, asciiAlpha, asciiAtext, asciiControl } from 'micromark-util-character';\n/** @type {Construct} */\nexport const autolink = {\n name: 'autolink',\n tokenize: tokenizeAutolink\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeAutolink(effects, ok, nok) {\n let size = 0;\n return start;\n\n /**\n * Start of an autolink.\n *\n * ```markdown\n * > | a<https://example.com>b\n * ^\n * > | a<user@example.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"autolink\");\n effects.enter(\"autolinkMarker\");\n effects.consume(code);\n effects.exit(\"autolinkMarker\");\n effects.enter(\"autolinkProtocol\");\n return open;\n }\n\n /**\n * After `<`, at protocol or atext.\n *\n * ```markdown\n * > | a<https://example.com>b\n * ^\n * > | a<user@example.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (asciiAlpha(code)) {\n effects.consume(code);\n return schemeOrEmailAtext;\n }\n if (code === 64) {\n return nok(code);\n }\n return emailAtext(code);\n }\n\n /**\n * At second byte of protocol or atext.\n *\n * ```markdown\n * > | a<https://example.com>b\n * ^\n * > | a<user@example.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function schemeOrEmailAtext(code) {\n // ASCII alphanumeric and `+`, `-`, and `.`.\n if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) {\n // Count the previous alphabetical from `open` too.\n size = 1;\n return schemeInsideOrEmailAtext(code);\n }\n return emailAtext(code);\n }\n\n /**\n * In ambiguous protocol or atext.\n *\n * ```markdown\n * > | a<https://example.com>b\n * ^\n * > | a<user@example.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function schemeInsideOrEmailAtext(code) {\n if (code === 58) {\n effects.consume(code);\n size = 0;\n return urlInside;\n }\n\n // ASCII alphanumeric and `+`, `-`, and `.`.\n if ((code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && size++ < 32) {\n effects.consume(code);\n return schemeInsideOrEmailAtext;\n }\n size = 0;\n return emailAtext(code);\n }\n\n /**\n * After protocol, in URL.\n *\n * ```markdown\n * > | a<https://example.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function urlInside(code) {\n if (code === 62) {\n effects.exit(\"autolinkProtocol\");\n effects.enter(\"autolinkMarker\");\n effects.consume(code);\n effects.exit(\"autolinkMarker\");\n effects.exit(\"autolink\");\n return ok;\n }\n\n // ASCII control, space, or `<`.\n if (code === null || code === 32 || code === 60 || asciiControl(code)) {\n return nok(code);\n }\n effects.consume(code);\n return urlInside;\n }\n\n /**\n * In email atext.\n *\n * ```markdown\n * > | a<user.name@example.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function emailAtext(code) {\n if (code === 64) {\n effects.consume(code);\n return emailAtSignOrDot;\n }\n if (asciiAtext(code)) {\n effects.consume(code);\n return emailAtext;\n }\n return nok(code);\n }\n\n /**\n * In label, after at-sign or dot.\n *\n * ```markdown\n * > | a<user.name@example.com>b\n * ^ ^\n * ```\n *\n * @type {State}\n */\n function emailAtSignOrDot(code) {\n return asciiAlphanumeric(code) ? emailLabel(code) : nok(code);\n }\n\n /**\n * In label, where `.` and `>` are allowed.\n *\n * ```markdown\n * > | a<user.name@example.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function emailLabel(code) {\n if (code === 46) {\n effects.consume(code);\n size = 0;\n return emailAtSignOrDot;\n }\n if (code === 62) {\n // Exit, then change the token type.\n effects.exit(\"autolinkProtocol\").type = \"autolinkEmail\";\n effects.enter(\"autolinkMarker\");\n effects.consume(code);\n effects.exit(\"autolinkMarker\");\n effects.exit(\"autolink\");\n return ok;\n }\n return emailValue(code);\n }\n\n /**\n * In label, where `.` and `>` are *not* allowed.\n *\n * Though, this is also used in `emailLabel` to parse other values.\n *\n * ```markdown\n * > | a<user.name@ex-ample.com>b\n * ^\n * ```\n *\n * @type {State}\n */\n function emailValue(code) {\n // ASCII alphanumeric or `-`.\n if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) {\n const next = code === 45 ? emailValue : emailLabel;\n effects.consume(code);\n return next;\n }\n return nok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nexport const blankLine = {\n partial: true,\n tokenize: tokenizeBlankLine\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeBlankLine(effects, ok, nok) {\n return start;\n\n /**\n * Start of blank line.\n *\n * > 👉 **Note**: `␠` represents a space character.\n *\n * ```markdown\n * > | ␠␠␊\n * ^\n * > | ␊\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n return markdownSpace(code) ? factorySpace(effects, after, \"linePrefix\")(code) : after(code);\n }\n\n /**\n * At eof/eol, after optional whitespace.\n *\n * > 👉 **Note**: `␠` represents a space character.\n *\n * ```markdown\n * > | ␠␠␊\n * ^\n * > | ␊\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n return code === null || markdownLineEnding(code) ? ok(code) : nok(code);\n }\n}","/**\n * @import {\n * Construct,\n * Exiter,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nexport const blockQuote = {\n continuation: {\n tokenize: tokenizeBlockQuoteContinuation\n },\n exit,\n name: 'blockQuote',\n tokenize: tokenizeBlockQuoteStart\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeBlockQuoteStart(effects, ok, nok) {\n const self = this;\n return start;\n\n /**\n * Start of block quote.\n *\n * ```markdown\n * > | > a\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n if (code === 62) {\n const state = self.containerState;\n if (!state.open) {\n effects.enter(\"blockQuote\", {\n _container: true\n });\n state.open = true;\n }\n effects.enter(\"blockQuotePrefix\");\n effects.enter(\"blockQuoteMarker\");\n effects.consume(code);\n effects.exit(\"blockQuoteMarker\");\n return after;\n }\n return nok(code);\n }\n\n /**\n * After `>`, before optional whitespace.\n *\n * ```markdown\n * > | > a\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n if (markdownSpace(code)) {\n effects.enter(\"blockQuotePrefixWhitespace\");\n effects.consume(code);\n effects.exit(\"blockQuotePrefixWhitespace\");\n effects.exit(\"blockQuotePrefix\");\n return ok;\n }\n effects.exit(\"blockQuotePrefix\");\n return ok(code);\n }\n}\n\n/**\n * Start of block quote continuation.\n *\n * ```markdown\n * | > a\n * > | > b\n * ^\n * ```\n *\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeBlockQuoteContinuation(effects, ok, nok) {\n const self = this;\n return contStart;\n\n /**\n * Start of block quote continuation.\n *\n * Also used to parse the first block quote opening.\n *\n * ```markdown\n * | > a\n * > | > b\n * ^\n * ```\n *\n * @type {State}\n */\n function contStart(code) {\n if (markdownSpace(code)) {\n // Always populated by defaults.\n\n return factorySpace(effects, contBefore, \"linePrefix\", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code);\n }\n return contBefore(code);\n }\n\n /**\n * At `>`, after optional whitespace.\n *\n * Also used to parse the first block quote opening.\n *\n * ```markdown\n * | > a\n * > | > b\n * ^\n * ```\n *\n * @type {State}\n */\n function contBefore(code) {\n return effects.attempt(blockQuote, ok, nok)(code);\n }\n}\n\n/** @type {Exiter} */\nfunction exit(effects) {\n effects.exit(\"blockQuote\");\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { asciiPunctuation } from 'micromark-util-character';\n/** @type {Construct} */\nexport const characterEscape = {\n name: 'characterEscape',\n tokenize: tokenizeCharacterEscape\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeCharacterEscape(effects, ok, nok) {\n return start;\n\n /**\n * Start of character escape.\n *\n * ```markdown\n * > | a\\*b\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"characterEscape\");\n effects.enter(\"escapeMarker\");\n effects.consume(code);\n effects.exit(\"escapeMarker\");\n return inside;\n }\n\n /**\n * After `\\`, at punctuation.\n *\n * ```markdown\n * > | a\\*b\n * ^\n * ```\n *\n * @type {State}\n */\n function inside(code) {\n // ASCII punctuation.\n if (asciiPunctuation(code)) {\n effects.enter(\"characterEscapeValue\");\n effects.consume(code);\n effects.exit(\"characterEscapeValue\");\n effects.exit(\"characterEscape\");\n return ok;\n }\n return nok(code);\n }\n}","/**\n * @import {\n * Code,\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { decodeNamedCharacterReference } from 'decode-named-character-reference';\nimport { asciiAlphanumeric, asciiDigit, asciiHexDigit } from 'micromark-util-character';\n/** @type {Construct} */\nexport const characterReference = {\n name: 'characterReference',\n tokenize: tokenizeCharacterReference\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeCharacterReference(effects, ok, nok) {\n const self = this;\n let size = 0;\n /** @type {number} */\n let max;\n /** @type {(code: Code) => boolean} */\n let test;\n return start;\n\n /**\n * Start of character reference.\n *\n * ```markdown\n * > | a&amp;b\n * ^\n * > | a&#123;b\n * ^\n * > | a&#x9;b\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"characterReference\");\n effects.enter(\"characterReferenceMarker\");\n effects.consume(code);\n effects.exit(\"characterReferenceMarker\");\n return open;\n }\n\n /**\n * After `&`, at `#` for numeric references or alphanumeric for named\n * references.\n *\n * ```markdown\n * > | a&amp;b\n * ^\n * > | a&#123;b\n * ^\n * > | a&#x9;b\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (code === 35) {\n effects.enter(\"characterReferenceMarkerNumeric\");\n effects.consume(code);\n effects.exit(\"characterReferenceMarkerNumeric\");\n return numeric;\n }\n effects.enter(\"characterReferenceValue\");\n max = 31;\n test = asciiAlphanumeric;\n return value(code);\n }\n\n /**\n * After `#`, at `x` for hexadecimals or digit for decimals.\n *\n * ```markdown\n * > | a&#123;b\n * ^\n * > | a&#x9;b\n * ^\n * ```\n *\n * @type {State}\n */\n function numeric(code) {\n if (code === 88 || code === 120) {\n effects.enter(\"characterReferenceMarkerHexadecimal\");\n effects.consume(code);\n effects.exit(\"characterReferenceMarkerHexadecimal\");\n effects.enter(\"characterReferenceValue\");\n max = 6;\n test = asciiHexDigit;\n return value;\n }\n effects.enter(\"characterReferenceValue\");\n max = 7;\n test = asciiDigit;\n return value(code);\n }\n\n /**\n * After markers (`&#x`, `&#`, or `&`), in value, before `;`.\n *\n * The character reference kind defines what and how many characters are\n * allowed.\n *\n * ```markdown\n * > | a&amp;b\n * ^^^\n * > | a&#123;b\n * ^^^\n * > | a&#x9;b\n * ^\n * ```\n *\n * @type {State}\n */\n function value(code) {\n if (code === 59 && size) {\n const token = effects.exit(\"characterReferenceValue\");\n if (test === asciiAlphanumeric && !decodeNamedCharacterReference(self.sliceSerialize(token))) {\n return nok(code);\n }\n\n // To do: `markdown-rs` uses a different name:\n // `CharacterReferenceMarkerSemi`.\n effects.enter(\"characterReferenceMarker\");\n effects.consume(code);\n effects.exit(\"characterReferenceMarker\");\n effects.exit(\"characterReference\");\n return ok;\n }\n if (test(code) && size++ < max) {\n effects.consume(code);\n return value;\n }\n return nok(code);\n }\n}","/**\n * @import {\n * Code,\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nconst nonLazyContinuation = {\n partial: true,\n tokenize: tokenizeNonLazyContinuation\n};\n\n/** @type {Construct} */\nexport const codeFenced = {\n concrete: true,\n name: 'codeFenced',\n tokenize: tokenizeCodeFenced\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeCodeFenced(effects, ok, nok) {\n const self = this;\n /** @type {Construct} */\n const closeStart = {\n partial: true,\n tokenize: tokenizeCloseStart\n };\n let initialPrefix = 0;\n let sizeOpen = 0;\n /** @type {NonNullable<Code>} */\n let marker;\n return start;\n\n /**\n * Start of code.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // To do: parse whitespace like `markdown-rs`.\n return beforeSequenceOpen(code);\n }\n\n /**\n * In opening fence, after prefix, at sequence.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function beforeSequenceOpen(code) {\n const tail = self.events[self.events.length - 1];\n initialPrefix = tail && tail[1].type === \"linePrefix\" ? tail[2].sliceSerialize(tail[1], true).length : 0;\n marker = code;\n effects.enter(\"codeFenced\");\n effects.enter(\"codeFencedFence\");\n effects.enter(\"codeFencedFenceSequence\");\n return sequenceOpen(code);\n }\n\n /**\n * In opening fence sequence.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function sequenceOpen(code) {\n if (code === marker) {\n sizeOpen++;\n effects.consume(code);\n return sequenceOpen;\n }\n if (sizeOpen < 3) {\n return nok(code);\n }\n effects.exit(\"codeFencedFenceSequence\");\n return markdownSpace(code) ? factorySpace(effects, infoBefore, \"whitespace\")(code) : infoBefore(code);\n }\n\n /**\n * In opening fence, after the sequence (and optional whitespace), before info.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function infoBefore(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"codeFencedFence\");\n return self.interrupt ? ok(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);\n }\n effects.enter(\"codeFencedFenceInfo\");\n effects.enter(\"chunkString\", {\n contentType: \"string\"\n });\n return info(code);\n }\n\n /**\n * In info.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function info(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"chunkString\");\n effects.exit(\"codeFencedFenceInfo\");\n return infoBefore(code);\n }\n if (markdownSpace(code)) {\n effects.exit(\"chunkString\");\n effects.exit(\"codeFencedFenceInfo\");\n return factorySpace(effects, metaBefore, \"whitespace\")(code);\n }\n if (code === 96 && code === marker) {\n return nok(code);\n }\n effects.consume(code);\n return info;\n }\n\n /**\n * In opening fence, after info and whitespace, before meta.\n *\n * ```markdown\n * > | ~~~js eval\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function metaBefore(code) {\n if (code === null || markdownLineEnding(code)) {\n return infoBefore(code);\n }\n effects.enter(\"codeFencedFenceMeta\");\n effects.enter(\"chunkString\", {\n contentType: \"string\"\n });\n return meta(code);\n }\n\n /**\n * In meta.\n *\n * ```markdown\n * > | ~~~js eval\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function meta(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"chunkString\");\n effects.exit(\"codeFencedFenceMeta\");\n return infoBefore(code);\n }\n if (code === 96 && code === marker) {\n return nok(code);\n }\n effects.consume(code);\n return meta;\n }\n\n /**\n * At eol/eof in code, before a non-lazy closing fence or content.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * > | alert(1)\n * ^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function atNonLazyBreak(code) {\n return effects.attempt(closeStart, after, contentBefore)(code);\n }\n\n /**\n * Before code content, not a closing fence, at eol.\n *\n * ```markdown\n * | ~~~js\n * > | alert(1)\n * ^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function contentBefore(code) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return contentStart;\n }\n\n /**\n * Before code content, not a closing fence.\n *\n * ```markdown\n * | ~~~js\n * > | alert(1)\n * ^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function contentStart(code) {\n return initialPrefix > 0 && markdownSpace(code) ? factorySpace(effects, beforeContentChunk, \"linePrefix\", initialPrefix + 1)(code) : beforeContentChunk(code);\n }\n\n /**\n * Before code content, after optional prefix.\n *\n * ```markdown\n * | ~~~js\n * > | alert(1)\n * ^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function beforeContentChunk(code) {\n if (code === null || markdownLineEnding(code)) {\n return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);\n }\n effects.enter(\"codeFlowValue\");\n return contentChunk(code);\n }\n\n /**\n * In code content.\n *\n * ```markdown\n * | ~~~js\n * > | alert(1)\n * ^^^^^^^^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function contentChunk(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"codeFlowValue\");\n return beforeContentChunk(code);\n }\n effects.consume(code);\n return contentChunk;\n }\n\n /**\n * After code.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n effects.exit(\"codeFenced\");\n return ok(code);\n }\n\n /**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\n function tokenizeCloseStart(effects, ok, nok) {\n let size = 0;\n return startBefore;\n\n /**\n *\n *\n * @type {State}\n */\n function startBefore(code) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return start;\n }\n\n /**\n * Before closing fence, at optional whitespace.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // Always populated by defaults.\n\n // To do: `enter` here or in next state?\n effects.enter(\"codeFencedFence\");\n return markdownSpace(code) ? factorySpace(effects, beforeSequenceClose, \"linePrefix\", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : beforeSequenceClose(code);\n }\n\n /**\n * In closing fence, after optional whitespace, at sequence.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function beforeSequenceClose(code) {\n if (code === marker) {\n effects.enter(\"codeFencedFenceSequence\");\n return sequenceClose(code);\n }\n return nok(code);\n }\n\n /**\n * In closing fence sequence.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceClose(code) {\n if (code === marker) {\n size++;\n effects.consume(code);\n return sequenceClose;\n }\n if (size >= sizeOpen) {\n effects.exit(\"codeFencedFenceSequence\");\n return markdownSpace(code) ? factorySpace(effects, sequenceCloseAfter, \"whitespace\")(code) : sequenceCloseAfter(code);\n }\n return nok(code);\n }\n\n /**\n * After closing fence sequence, after optional whitespace.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceCloseAfter(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"codeFencedFence\");\n return ok(code);\n }\n return nok(code);\n }\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeNonLazyContinuation(effects, ok, nok) {\n const self = this;\n return start;\n\n /**\n *\n *\n * @type {State}\n */\n function start(code) {\n if (code === null) {\n return nok(code);\n }\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return lineStart;\n }\n\n /**\n *\n *\n * @type {State}\n */\n function lineStart(code) {\n return self.parser.lazy[self.now().line] ? nok(code) : ok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nexport const codeIndented = {\n name: 'codeIndented',\n tokenize: tokenizeCodeIndented\n};\n\n/** @type {Construct} */\nconst furtherStart = {\n partial: true,\n tokenize: tokenizeFurtherStart\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeCodeIndented(effects, ok, nok) {\n const self = this;\n return start;\n\n /**\n * Start of code (indented).\n *\n * > **Parsing note**: it is not needed to check if this first line is a\n * > filled line (that it has a non-whitespace character), because blank lines\n * > are parsed already, so we never run into that.\n *\n * ```markdown\n * > | aaa\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // To do: manually check if interrupting like `markdown-rs`.\n\n effects.enter(\"codeIndented\");\n // To do: use an improved `space_or_tab` function like `markdown-rs`,\n // so that we can drop the next state.\n return factorySpace(effects, afterPrefix, \"linePrefix\", 4 + 1)(code);\n }\n\n /**\n * At start, after 1 or 4 spaces.\n *\n * ```markdown\n * > | aaa\n * ^\n * ```\n *\n * @type {State}\n */\n function afterPrefix(code) {\n const tail = self.events[self.events.length - 1];\n return tail && tail[1].type === \"linePrefix\" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? atBreak(code) : nok(code);\n }\n\n /**\n * At a break.\n *\n * ```markdown\n * > | aaa\n * ^ ^\n * ```\n *\n * @type {State}\n */\n function atBreak(code) {\n if (code === null) {\n return after(code);\n }\n if (markdownLineEnding(code)) {\n return effects.attempt(furtherStart, atBreak, after)(code);\n }\n effects.enter(\"codeFlowValue\");\n return inside(code);\n }\n\n /**\n * In code content.\n *\n * ```markdown\n * > | aaa\n * ^^^^\n * ```\n *\n * @type {State}\n */\n function inside(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"codeFlowValue\");\n return atBreak(code);\n }\n effects.consume(code);\n return inside;\n }\n\n /** @type {State} */\n function after(code) {\n effects.exit(\"codeIndented\");\n // To do: allow interrupting like `markdown-rs`.\n // Feel free to interrupt.\n // tokenizer.interrupt = false\n return ok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeFurtherStart(effects, ok, nok) {\n const self = this;\n return furtherStart;\n\n /**\n * At eol, trying to parse another indent.\n *\n * ```markdown\n * > | aaa\n * ^\n * | bbb\n * ```\n *\n * @type {State}\n */\n function furtherStart(code) {\n // To do: improve `lazy` / `pierce` handling.\n // If this is a lazy line, it can’t be code.\n if (self.parser.lazy[self.now().line]) {\n return nok(code);\n }\n if (markdownLineEnding(code)) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return furtherStart;\n }\n\n // To do: the code here in `micromark-js` is a bit different from\n // `markdown-rs` because there it can attempt spaces.\n // We can’t yet.\n //\n // To do: use an improved `space_or_tab` function like `markdown-rs`,\n // so that we can drop the next state.\n return factorySpace(effects, afterPrefix, \"linePrefix\", 4 + 1)(code);\n }\n\n /**\n * At start, after 1 or 4 spaces.\n *\n * ```markdown\n * > | aaa\n * ^\n * ```\n *\n * @type {State}\n */\n function afterPrefix(code) {\n const tail = self.events[self.events.length - 1];\n return tail && tail[1].type === \"linePrefix\" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? ok(code) : markdownLineEnding(code) ? furtherStart(code) : nok(code);\n }\n}","/**\n * @import {\n * Construct,\n * Previous,\n * Resolver,\n * State,\n * TokenizeContext,\n * Tokenizer,\n * Token\n * } from 'micromark-util-types'\n */\n\nimport { markdownLineEnding } from 'micromark-util-character';\n/** @type {Construct} */\nexport const codeText = {\n name: 'codeText',\n previous,\n resolve: resolveCodeText,\n tokenize: tokenizeCodeText\n};\n\n// To do: next major: don’t resolve, like `markdown-rs`.\n/** @type {Resolver} */\nfunction resolveCodeText(events) {\n let tailExitIndex = events.length - 4;\n let headEnterIndex = 3;\n /** @type {number} */\n let index;\n /** @type {number | undefined} */\n let enter;\n\n // If we start and end with an EOL or a space.\n if ((events[headEnterIndex][1].type === \"lineEnding\" || events[headEnterIndex][1].type === 'space') && (events[tailExitIndex][1].type === \"lineEnding\" || events[tailExitIndex][1].type === 'space')) {\n index = headEnterIndex;\n\n // And we have data.\n while (++index < tailExitIndex) {\n if (events[index][1].type === \"codeTextData\") {\n // Then we have padding.\n events[headEnterIndex][1].type = \"codeTextPadding\";\n events[tailExitIndex][1].type = \"codeTextPadding\";\n headEnterIndex += 2;\n tailExitIndex -= 2;\n break;\n }\n }\n }\n\n // Merge adjacent spaces and data.\n index = headEnterIndex - 1;\n tailExitIndex++;\n while (++index <= tailExitIndex) {\n if (enter === undefined) {\n if (index !== tailExitIndex && events[index][1].type !== \"lineEnding\") {\n enter = index;\n }\n } else if (index === tailExitIndex || events[index][1].type === \"lineEnding\") {\n events[enter][1].type = \"codeTextData\";\n if (index !== enter + 2) {\n events[enter][1].end = events[index - 1][1].end;\n events.splice(enter + 2, index - enter - 2);\n tailExitIndex -= index - enter - 2;\n index = enter + 2;\n }\n enter = undefined;\n }\n }\n return events;\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Previous}\n */\nfunction previous(code) {\n // If there is a previous code, there will always be a tail.\n return code !== 96 || this.events[this.events.length - 1][1].type === \"characterEscape\";\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeCodeText(effects, ok, nok) {\n const self = this;\n let sizeOpen = 0;\n /** @type {number} */\n let size;\n /** @type {Token} */\n let token;\n return start;\n\n /**\n * Start of code (text).\n *\n * ```markdown\n * > | `a`\n * ^\n * > | \\`a`\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"codeText\");\n effects.enter(\"codeTextSequence\");\n return sequenceOpen(code);\n }\n\n /**\n * In opening sequence.\n *\n * ```markdown\n * > | `a`\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceOpen(code) {\n if (code === 96) {\n effects.consume(code);\n sizeOpen++;\n return sequenceOpen;\n }\n effects.exit(\"codeTextSequence\");\n return between(code);\n }\n\n /**\n * Between something and something else.\n *\n * ```markdown\n * > | `a`\n * ^^\n * ```\n *\n * @type {State}\n */\n function between(code) {\n // EOF.\n if (code === null) {\n return nok(code);\n }\n\n // To do: next major: don’t do spaces in resolve, but when compiling,\n // like `markdown-rs`.\n // Tabs don’t work, and virtual spaces don’t make sense.\n if (code === 32) {\n effects.enter('space');\n effects.consume(code);\n effects.exit('space');\n return between;\n }\n\n // Closing fence? Could also be data.\n if (code === 96) {\n token = effects.enter(\"codeTextSequence\");\n size = 0;\n return sequenceClose(code);\n }\n if (markdownLineEnding(code)) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return between;\n }\n\n // Data.\n effects.enter(\"codeTextData\");\n return data(code);\n }\n\n /**\n * In data.\n *\n * ```markdown\n * > | `a`\n * ^\n * ```\n *\n * @type {State}\n */\n function data(code) {\n if (code === null || code === 32 || code === 96 || markdownLineEnding(code)) {\n effects.exit(\"codeTextData\");\n return between(code);\n }\n effects.consume(code);\n return data;\n }\n\n /**\n * In closing sequence.\n *\n * ```markdown\n * > | `a`\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceClose(code) {\n // More.\n if (code === 96) {\n effects.consume(code);\n size++;\n return sequenceClose;\n }\n\n // Done!\n if (size === sizeOpen) {\n effects.exit(\"codeTextSequence\");\n effects.exit(\"codeText\");\n return ok(code);\n }\n\n // More or less accents: mark as data.\n token.type = \"codeTextData\";\n return data(code);\n }\n}","/**\n * Some of the internal operations of micromark do lots of editing\n * operations on very large arrays. This runs into problems with two\n * properties of most circa-2020 JavaScript interpreters:\n *\n * - Array-length modifications at the high end of an array (push/pop) are\n * expected to be common and are implemented in (amortized) time\n * proportional to the number of elements added or removed, whereas\n * other operations (shift/unshift and splice) are much less efficient.\n * - Function arguments are passed on the stack, so adding tens of thousands\n * of elements to an array with `arr.push(...newElements)` will frequently\n * cause stack overflows. (see <https://stackoverflow.com/questions/22123769/rangeerror-maximum-call-stack-size-exceeded-why>)\n *\n * SpliceBuffers are an implementation of gap buffers, which are a\n * generalization of the \"queue made of two stacks\" idea. The splice buffer\n * maintains a cursor, and moving the cursor has cost proportional to the\n * distance the cursor moves, but inserting, deleting, or splicing in\n * new information at the cursor is as efficient as the push/pop operation.\n * This allows for an efficient sequence of splices (or pushes, pops, shifts,\n * or unshifts) as long such edits happen at the same part of the array or\n * generally sweep through the array from the beginning to the end.\n *\n * The interface for splice buffers also supports large numbers of inputs by\n * passing a single array argument rather passing multiple arguments on the\n * function call stack.\n *\n * @template T\n * Item type.\n */\nexport class SpliceBuffer {\n /**\n * @param {ReadonlyArray<T> | null | undefined} [initial]\n * Initial items (optional).\n * @returns\n * Splice buffer.\n */\n constructor(initial) {\n /** @type {Array<T>} */\n this.left = initial ? [...initial] : [];\n /** @type {Array<T>} */\n this.right = [];\n }\n\n /**\n * Array access;\n * does not move the cursor.\n *\n * @param {number} index\n * Index.\n * @return {T}\n * Item.\n */\n get(index) {\n if (index < 0 || index >= this.left.length + this.right.length) {\n throw new RangeError('Cannot access index `' + index + '` in a splice buffer of size `' + (this.left.length + this.right.length) + '`');\n }\n if (index < this.left.length) return this.left[index];\n return this.right[this.right.length - index + this.left.length - 1];\n }\n\n /**\n * The length of the splice buffer, one greater than the largest index in the\n * array.\n */\n get length() {\n return this.left.length + this.right.length;\n }\n\n /**\n * Remove and return `list[0]`;\n * moves the cursor to `0`.\n *\n * @returns {T | undefined}\n * Item, optional.\n */\n shift() {\n this.setCursor(0);\n return this.right.pop();\n }\n\n /**\n * Slice the buffer to get an array;\n * does not move the cursor.\n *\n * @param {number} start\n * Start.\n * @param {number | null | undefined} [end]\n * End (optional).\n * @returns {Array<T>}\n * Array of items.\n */\n slice(start, end) {\n /** @type {number} */\n const stop = end === null || end === undefined ? Number.POSITIVE_INFINITY : end;\n if (stop < this.left.length) {\n return this.left.slice(start, stop);\n }\n if (start > this.left.length) {\n return this.right.slice(this.right.length - stop + this.left.length, this.right.length - start + this.left.length).reverse();\n }\n return this.left.slice(start).concat(this.right.slice(this.right.length - stop + this.left.length).reverse());\n }\n\n /**\n * Mimics the behavior of Array.prototype.splice() except for the change of\n * interface necessary to avoid segfaults when patching in very large arrays.\n *\n * This operation moves cursor is moved to `start` and results in the cursor\n * placed after any inserted items.\n *\n * @param {number} start\n * Start;\n * zero-based index at which to start changing the array;\n * negative numbers count backwards from the end of the array and values\n * that are out-of bounds are clamped to the appropriate end of the array.\n * @param {number | null | undefined} [deleteCount=0]\n * Delete count (default: `0`);\n * maximum number of elements to delete, starting from start.\n * @param {Array<T> | null | undefined} [items=[]]\n * Items to include in place of the deleted items (default: `[]`).\n * @return {Array<T>}\n * Any removed items.\n */\n splice(start, deleteCount, items) {\n /** @type {number} */\n const count = deleteCount || 0;\n this.setCursor(Math.trunc(start));\n const removed = this.right.splice(this.right.length - count, Number.POSITIVE_INFINITY);\n if (items) chunkedPush(this.left, items);\n return removed.reverse();\n }\n\n /**\n * Remove and return the highest-numbered item in the array, so\n * `list[list.length - 1]`;\n * Moves the cursor to `length`.\n *\n * @returns {T | undefined}\n * Item, optional.\n */\n pop() {\n this.setCursor(Number.POSITIVE_INFINITY);\n return this.left.pop();\n }\n\n /**\n * Inserts a single item to the high-numbered side of the array;\n * moves the cursor to `length`.\n *\n * @param {T} item\n * Item.\n * @returns {undefined}\n * Nothing.\n */\n push(item) {\n this.setCursor(Number.POSITIVE_INFINITY);\n this.left.push(item);\n }\n\n /**\n * Inserts many items to the high-numbered side of the array.\n * Moves the cursor to `length`.\n *\n * @param {Array<T>} items\n * Items.\n * @returns {undefined}\n * Nothing.\n */\n pushMany(items) {\n this.setCursor(Number.POSITIVE_INFINITY);\n chunkedPush(this.left, items);\n }\n\n /**\n * Inserts a single item to the low-numbered side of the array;\n * Moves the cursor to `0`.\n *\n * @param {T} item\n * Item.\n * @returns {undefined}\n * Nothing.\n */\n unshift(item) {\n this.setCursor(0);\n this.right.push(item);\n }\n\n /**\n * Inserts many items to the low-numbered side of the array;\n * moves the cursor to `0`.\n *\n * @param {Array<T>} items\n * Items.\n * @returns {undefined}\n * Nothing.\n */\n unshiftMany(items) {\n this.setCursor(0);\n chunkedPush(this.right, items.reverse());\n }\n\n /**\n * Move the cursor to a specific position in the array. Requires\n * time proportional to the distance moved.\n *\n * If `n < 0`, the cursor will end up at the beginning.\n * If `n > length`, the cursor will end up at the end.\n *\n * @param {number} n\n * Position.\n * @return {undefined}\n * Nothing.\n */\n setCursor(n) {\n if (n === this.left.length || n > this.left.length && this.right.length === 0 || n < 0 && this.left.length === 0) return;\n if (n < this.left.length) {\n // Move cursor to the this.left\n const removed = this.left.splice(n, Number.POSITIVE_INFINITY);\n chunkedPush(this.right, removed.reverse());\n } else {\n // Move cursor to the this.right\n const removed = this.right.splice(this.left.length + this.right.length - n, Number.POSITIVE_INFINITY);\n chunkedPush(this.left, removed.reverse());\n }\n }\n}\n\n/**\n * Avoid stack overflow by pushing items onto the stack in segments\n *\n * @template T\n * Item type.\n * @param {Array<T>} list\n * List to inject into.\n * @param {ReadonlyArray<T>} right\n * Items to inject.\n * @return {undefined}\n * Nothing.\n */\nfunction chunkedPush(list, right) {\n /** @type {number} */\n let chunkStart = 0;\n if (right.length < 10000) {\n list.push(...right);\n } else {\n while (chunkStart < right.length) {\n list.push(...right.slice(chunkStart, chunkStart + 10000));\n chunkStart += 10000;\n }\n }\n}","/**\n * @import {Chunk, Event, Token} from 'micromark-util-types'\n */\n\nimport { splice } from 'micromark-util-chunked';\nimport { SpliceBuffer } from './lib/splice-buffer.js';\n\n// Hidden API exposed for testing.\nexport { SpliceBuffer } from './lib/splice-buffer.js';\n\n/**\n * Tokenize subcontent.\n *\n * @param {Array<Event>} eventsArray\n * List of events.\n * @returns {boolean}\n * Whether subtokens were found.\n */\n// eslint-disable-next-line complexity\nexport function subtokenize(eventsArray) {\n /** @type {Record<string, number>} */\n const jumps = {};\n let index = -1;\n /** @type {Event} */\n let event;\n /** @type {number | undefined} */\n let lineIndex;\n /** @type {number} */\n let otherIndex;\n /** @type {Event} */\n let otherEvent;\n /** @type {Array<Event>} */\n let parameters;\n /** @type {Array<Event>} */\n let subevents;\n /** @type {boolean | undefined} */\n let more;\n const events = new SpliceBuffer(eventsArray);\n while (++index < events.length) {\n while (index in jumps) {\n index = jumps[index];\n }\n event = events.get(index);\n\n // Add a hook for the GFM tasklist extension, which needs to know if text\n // is in the first content of a list item.\n if (index && event[1].type === \"chunkFlow\" && events.get(index - 1)[1].type === \"listItemPrefix\") {\n subevents = event[1]._tokenizer.events;\n otherIndex = 0;\n if (otherIndex < subevents.length && subevents[otherIndex][1].type === \"lineEndingBlank\") {\n otherIndex += 2;\n }\n if (otherIndex < subevents.length && subevents[otherIndex][1].type === \"content\") {\n while (++otherIndex < subevents.length) {\n if (subevents[otherIndex][1].type === \"content\") {\n break;\n }\n if (subevents[otherIndex][1].type === \"chunkText\") {\n subevents[otherIndex][1]._isInFirstContentOfListItem = true;\n otherIndex++;\n }\n }\n }\n }\n\n // Enter.\n if (event[0] === 'enter') {\n if (event[1].contentType) {\n Object.assign(jumps, subcontent(events, index));\n index = jumps[index];\n more = true;\n }\n }\n // Exit.\n else if (event[1]._container) {\n otherIndex = index;\n lineIndex = undefined;\n while (otherIndex--) {\n otherEvent = events.get(otherIndex);\n if (otherEvent[1].type === \"lineEnding\" || otherEvent[1].type === \"lineEndingBlank\") {\n if (otherEvent[0] === 'enter') {\n if (lineIndex) {\n events.get(lineIndex)[1].type = \"lineEndingBlank\";\n }\n otherEvent[1].type = \"lineEnding\";\n lineIndex = otherIndex;\n }\n } else if (otherEvent[1].type === \"linePrefix\" || otherEvent[1].type === \"listItemIndent\") {\n // Move past.\n } else {\n break;\n }\n }\n if (lineIndex) {\n // Fix position.\n event[1].end = {\n ...events.get(lineIndex)[1].start\n };\n\n // Switch container exit w/ line endings.\n parameters = events.slice(lineIndex, index);\n parameters.unshift(event);\n events.splice(lineIndex, index - lineIndex + 1, parameters);\n }\n }\n }\n\n // The changes to the `events` buffer must be copied back into the eventsArray\n splice(eventsArray, 0, Number.POSITIVE_INFINITY, events.slice(0));\n return !more;\n}\n\n/**\n * Tokenize embedded tokens.\n *\n * @param {SpliceBuffer<Event>} events\n * Events.\n * @param {number} eventIndex\n * Index.\n * @returns {Record<string, number>}\n * Gaps.\n */\nfunction subcontent(events, eventIndex) {\n const token = events.get(eventIndex)[1];\n const context = events.get(eventIndex)[2];\n let startPosition = eventIndex - 1;\n /** @type {Array<number>} */\n const startPositions = [];\n let tokenizer = token._tokenizer;\n if (!tokenizer) {\n tokenizer = context.parser[token.contentType](token.start);\n if (token._contentTypeTextTrailing) {\n tokenizer._contentTypeTextTrailing = true;\n }\n }\n const childEvents = tokenizer.events;\n /** @type {Array<[number, number]>} */\n const jumps = [];\n /** @type {Record<string, number>} */\n const gaps = {};\n /** @type {Array<Chunk>} */\n let stream;\n /** @type {Token | undefined} */\n let previous;\n let index = -1;\n /** @type {Token | undefined} */\n let current = token;\n let adjust = 0;\n let start = 0;\n const breaks = [start];\n\n // Loop forward through the linked tokens to pass them in order to the\n // subtokenizer.\n while (current) {\n // Find the position of the event for this token.\n while (events.get(++startPosition)[1] !== current) {\n // Empty.\n }\n startPositions.push(startPosition);\n if (!current._tokenizer) {\n stream = context.sliceStream(current);\n if (!current.next) {\n stream.push(null);\n }\n if (previous) {\n tokenizer.defineSkip(current.start);\n }\n if (current._isInFirstContentOfListItem) {\n tokenizer._gfmTasklistFirstContentOfListItem = true;\n }\n tokenizer.write(stream);\n if (current._isInFirstContentOfListItem) {\n tokenizer._gfmTasklistFirstContentOfListItem = undefined;\n }\n }\n\n // Unravel the next token.\n previous = current;\n current = current.next;\n }\n\n // Now, loop back through all events (and linked tokens), to figure out which\n // parts belong where.\n current = token;\n while (++index < childEvents.length) {\n if (\n // Find a void token that includes a break.\n childEvents[index][0] === 'exit' && childEvents[index - 1][0] === 'enter' && childEvents[index][1].type === childEvents[index - 1][1].type && childEvents[index][1].start.line !== childEvents[index][1].end.line) {\n start = index + 1;\n breaks.push(start);\n // Help GC.\n current._tokenizer = undefined;\n current.previous = undefined;\n current = current.next;\n }\n }\n\n // Help GC.\n tokenizer.events = [];\n\n // If there’s one more token (which is the cases for lines that end in an\n // EOF), that’s perfect: the last point we found starts it.\n // If there isn’t then make sure any remaining content is added to it.\n if (current) {\n // Help GC.\n current._tokenizer = undefined;\n current.previous = undefined;\n } else {\n breaks.pop();\n }\n\n // Now splice the events from the subtokenizer into the current events,\n // moving back to front so that splice indices aren’t affected.\n index = breaks.length;\n while (index--) {\n const slice = childEvents.slice(breaks[index], breaks[index + 1]);\n const start = startPositions.pop();\n jumps.push([start, start + slice.length - 1]);\n events.splice(start, 2, slice);\n }\n jumps.reverse();\n index = -1;\n while (++index < jumps.length) {\n gaps[adjust + jumps[index][0]] = adjust + jumps[index][1];\n adjust += jumps[index][1] - jumps[index][0] - 1;\n }\n return gaps;\n}","/**\n * @import {\n * Construct,\n * Resolver,\n * State,\n * TokenizeContext,\n * Tokenizer,\n * Token\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding } from 'micromark-util-character';\nimport { subtokenize } from 'micromark-util-subtokenize';\n/**\n * No name because it must not be turned off.\n * @type {Construct}\n */\nexport const content = {\n resolve: resolveContent,\n tokenize: tokenizeContent\n};\n\n/** @type {Construct} */\nconst continuationConstruct = {\n partial: true,\n tokenize: tokenizeContinuation\n};\n\n/**\n * Content is transparent: it’s parsed right now. That way, definitions are also\n * parsed right now: before text in paragraphs (specifically, media) are parsed.\n *\n * @type {Resolver}\n */\nfunction resolveContent(events) {\n subtokenize(events);\n return events;\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeContent(effects, ok) {\n /** @type {Token | undefined} */\n let previous;\n return chunkStart;\n\n /**\n * Before a content chunk.\n *\n * ```markdown\n * > | abc\n * ^\n * ```\n *\n * @type {State}\n */\n function chunkStart(code) {\n effects.enter(\"content\");\n previous = effects.enter(\"chunkContent\", {\n contentType: \"content\"\n });\n return chunkInside(code);\n }\n\n /**\n * In a content chunk.\n *\n * ```markdown\n * > | abc\n * ^^^\n * ```\n *\n * @type {State}\n */\n function chunkInside(code) {\n if (code === null) {\n return contentEnd(code);\n }\n\n // To do: in `markdown-rs`, each line is parsed on its own, and everything\n // is stitched together resolving.\n if (markdownLineEnding(code)) {\n return effects.check(continuationConstruct, contentContinue, contentEnd)(code);\n }\n\n // Data.\n effects.consume(code);\n return chunkInside;\n }\n\n /**\n *\n *\n * @type {State}\n */\n function contentEnd(code) {\n effects.exit(\"chunkContent\");\n effects.exit(\"content\");\n return ok(code);\n }\n\n /**\n *\n *\n * @type {State}\n */\n function contentContinue(code) {\n effects.consume(code);\n effects.exit(\"chunkContent\");\n previous.next = effects.enter(\"chunkContent\", {\n contentType: \"content\",\n previous\n });\n previous = previous.next;\n return chunkInside;\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeContinuation(effects, ok, nok) {\n const self = this;\n return startLookahead;\n\n /**\n *\n *\n * @type {State}\n */\n function startLookahead(code) {\n effects.exit(\"chunkContent\");\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return factorySpace(effects, prefixed, \"linePrefix\");\n }\n\n /**\n *\n *\n * @type {State}\n */\n function prefixed(code) {\n if (code === null || markdownLineEnding(code)) {\n return nok(code);\n }\n\n // Always populated by defaults.\n\n const tail = self.events[self.events.length - 1];\n if (!self.parser.constructs.disable.null.includes('codeIndented') && tail && tail[1].type === \"linePrefix\" && tail[2].sliceSerialize(tail[1], true).length >= 4) {\n return ok(code);\n }\n return effects.interrupt(self.parser.constructs.flow, nok, ok)(code);\n }\n}","/**\n * @import {Effects, State, TokenType} from 'micromark-util-types'\n */\n\nimport { asciiControl, markdownLineEndingOrSpace, markdownLineEnding } from 'micromark-util-character';\n/**\n * Parse destinations.\n *\n * ###### Examples\n *\n * ```markdown\n * <a>\n * <a\\>b>\n * <a b>\n * <a)>\n * a\n * a\\)b\n * a(b)c\n * a(b)\n * ```\n *\n * @param {Effects} effects\n * Context.\n * @param {State} ok\n * State switched to when successful.\n * @param {State} nok\n * State switched to when unsuccessful.\n * @param {TokenType} type\n * Type for whole (`<a>` or `b`).\n * @param {TokenType} literalType\n * Type when enclosed (`<a>`).\n * @param {TokenType} literalMarkerType\n * Type for enclosing (`<` and `>`).\n * @param {TokenType} rawType\n * Type when not enclosed (`b`).\n * @param {TokenType} stringType\n * Type for the value (`a` or `b`).\n * @param {number | undefined} [max=Infinity]\n * Depth of nested parens (inclusive).\n * @returns {State}\n * Start state.\n */\nexport function factoryDestination(effects, ok, nok, type, literalType, literalMarkerType, rawType, stringType, max) {\n const limit = max || Number.POSITIVE_INFINITY;\n let balance = 0;\n return start;\n\n /**\n * Start of destination.\n *\n * ```markdown\n * > | <aa>\n * ^\n * > | aa\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n if (code === 60) {\n effects.enter(type);\n effects.enter(literalType);\n effects.enter(literalMarkerType);\n effects.consume(code);\n effects.exit(literalMarkerType);\n return enclosedBefore;\n }\n\n // ASCII control, space, closing paren.\n if (code === null || code === 32 || code === 41 || asciiControl(code)) {\n return nok(code);\n }\n effects.enter(type);\n effects.enter(rawType);\n effects.enter(stringType);\n effects.enter(\"chunkString\", {\n contentType: \"string\"\n });\n return raw(code);\n }\n\n /**\n * After `<`, at an enclosed destination.\n *\n * ```markdown\n * > | <aa>\n * ^\n * ```\n *\n * @type {State}\n */\n function enclosedBefore(code) {\n if (code === 62) {\n effects.enter(literalMarkerType);\n effects.consume(code);\n effects.exit(literalMarkerType);\n effects.exit(literalType);\n effects.exit(type);\n return ok;\n }\n effects.enter(stringType);\n effects.enter(\"chunkString\", {\n contentType: \"string\"\n });\n return enclosed(code);\n }\n\n /**\n * In enclosed destination.\n *\n * ```markdown\n * > | <aa>\n * ^\n * ```\n *\n * @type {State}\n */\n function enclosed(code) {\n if (code === 62) {\n effects.exit(\"chunkString\");\n effects.exit(stringType);\n return enclosedBefore(code);\n }\n if (code === null || code === 60 || markdownLineEnding(code)) {\n return nok(code);\n }\n effects.consume(code);\n return code === 92 ? enclosedEscape : enclosed;\n }\n\n /**\n * After `\\`, at a special character.\n *\n * ```markdown\n * > | <a\\*a>\n * ^\n * ```\n *\n * @type {State}\n */\n function enclosedEscape(code) {\n if (code === 60 || code === 62 || code === 92) {\n effects.consume(code);\n return enclosed;\n }\n return enclosed(code);\n }\n\n /**\n * In raw destination.\n *\n * ```markdown\n * > | aa\n * ^\n * ```\n *\n * @type {State}\n */\n function raw(code) {\n if (!balance && (code === null || code === 41 || markdownLineEndingOrSpace(code))) {\n effects.exit(\"chunkString\");\n effects.exit(stringType);\n effects.exit(rawType);\n effects.exit(type);\n return ok(code);\n }\n if (balance < limit && code === 40) {\n effects.consume(code);\n balance++;\n return raw;\n }\n if (code === 41) {\n effects.consume(code);\n balance--;\n return raw;\n }\n\n // ASCII control (but *not* `\\0`) and space and `(`.\n // Note: in `markdown-rs`, `\\0` exists in codes, in `micromark-js` it\n // doesn’t.\n if (code === null || code === 32 || code === 40 || asciiControl(code)) {\n return nok(code);\n }\n effects.consume(code);\n return code === 92 ? rawEscape : raw;\n }\n\n /**\n * After `\\`, at special character.\n *\n * ```markdown\n * > | a\\*a\n * ^\n * ```\n *\n * @type {State}\n */\n function rawEscape(code) {\n if (code === 40 || code === 41 || code === 92) {\n effects.consume(code);\n return raw;\n }\n return raw(code);\n }\n}","/**\n * @import {\n * Effects,\n * State,\n * TokenizeContext,\n * TokenType\n * } from 'micromark-util-types'\n */\n\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/**\n * Parse labels.\n *\n * > 👉 **Note**: labels in markdown are capped at 999 characters in the string.\n *\n * ###### Examples\n *\n * ```markdown\n * [a]\n * [a\n * b]\n * [a\\]b]\n * ```\n *\n * @this {TokenizeContext}\n * Tokenize context.\n * @param {Effects} effects\n * Context.\n * @param {State} ok\n * State switched to when successful.\n * @param {State} nok\n * State switched to when unsuccessful.\n * @param {TokenType} type\n * Type of the whole label (`[a]`).\n * @param {TokenType} markerType\n * Type for the markers (`[` and `]`).\n * @param {TokenType} stringType\n * Type for the identifier (`a`).\n * @returns {State}\n * Start state.\n */\nexport function factoryLabel(effects, ok, nok, type, markerType, stringType) {\n const self = this;\n let size = 0;\n /** @type {boolean} */\n let seen;\n return start;\n\n /**\n * Start of label.\n *\n * ```markdown\n * > | [a]\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(type);\n effects.enter(markerType);\n effects.consume(code);\n effects.exit(markerType);\n effects.enter(stringType);\n return atBreak;\n }\n\n /**\n * In label, at something, before something else.\n *\n * ```markdown\n * > | [a]\n * ^\n * ```\n *\n * @type {State}\n */\n function atBreak(code) {\n if (size > 999 || code === null || code === 91 || code === 93 && !seen ||\n // To do: remove in the future once we’ve switched from\n // `micromark-extension-footnote` to `micromark-extension-gfm-footnote`,\n // which doesn’t need this.\n // Hidden footnotes hook.\n /* c8 ignore next 3 */\n code === 94 && !size && '_hiddenFootnoteSupport' in self.parser.constructs) {\n return nok(code);\n }\n if (code === 93) {\n effects.exit(stringType);\n effects.enter(markerType);\n effects.consume(code);\n effects.exit(markerType);\n effects.exit(type);\n return ok;\n }\n\n // To do: indent? Link chunks and EOLs together?\n if (markdownLineEnding(code)) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return atBreak;\n }\n effects.enter(\"chunkString\", {\n contentType: \"string\"\n });\n return labelInside(code);\n }\n\n /**\n * In label, in text.\n *\n * ```markdown\n * > | [a]\n * ^\n * ```\n *\n * @type {State}\n */\n function labelInside(code) {\n if (code === null || code === 91 || code === 93 || markdownLineEnding(code) || size++ > 999) {\n effects.exit(\"chunkString\");\n return atBreak(code);\n }\n effects.consume(code);\n if (!seen) seen = !markdownSpace(code);\n return code === 92 ? labelEscape : labelInside;\n }\n\n /**\n * After `\\`, at a special character.\n *\n * ```markdown\n * > | [a\\*a]\n * ^\n * ```\n *\n * @type {State}\n */\n function labelEscape(code) {\n if (code === 91 || code === 92 || code === 93) {\n effects.consume(code);\n size++;\n return labelInside;\n }\n return labelInside(code);\n }\n}","/**\n * @import {\n * Code,\n * Effects,\n * State,\n * TokenType\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding } from 'micromark-util-character';\n/**\n * Parse titles.\n *\n * ###### Examples\n *\n * ```markdown\n * \"a\"\n * 'b'\n * (c)\n * \"a\n * b\"\n * 'a\n * b'\n * (a\\)b)\n * ```\n *\n * @param {Effects} effects\n * Context.\n * @param {State} ok\n * State switched to when successful.\n * @param {State} nok\n * State switched to when unsuccessful.\n * @param {TokenType} type\n * Type of the whole title (`\"a\"`, `'b'`, `(c)`).\n * @param {TokenType} markerType\n * Type for the markers (`\"`, `'`, `(`, and `)`).\n * @param {TokenType} stringType\n * Type for the value (`a`).\n * @returns {State}\n * Start state.\n */\nexport function factoryTitle(effects, ok, nok, type, markerType, stringType) {\n /** @type {NonNullable<Code>} */\n let marker;\n return start;\n\n /**\n * Start of title.\n *\n * ```markdown\n * > | \"a\"\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n if (code === 34 || code === 39 || code === 40) {\n effects.enter(type);\n effects.enter(markerType);\n effects.consume(code);\n effects.exit(markerType);\n marker = code === 40 ? 41 : code;\n return begin;\n }\n return nok(code);\n }\n\n /**\n * After opening marker.\n *\n * This is also used at the closing marker.\n *\n * ```markdown\n * > | \"a\"\n * ^\n * ```\n *\n * @type {State}\n */\n function begin(code) {\n if (code === marker) {\n effects.enter(markerType);\n effects.consume(code);\n effects.exit(markerType);\n effects.exit(type);\n return ok;\n }\n effects.enter(stringType);\n return atBreak(code);\n }\n\n /**\n * At something, before something else.\n *\n * ```markdown\n * > | \"a\"\n * ^\n * ```\n *\n * @type {State}\n */\n function atBreak(code) {\n if (code === marker) {\n effects.exit(stringType);\n return begin(marker);\n }\n if (code === null) {\n return nok(code);\n }\n\n // Note: blank lines can’t exist in content.\n if (markdownLineEnding(code)) {\n // To do: use `space_or_tab_eol_with_options`, connect.\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return factorySpace(effects, atBreak, \"linePrefix\");\n }\n effects.enter(\"chunkString\", {\n contentType: \"string\"\n });\n return inside(code);\n }\n\n /**\n *\n *\n * @type {State}\n */\n function inside(code) {\n if (code === marker || code === null || markdownLineEnding(code)) {\n effects.exit(\"chunkString\");\n return atBreak(code);\n }\n effects.consume(code);\n return code === 92 ? escape : inside;\n }\n\n /**\n * After `\\`, at a special character.\n *\n * ```markdown\n * > | \"a\\*b\"\n * ^\n * ```\n *\n * @type {State}\n */\n function escape(code) {\n if (code === marker || code === 92) {\n effects.consume(code);\n return inside;\n }\n return inside(code);\n }\n}","/**\n * @import {Effects, State} from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/**\n * Parse spaces and tabs.\n *\n * There is no `nok` parameter:\n *\n * * line endings or spaces in markdown are often optional, in which case this\n * factory can be used and `ok` will be switched to whether spaces were found\n * or not\n * * one line ending or space can be detected with\n * `markdownLineEndingOrSpace(code)` right before using `factoryWhitespace`\n *\n * @param {Effects} effects\n * Context.\n * @param {State} ok\n * State switched to when successful.\n * @returns {State}\n * Start state.\n */\nexport function factoryWhitespace(effects, ok) {\n /** @type {boolean} */\n let seen;\n return start;\n\n /** @type {State} */\n function start(code) {\n if (markdownLineEnding(code)) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n seen = true;\n return start;\n }\n if (markdownSpace(code)) {\n return factorySpace(effects, start, seen ? \"linePrefix\" : \"lineSuffix\")(code);\n }\n return ok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factoryDestination } from 'micromark-factory-destination';\nimport { factoryLabel } from 'micromark-factory-label';\nimport { factorySpace } from 'micromark-factory-space';\nimport { factoryTitle } from 'micromark-factory-title';\nimport { factoryWhitespace } from 'micromark-factory-whitespace';\nimport { markdownLineEndingOrSpace, markdownLineEnding, markdownSpace } from 'micromark-util-character';\nimport { normalizeIdentifier } from 'micromark-util-normalize-identifier';\n/** @type {Construct} */\nexport const definition = {\n name: 'definition',\n tokenize: tokenizeDefinition\n};\n\n/** @type {Construct} */\nconst titleBefore = {\n partial: true,\n tokenize: tokenizeTitleBefore\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeDefinition(effects, ok, nok) {\n const self = this;\n /** @type {string} */\n let identifier;\n return start;\n\n /**\n * At start of a definition.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // Do not interrupt paragraphs (but do follow definitions).\n // To do: do `interrupt` the way `markdown-rs` does.\n // To do: parse whitespace the way `markdown-rs` does.\n effects.enter(\"definition\");\n return before(code);\n }\n\n /**\n * After optional whitespace, at `[`.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function before(code) {\n // To do: parse whitespace the way `markdown-rs` does.\n\n return factoryLabel.call(self, effects, labelAfter,\n // Note: we don’t need to reset the way `markdown-rs` does.\n nok, \"definitionLabel\", \"definitionLabelMarker\", \"definitionLabelString\")(code);\n }\n\n /**\n * After label.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function labelAfter(code) {\n identifier = normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1));\n if (code === 58) {\n effects.enter(\"definitionMarker\");\n effects.consume(code);\n effects.exit(\"definitionMarker\");\n return markerAfter;\n }\n return nok(code);\n }\n\n /**\n * After marker.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function markerAfter(code) {\n // Note: whitespace is optional.\n return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, destinationBefore)(code) : destinationBefore(code);\n }\n\n /**\n * Before destination.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function destinationBefore(code) {\n return factoryDestination(effects, destinationAfter,\n // Note: we don’t need to reset the way `markdown-rs` does.\n nok, \"definitionDestination\", \"definitionDestinationLiteral\", \"definitionDestinationLiteralMarker\", \"definitionDestinationRaw\", \"definitionDestinationString\")(code);\n }\n\n /**\n * After destination.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function destinationAfter(code) {\n return effects.attempt(titleBefore, after, after)(code);\n }\n\n /**\n * After definition.\n *\n * ```markdown\n * > | [a]: b\n * ^\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n return markdownSpace(code) ? factorySpace(effects, afterWhitespace, \"whitespace\")(code) : afterWhitespace(code);\n }\n\n /**\n * After definition, after optional whitespace.\n *\n * ```markdown\n * > | [a]: b\n * ^\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function afterWhitespace(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"definition\");\n\n // Note: we don’t care about uniqueness.\n // It’s likely that that doesn’t happen very frequently.\n // It is more likely that it wastes precious time.\n self.parser.defined.push(identifier);\n\n // To do: `markdown-rs` interrupt.\n // // You’d be interrupting.\n // tokenizer.interrupt = true\n return ok(code);\n }\n return nok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeTitleBefore(effects, ok, nok) {\n return titleBefore;\n\n /**\n * After destination, at whitespace.\n *\n * ```markdown\n * > | [a]: b\n * ^\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function titleBefore(code) {\n return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, beforeMarker)(code) : nok(code);\n }\n\n /**\n * At title.\n *\n * ```markdown\n * | [a]: b\n * > | \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function beforeMarker(code) {\n return factoryTitle(effects, titleAfter, nok, \"definitionTitle\", \"definitionTitleMarker\", \"definitionTitleString\")(code);\n }\n\n /**\n * After title.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function titleAfter(code) {\n return markdownSpace(code) ? factorySpace(effects, titleAfterOptionalWhitespace, \"whitespace\")(code) : titleAfterOptionalWhitespace(code);\n }\n\n /**\n * After title, after optional whitespace.\n *\n * ```markdown\n * > | [a]: b \"c\"\n * ^\n * ```\n *\n * @type {State}\n */\n function titleAfterOptionalWhitespace(code) {\n return code === null || markdownLineEnding(code) ? ok(code) : nok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { markdownLineEnding } from 'micromark-util-character';\n/** @type {Construct} */\nexport const hardBreakEscape = {\n name: 'hardBreakEscape',\n tokenize: tokenizeHardBreakEscape\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeHardBreakEscape(effects, ok, nok) {\n return start;\n\n /**\n * Start of a hard break (escape).\n *\n * ```markdown\n * > | a\\\n * ^\n * | b\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"hardBreakEscape\");\n effects.consume(code);\n return after;\n }\n\n /**\n * After `\\`, at eol.\n *\n * ```markdown\n * > | a\\\n * ^\n * | b\n * ```\n *\n * @type {State}\n */\n function after(code) {\n if (markdownLineEnding(code)) {\n effects.exit(\"hardBreakEscape\");\n return ok(code);\n }\n return nok(code);\n }\n}","/**\n * @import {\n * Construct,\n * Resolver,\n * State,\n * TokenizeContext,\n * Tokenizer,\n * Token\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEndingOrSpace, markdownLineEnding, markdownSpace } from 'micromark-util-character';\nimport { splice } from 'micromark-util-chunked';\n/** @type {Construct} */\nexport const headingAtx = {\n name: 'headingAtx',\n resolve: resolveHeadingAtx,\n tokenize: tokenizeHeadingAtx\n};\n\n/** @type {Resolver} */\nfunction resolveHeadingAtx(events, context) {\n let contentEnd = events.length - 2;\n let contentStart = 3;\n /** @type {Token} */\n let content;\n /** @type {Token} */\n let text;\n\n // Prefix whitespace, part of the opening.\n if (events[contentStart][1].type === \"whitespace\") {\n contentStart += 2;\n }\n\n // Suffix whitespace, part of the closing.\n if (contentEnd - 2 > contentStart && events[contentEnd][1].type === \"whitespace\") {\n contentEnd -= 2;\n }\n if (events[contentEnd][1].type === \"atxHeadingSequence\" && (contentStart === contentEnd - 1 || contentEnd - 4 > contentStart && events[contentEnd - 2][1].type === \"whitespace\")) {\n contentEnd -= contentStart + 1 === contentEnd ? 2 : 4;\n }\n if (contentEnd > contentStart) {\n content = {\n type: \"atxHeadingText\",\n start: events[contentStart][1].start,\n end: events[contentEnd][1].end\n };\n text = {\n type: \"chunkText\",\n start: events[contentStart][1].start,\n end: events[contentEnd][1].end,\n contentType: \"text\"\n };\n splice(events, contentStart, contentEnd - contentStart + 1, [['enter', content, context], ['enter', text, context], ['exit', text, context], ['exit', content, context]]);\n }\n return events;\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeHeadingAtx(effects, ok, nok) {\n let size = 0;\n return start;\n\n /**\n * Start of a heading (atx).\n *\n * ```markdown\n * > | ## aa\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // To do: parse indent like `markdown-rs`.\n effects.enter(\"atxHeading\");\n return before(code);\n }\n\n /**\n * After optional whitespace, at `#`.\n *\n * ```markdown\n * > | ## aa\n * ^\n * ```\n *\n * @type {State}\n */\n function before(code) {\n effects.enter(\"atxHeadingSequence\");\n return sequenceOpen(code);\n }\n\n /**\n * In opening sequence.\n *\n * ```markdown\n * > | ## aa\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceOpen(code) {\n if (code === 35 && size++ < 6) {\n effects.consume(code);\n return sequenceOpen;\n }\n\n // Always at least one `#`.\n if (code === null || markdownLineEndingOrSpace(code)) {\n effects.exit(\"atxHeadingSequence\");\n return atBreak(code);\n }\n return nok(code);\n }\n\n /**\n * After something, before something else.\n *\n * ```markdown\n * > | ## aa\n * ^\n * ```\n *\n * @type {State}\n */\n function atBreak(code) {\n if (code === 35) {\n effects.enter(\"atxHeadingSequence\");\n return sequenceFurther(code);\n }\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"atxHeading\");\n // To do: interrupt like `markdown-rs`.\n // // Feel free to interrupt.\n // tokenizer.interrupt = false\n return ok(code);\n }\n if (markdownSpace(code)) {\n return factorySpace(effects, atBreak, \"whitespace\")(code);\n }\n\n // To do: generate `data` tokens, add the `text` token later.\n // Needs edit map, see: `markdown.rs`.\n effects.enter(\"atxHeadingText\");\n return data(code);\n }\n\n /**\n * In further sequence (after whitespace).\n *\n * Could be normal “visible” hashes in the heading or a final sequence.\n *\n * ```markdown\n * > | ## aa ##\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceFurther(code) {\n if (code === 35) {\n effects.consume(code);\n return sequenceFurther;\n }\n effects.exit(\"atxHeadingSequence\");\n return atBreak(code);\n }\n\n /**\n * In text.\n *\n * ```markdown\n * > | ## aa\n * ^\n * ```\n *\n * @type {State}\n */\n function data(code) {\n if (code === null || code === 35 || markdownLineEndingOrSpace(code)) {\n effects.exit(\"atxHeadingText\");\n return atBreak(code);\n }\n effects.consume(code);\n return data;\n }\n}","/**\n * List of lowercase HTML “block” tag names.\n *\n * The list, when parsing HTML (flow), results in more relaxed rules (condition\n * 6).\n * Because they are known blocks, the HTML-like syntax doesn’t have to be\n * strictly parsed.\n * For tag names not in this list, a more strict algorithm (condition 7) is used\n * to detect whether the HTML-like syntax is seen as HTML (flow) or not.\n *\n * This is copied from:\n * <https://spec.commonmark.org/0.30/#html-blocks>.\n *\n * > 👉 **Note**: `search` was added in `CommonMark@0.31`.\n */\nexport const htmlBlockNames = [\n 'address',\n 'article',\n 'aside',\n 'base',\n 'basefont',\n 'blockquote',\n 'body',\n 'caption',\n 'center',\n 'col',\n 'colgroup',\n 'dd',\n 'details',\n 'dialog',\n 'dir',\n 'div',\n 'dl',\n 'dt',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'frame',\n 'frameset',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'head',\n 'header',\n 'hr',\n 'html',\n 'iframe',\n 'legend',\n 'li',\n 'link',\n 'main',\n 'menu',\n 'menuitem',\n 'nav',\n 'noframes',\n 'ol',\n 'optgroup',\n 'option',\n 'p',\n 'param',\n 'search',\n 'section',\n 'summary',\n 'table',\n 'tbody',\n 'td',\n 'tfoot',\n 'th',\n 'thead',\n 'title',\n 'tr',\n 'track',\n 'ul'\n]\n\n/**\n * List of lowercase HTML “raw” tag names.\n *\n * The list, when parsing HTML (flow), results in HTML that can include lines\n * without exiting, until a closing tag also in this list is found (condition\n * 1).\n *\n * This module is copied from:\n * <https://spec.commonmark.org/0.30/#html-blocks>.\n *\n * > 👉 **Note**: `textarea` was added in `CommonMark@0.30`.\n */\nexport const htmlRawNames = ['pre', 'script', 'style', 'textarea']\n","/**\n * @import {\n * Code,\n * Construct,\n * Resolver,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { asciiAlphanumeric, asciiAlpha, markdownLineEndingOrSpace, markdownLineEnding, markdownSpace } from 'micromark-util-character';\nimport { htmlBlockNames, htmlRawNames } from 'micromark-util-html-tag-name';\nimport { blankLine } from './blank-line.js';\n\n/** @type {Construct} */\nexport const htmlFlow = {\n concrete: true,\n name: 'htmlFlow',\n resolveTo: resolveToHtmlFlow,\n tokenize: tokenizeHtmlFlow\n};\n\n/** @type {Construct} */\nconst blankLineBefore = {\n partial: true,\n tokenize: tokenizeBlankLineBefore\n};\nconst nonLazyContinuationStart = {\n partial: true,\n tokenize: tokenizeNonLazyContinuationStart\n};\n\n/** @type {Resolver} */\nfunction resolveToHtmlFlow(events) {\n let index = events.length;\n while (index--) {\n if (events[index][0] === 'enter' && events[index][1].type === \"htmlFlow\") {\n break;\n }\n }\n if (index > 1 && events[index - 2][1].type === \"linePrefix\") {\n // Add the prefix start to the HTML token.\n events[index][1].start = events[index - 2][1].start;\n // Add the prefix start to the HTML line token.\n events[index + 1][1].start = events[index - 2][1].start;\n // Remove the line prefix.\n events.splice(index - 2, 2);\n }\n return events;\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeHtmlFlow(effects, ok, nok) {\n const self = this;\n /** @type {number} */\n let marker;\n /** @type {boolean} */\n let closingTag;\n /** @type {string} */\n let buffer;\n /** @type {number} */\n let index;\n /** @type {Code} */\n let markerB;\n return start;\n\n /**\n * Start of HTML (flow).\n *\n * ```markdown\n * > | <x />\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // To do: parse indent like `markdown-rs`.\n return before(code);\n }\n\n /**\n * At `<`, after optional whitespace.\n *\n * ```markdown\n * > | <x />\n * ^\n * ```\n *\n * @type {State}\n */\n function before(code) {\n effects.enter(\"htmlFlow\");\n effects.enter(\"htmlFlowData\");\n effects.consume(code);\n return open;\n }\n\n /**\n * After `<`, at tag name or other stuff.\n *\n * ```markdown\n * > | <x />\n * ^\n * > | <!doctype>\n * ^\n * > | <!--xxx-->\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (code === 33) {\n effects.consume(code);\n return declarationOpen;\n }\n if (code === 47) {\n effects.consume(code);\n closingTag = true;\n return tagCloseStart;\n }\n if (code === 63) {\n effects.consume(code);\n marker = 3;\n // To do:\n // tokenizer.concrete = true\n // To do: use `markdown-rs` style interrupt.\n // While we’re in an instruction instead of a declaration, we’re on a `?`\n // right now, so we do need to search for `>`, similar to declarations.\n return self.interrupt ? ok : continuationDeclarationInside;\n }\n\n // ASCII alphabetical.\n if (asciiAlpha(code)) {\n // Always the case.\n effects.consume(code);\n buffer = String.fromCharCode(code);\n return tagName;\n }\n return nok(code);\n }\n\n /**\n * After `<!`, at declaration, comment, or CDATA.\n *\n * ```markdown\n * > | <!doctype>\n * ^\n * > | <!--xxx-->\n * ^\n * > | <![CDATA[>&<]]>\n * ^\n * ```\n *\n * @type {State}\n */\n function declarationOpen(code) {\n if (code === 45) {\n effects.consume(code);\n marker = 2;\n return commentOpenInside;\n }\n if (code === 91) {\n effects.consume(code);\n marker = 5;\n index = 0;\n return cdataOpenInside;\n }\n\n // ASCII alphabetical.\n if (asciiAlpha(code)) {\n effects.consume(code);\n marker = 4;\n // // Do not form containers.\n // tokenizer.concrete = true\n return self.interrupt ? ok : continuationDeclarationInside;\n }\n return nok(code);\n }\n\n /**\n * After `<!-`, inside a comment, at another `-`.\n *\n * ```markdown\n * > | <!--xxx-->\n * ^\n * ```\n *\n * @type {State}\n */\n function commentOpenInside(code) {\n if (code === 45) {\n effects.consume(code);\n // // Do not form containers.\n // tokenizer.concrete = true\n return self.interrupt ? ok : continuationDeclarationInside;\n }\n return nok(code);\n }\n\n /**\n * After `<![`, inside CDATA, expecting `CDATA[`.\n *\n * ```markdown\n * > | <![CDATA[>&<]]>\n * ^^^^^^\n * ```\n *\n * @type {State}\n */\n function cdataOpenInside(code) {\n const value = \"CDATA[\";\n if (code === value.charCodeAt(index++)) {\n effects.consume(code);\n if (index === value.length) {\n // // Do not form containers.\n // tokenizer.concrete = true\n return self.interrupt ? ok : continuation;\n }\n return cdataOpenInside;\n }\n return nok(code);\n }\n\n /**\n * After `</`, in closing tag, at tag name.\n *\n * ```markdown\n * > | </x>\n * ^\n * ```\n *\n * @type {State}\n */\n function tagCloseStart(code) {\n if (asciiAlpha(code)) {\n // Always the case.\n effects.consume(code);\n buffer = String.fromCharCode(code);\n return tagName;\n }\n return nok(code);\n }\n\n /**\n * In tag name.\n *\n * ```markdown\n * > | <ab>\n * ^^\n * > | </ab>\n * ^^\n * ```\n *\n * @type {State}\n */\n function tagName(code) {\n if (code === null || code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {\n const slash = code === 47;\n const name = buffer.toLowerCase();\n if (!slash && !closingTag && htmlRawNames.includes(name)) {\n marker = 1;\n // // Do not form containers.\n // tokenizer.concrete = true\n return self.interrupt ? ok(code) : continuation(code);\n }\n if (htmlBlockNames.includes(buffer.toLowerCase())) {\n marker = 6;\n if (slash) {\n effects.consume(code);\n return basicSelfClosing;\n }\n\n // // Do not form containers.\n // tokenizer.concrete = true\n return self.interrupt ? ok(code) : continuation(code);\n }\n marker = 7;\n // Do not support complete HTML when interrupting.\n return self.interrupt && !self.parser.lazy[self.now().line] ? nok(code) : closingTag ? completeClosingTagAfter(code) : completeAttributeNameBefore(code);\n }\n\n // ASCII alphanumerical and `-`.\n if (code === 45 || asciiAlphanumeric(code)) {\n effects.consume(code);\n buffer += String.fromCharCode(code);\n return tagName;\n }\n return nok(code);\n }\n\n /**\n * After closing slash of a basic tag name.\n *\n * ```markdown\n * > | <div/>\n * ^\n * ```\n *\n * @type {State}\n */\n function basicSelfClosing(code) {\n if (code === 62) {\n effects.consume(code);\n // // Do not form containers.\n // tokenizer.concrete = true\n return self.interrupt ? ok : continuation;\n }\n return nok(code);\n }\n\n /**\n * After closing slash of a complete tag name.\n *\n * ```markdown\n * > | <x/>\n * ^\n * ```\n *\n * @type {State}\n */\n function completeClosingTagAfter(code) {\n if (markdownSpace(code)) {\n effects.consume(code);\n return completeClosingTagAfter;\n }\n return completeEnd(code);\n }\n\n /**\n * At an attribute name.\n *\n * At first, this state is used after a complete tag name, after whitespace,\n * where it expects optional attributes or the end of the tag.\n * It is also reused after attributes, when expecting more optional\n * attributes.\n *\n * ```markdown\n * > | <a />\n * ^\n * > | <a :b>\n * ^\n * > | <a _b>\n * ^\n * > | <a b>\n * ^\n * > | <a >\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAttributeNameBefore(code) {\n if (code === 47) {\n effects.consume(code);\n return completeEnd;\n }\n\n // ASCII alphanumerical and `:` and `_`.\n if (code === 58 || code === 95 || asciiAlpha(code)) {\n effects.consume(code);\n return completeAttributeName;\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return completeAttributeNameBefore;\n }\n return completeEnd(code);\n }\n\n /**\n * In attribute name.\n *\n * ```markdown\n * > | <a :b>\n * ^\n * > | <a _b>\n * ^\n * > | <a b>\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAttributeName(code) {\n // ASCII alphanumerical and `-`, `.`, `:`, and `_`.\n if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {\n effects.consume(code);\n return completeAttributeName;\n }\n return completeAttributeNameAfter(code);\n }\n\n /**\n * After attribute name, at an optional initializer, the end of the tag, or\n * whitespace.\n *\n * ```markdown\n * > | <a b>\n * ^\n * > | <a b=c>\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAttributeNameAfter(code) {\n if (code === 61) {\n effects.consume(code);\n return completeAttributeValueBefore;\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return completeAttributeNameAfter;\n }\n return completeAttributeNameBefore(code);\n }\n\n /**\n * Before unquoted, double quoted, or single quoted attribute value, allowing\n * whitespace.\n *\n * ```markdown\n * > | <a b=c>\n * ^\n * > | <a b=\"c\">\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAttributeValueBefore(code) {\n if (code === null || code === 60 || code === 61 || code === 62 || code === 96) {\n return nok(code);\n }\n if (code === 34 || code === 39) {\n effects.consume(code);\n markerB = code;\n return completeAttributeValueQuoted;\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return completeAttributeValueBefore;\n }\n return completeAttributeValueUnquoted(code);\n }\n\n /**\n * In double or single quoted attribute value.\n *\n * ```markdown\n * > | <a b=\"c\">\n * ^\n * > | <a b='c'>\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAttributeValueQuoted(code) {\n if (code === markerB) {\n effects.consume(code);\n markerB = null;\n return completeAttributeValueQuotedAfter;\n }\n if (code === null || markdownLineEnding(code)) {\n return nok(code);\n }\n effects.consume(code);\n return completeAttributeValueQuoted;\n }\n\n /**\n * In unquoted attribute value.\n *\n * ```markdown\n * > | <a b=c>\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAttributeValueUnquoted(code) {\n if (code === null || code === 34 || code === 39 || code === 47 || code === 60 || code === 61 || code === 62 || code === 96 || markdownLineEndingOrSpace(code)) {\n return completeAttributeNameAfter(code);\n }\n effects.consume(code);\n return completeAttributeValueUnquoted;\n }\n\n /**\n * After double or single quoted attribute value, before whitespace or the\n * end of the tag.\n *\n * ```markdown\n * > | <a b=\"c\">\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAttributeValueQuotedAfter(code) {\n if (code === 47 || code === 62 || markdownSpace(code)) {\n return completeAttributeNameBefore(code);\n }\n return nok(code);\n }\n\n /**\n * In certain circumstances of a complete tag where only an `>` is allowed.\n *\n * ```markdown\n * > | <a b=\"c\">\n * ^\n * ```\n *\n * @type {State}\n */\n function completeEnd(code) {\n if (code === 62) {\n effects.consume(code);\n return completeAfter;\n }\n return nok(code);\n }\n\n /**\n * After `>` in a complete tag.\n *\n * ```markdown\n * > | <x>\n * ^\n * ```\n *\n * @type {State}\n */\n function completeAfter(code) {\n if (code === null || markdownLineEnding(code)) {\n // // Do not form containers.\n // tokenizer.concrete = true\n return continuation(code);\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return completeAfter;\n }\n return nok(code);\n }\n\n /**\n * In continuation of any HTML kind.\n *\n * ```markdown\n * > | <!--xxx-->\n * ^\n * ```\n *\n * @type {State}\n */\n function continuation(code) {\n if (code === 45 && marker === 2) {\n effects.consume(code);\n return continuationCommentInside;\n }\n if (code === 60 && marker === 1) {\n effects.consume(code);\n return continuationRawTagOpen;\n }\n if (code === 62 && marker === 4) {\n effects.consume(code);\n return continuationClose;\n }\n if (code === 63 && marker === 3) {\n effects.consume(code);\n return continuationDeclarationInside;\n }\n if (code === 93 && marker === 5) {\n effects.consume(code);\n return continuationCdataInside;\n }\n if (markdownLineEnding(code) && (marker === 6 || marker === 7)) {\n effects.exit(\"htmlFlowData\");\n return effects.check(blankLineBefore, continuationAfter, continuationStart)(code);\n }\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"htmlFlowData\");\n return continuationStart(code);\n }\n effects.consume(code);\n return continuation;\n }\n\n /**\n * In continuation, at eol.\n *\n * ```markdown\n * > | <x>\n * ^\n * | asd\n * ```\n *\n * @type {State}\n */\n function continuationStart(code) {\n return effects.check(nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code);\n }\n\n /**\n * In continuation, at eol, before non-lazy content.\n *\n * ```markdown\n * > | <x>\n * ^\n * | asd\n * ```\n *\n * @type {State}\n */\n function continuationStartNonLazy(code) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return continuationBefore;\n }\n\n /**\n * In continuation, before non-lazy content.\n *\n * ```markdown\n * | <x>\n * > | asd\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationBefore(code) {\n if (code === null || markdownLineEnding(code)) {\n return continuationStart(code);\n }\n effects.enter(\"htmlFlowData\");\n return continuation(code);\n }\n\n /**\n * In comment continuation, after one `-`, expecting another.\n *\n * ```markdown\n * > | <!--xxx-->\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationCommentInside(code) {\n if (code === 45) {\n effects.consume(code);\n return continuationDeclarationInside;\n }\n return continuation(code);\n }\n\n /**\n * In raw continuation, after `<`, at `/`.\n *\n * ```markdown\n * > | <script>console.log(1)</script>\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationRawTagOpen(code) {\n if (code === 47) {\n effects.consume(code);\n buffer = '';\n return continuationRawEndTag;\n }\n return continuation(code);\n }\n\n /**\n * In raw continuation, after `</`, in a raw tag name.\n *\n * ```markdown\n * > | <script>console.log(1)</script>\n * ^^^^^^\n * ```\n *\n * @type {State}\n */\n function continuationRawEndTag(code) {\n if (code === 62) {\n const name = buffer.toLowerCase();\n if (htmlRawNames.includes(name)) {\n effects.consume(code);\n return continuationClose;\n }\n return continuation(code);\n }\n if (asciiAlpha(code) && buffer.length < 8) {\n // Always the case.\n effects.consume(code);\n buffer += String.fromCharCode(code);\n return continuationRawEndTag;\n }\n return continuation(code);\n }\n\n /**\n * In cdata continuation, after `]`, expecting `]>`.\n *\n * ```markdown\n * > | <![CDATA[>&<]]>\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationCdataInside(code) {\n if (code === 93) {\n effects.consume(code);\n return continuationDeclarationInside;\n }\n return continuation(code);\n }\n\n /**\n * In declaration or instruction continuation, at `>`.\n *\n * ```markdown\n * > | <!-->\n * ^\n * > | <?>\n * ^\n * > | <!q>\n * ^\n * > | <!--ab-->\n * ^\n * > | <![CDATA[>&<]]>\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationDeclarationInside(code) {\n if (code === 62) {\n effects.consume(code);\n return continuationClose;\n }\n\n // More dashes.\n if (code === 45 && marker === 2) {\n effects.consume(code);\n return continuationDeclarationInside;\n }\n return continuation(code);\n }\n\n /**\n * In closed continuation: everything we get until the eol/eof is part of it.\n *\n * ```markdown\n * > | <!doctype>\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationClose(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"htmlFlowData\");\n return continuationAfter(code);\n }\n effects.consume(code);\n return continuationClose;\n }\n\n /**\n * Done.\n *\n * ```markdown\n * > | <!doctype>\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationAfter(code) {\n effects.exit(\"htmlFlow\");\n // // Feel free to interrupt.\n // tokenizer.interrupt = false\n // // No longer concrete.\n // tokenizer.concrete = false\n return ok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeNonLazyContinuationStart(effects, ok, nok) {\n const self = this;\n return start;\n\n /**\n * At eol, before continuation.\n *\n * ```markdown\n * > | * ```js\n * ^\n * | b\n * ```\n *\n * @type {State}\n */\n function start(code) {\n if (markdownLineEnding(code)) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return after;\n }\n return nok(code);\n }\n\n /**\n * A continuation.\n *\n * ```markdown\n * | * ```js\n * > | b\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n return self.parser.lazy[self.now().line] ? nok(code) : ok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeBlankLineBefore(effects, ok, nok) {\n return start;\n\n /**\n * Before eol, expecting blank line.\n *\n * ```markdown\n * > | <div>\n * ^\n * |\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return effects.attempt(blankLine, ok, nok);\n }\n}","/**\n * @import {\n * Code,\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { asciiAlphanumeric, asciiAlpha, markdownLineEndingOrSpace, markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nexport const htmlText = {\n name: 'htmlText',\n tokenize: tokenizeHtmlText\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeHtmlText(effects, ok, nok) {\n const self = this;\n /** @type {NonNullable<Code> | undefined} */\n let marker;\n /** @type {number} */\n let index;\n /** @type {State} */\n let returnState;\n return start;\n\n /**\n * Start of HTML (text).\n *\n * ```markdown\n * > | a <b> c\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"htmlText\");\n effects.enter(\"htmlTextData\");\n effects.consume(code);\n return open;\n }\n\n /**\n * After `<`, at tag name or other stuff.\n *\n * ```markdown\n * > | a <b> c\n * ^\n * > | a <!doctype> c\n * ^\n * > | a <!--b--> c\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (code === 33) {\n effects.consume(code);\n return declarationOpen;\n }\n if (code === 47) {\n effects.consume(code);\n return tagCloseStart;\n }\n if (code === 63) {\n effects.consume(code);\n return instruction;\n }\n\n // ASCII alphabetical.\n if (asciiAlpha(code)) {\n effects.consume(code);\n return tagOpen;\n }\n return nok(code);\n }\n\n /**\n * After `<!`, at declaration, comment, or CDATA.\n *\n * ```markdown\n * > | a <!doctype> c\n * ^\n * > | a <!--b--> c\n * ^\n * > | a <![CDATA[>&<]]> c\n * ^\n * ```\n *\n * @type {State}\n */\n function declarationOpen(code) {\n if (code === 45) {\n effects.consume(code);\n return commentOpenInside;\n }\n if (code === 91) {\n effects.consume(code);\n index = 0;\n return cdataOpenInside;\n }\n if (asciiAlpha(code)) {\n effects.consume(code);\n return declaration;\n }\n return nok(code);\n }\n\n /**\n * In a comment, after `<!-`, at another `-`.\n *\n * ```markdown\n * > | a <!--b--> c\n * ^\n * ```\n *\n * @type {State}\n */\n function commentOpenInside(code) {\n if (code === 45) {\n effects.consume(code);\n return commentEnd;\n }\n return nok(code);\n }\n\n /**\n * In comment.\n *\n * ```markdown\n * > | a <!--b--> c\n * ^\n * ```\n *\n * @type {State}\n */\n function comment(code) {\n if (code === null) {\n return nok(code);\n }\n if (code === 45) {\n effects.consume(code);\n return commentClose;\n }\n if (markdownLineEnding(code)) {\n returnState = comment;\n return lineEndingBefore(code);\n }\n effects.consume(code);\n return comment;\n }\n\n /**\n * In comment, after `-`.\n *\n * ```markdown\n * > | a <!--b--> c\n * ^\n * ```\n *\n * @type {State}\n */\n function commentClose(code) {\n if (code === 45) {\n effects.consume(code);\n return commentEnd;\n }\n return comment(code);\n }\n\n /**\n * In comment, after `--`.\n *\n * ```markdown\n * > | a <!--b--> c\n * ^\n * ```\n *\n * @type {State}\n */\n function commentEnd(code) {\n return code === 62 ? end(code) : code === 45 ? commentClose(code) : comment(code);\n }\n\n /**\n * After `<![`, in CDATA, expecting `CDATA[`.\n *\n * ```markdown\n * > | a <![CDATA[>&<]]> b\n * ^^^^^^\n * ```\n *\n * @type {State}\n */\n function cdataOpenInside(code) {\n const value = \"CDATA[\";\n if (code === value.charCodeAt(index++)) {\n effects.consume(code);\n return index === value.length ? cdata : cdataOpenInside;\n }\n return nok(code);\n }\n\n /**\n * In CDATA.\n *\n * ```markdown\n * > | a <![CDATA[>&<]]> b\n * ^^^\n * ```\n *\n * @type {State}\n */\n function cdata(code) {\n if (code === null) {\n return nok(code);\n }\n if (code === 93) {\n effects.consume(code);\n return cdataClose;\n }\n if (markdownLineEnding(code)) {\n returnState = cdata;\n return lineEndingBefore(code);\n }\n effects.consume(code);\n return cdata;\n }\n\n /**\n * In CDATA, after `]`, at another `]`.\n *\n * ```markdown\n * > | a <![CDATA[>&<]]> b\n * ^\n * ```\n *\n * @type {State}\n */\n function cdataClose(code) {\n if (code === 93) {\n effects.consume(code);\n return cdataEnd;\n }\n return cdata(code);\n }\n\n /**\n * In CDATA, after `]]`, at `>`.\n *\n * ```markdown\n * > | a <![CDATA[>&<]]> b\n * ^\n * ```\n *\n * @type {State}\n */\n function cdataEnd(code) {\n if (code === 62) {\n return end(code);\n }\n if (code === 93) {\n effects.consume(code);\n return cdataEnd;\n }\n return cdata(code);\n }\n\n /**\n * In declaration.\n *\n * ```markdown\n * > | a <!b> c\n * ^\n * ```\n *\n * @type {State}\n */\n function declaration(code) {\n if (code === null || code === 62) {\n return end(code);\n }\n if (markdownLineEnding(code)) {\n returnState = declaration;\n return lineEndingBefore(code);\n }\n effects.consume(code);\n return declaration;\n }\n\n /**\n * In instruction.\n *\n * ```markdown\n * > | a <?b?> c\n * ^\n * ```\n *\n * @type {State}\n */\n function instruction(code) {\n if (code === null) {\n return nok(code);\n }\n if (code === 63) {\n effects.consume(code);\n return instructionClose;\n }\n if (markdownLineEnding(code)) {\n returnState = instruction;\n return lineEndingBefore(code);\n }\n effects.consume(code);\n return instruction;\n }\n\n /**\n * In instruction, after `?`, at `>`.\n *\n * ```markdown\n * > | a <?b?> c\n * ^\n * ```\n *\n * @type {State}\n */\n function instructionClose(code) {\n return code === 62 ? end(code) : instruction(code);\n }\n\n /**\n * After `</`, in closing tag, at tag name.\n *\n * ```markdown\n * > | a </b> c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagCloseStart(code) {\n // ASCII alphabetical.\n if (asciiAlpha(code)) {\n effects.consume(code);\n return tagClose;\n }\n return nok(code);\n }\n\n /**\n * After `</x`, in a tag name.\n *\n * ```markdown\n * > | a </b> c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagClose(code) {\n // ASCII alphanumerical and `-`.\n if (code === 45 || asciiAlphanumeric(code)) {\n effects.consume(code);\n return tagClose;\n }\n return tagCloseBetween(code);\n }\n\n /**\n * In closing tag, after tag name.\n *\n * ```markdown\n * > | a </b> c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagCloseBetween(code) {\n if (markdownLineEnding(code)) {\n returnState = tagCloseBetween;\n return lineEndingBefore(code);\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return tagCloseBetween;\n }\n return end(code);\n }\n\n /**\n * After `<x`, in opening tag name.\n *\n * ```markdown\n * > | a <b> c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpen(code) {\n // ASCII alphanumerical and `-`.\n if (code === 45 || asciiAlphanumeric(code)) {\n effects.consume(code);\n return tagOpen;\n }\n if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {\n return tagOpenBetween(code);\n }\n return nok(code);\n }\n\n /**\n * In opening tag, after tag name.\n *\n * ```markdown\n * > | a <b> c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenBetween(code) {\n if (code === 47) {\n effects.consume(code);\n return end;\n }\n\n // ASCII alphabetical and `:` and `_`.\n if (code === 58 || code === 95 || asciiAlpha(code)) {\n effects.consume(code);\n return tagOpenAttributeName;\n }\n if (markdownLineEnding(code)) {\n returnState = tagOpenBetween;\n return lineEndingBefore(code);\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return tagOpenBetween;\n }\n return end(code);\n }\n\n /**\n * In attribute name.\n *\n * ```markdown\n * > | a <b c> d\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeName(code) {\n // ASCII alphabetical and `-`, `.`, `:`, and `_`.\n if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {\n effects.consume(code);\n return tagOpenAttributeName;\n }\n return tagOpenAttributeNameAfter(code);\n }\n\n /**\n * After attribute name, before initializer, the end of the tag, or\n * whitespace.\n *\n * ```markdown\n * > | a <b c> d\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeNameAfter(code) {\n if (code === 61) {\n effects.consume(code);\n return tagOpenAttributeValueBefore;\n }\n if (markdownLineEnding(code)) {\n returnState = tagOpenAttributeNameAfter;\n return lineEndingBefore(code);\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return tagOpenAttributeNameAfter;\n }\n return tagOpenBetween(code);\n }\n\n /**\n * Before unquoted, double quoted, or single quoted attribute value, allowing\n * whitespace.\n *\n * ```markdown\n * > | a <b c=d> e\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeValueBefore(code) {\n if (code === null || code === 60 || code === 61 || code === 62 || code === 96) {\n return nok(code);\n }\n if (code === 34 || code === 39) {\n effects.consume(code);\n marker = code;\n return tagOpenAttributeValueQuoted;\n }\n if (markdownLineEnding(code)) {\n returnState = tagOpenAttributeValueBefore;\n return lineEndingBefore(code);\n }\n if (markdownSpace(code)) {\n effects.consume(code);\n return tagOpenAttributeValueBefore;\n }\n effects.consume(code);\n return tagOpenAttributeValueUnquoted;\n }\n\n /**\n * In double or single quoted attribute value.\n *\n * ```markdown\n * > | a <b c=\"d\"> e\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeValueQuoted(code) {\n if (code === marker) {\n effects.consume(code);\n marker = undefined;\n return tagOpenAttributeValueQuotedAfter;\n }\n if (code === null) {\n return nok(code);\n }\n if (markdownLineEnding(code)) {\n returnState = tagOpenAttributeValueQuoted;\n return lineEndingBefore(code);\n }\n effects.consume(code);\n return tagOpenAttributeValueQuoted;\n }\n\n /**\n * In unquoted attribute value.\n *\n * ```markdown\n * > | a <b c=d> e\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeValueUnquoted(code) {\n if (code === null || code === 34 || code === 39 || code === 60 || code === 61 || code === 96) {\n return nok(code);\n }\n if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {\n return tagOpenBetween(code);\n }\n effects.consume(code);\n return tagOpenAttributeValueUnquoted;\n }\n\n /**\n * After double or single quoted attribute value, before whitespace or the end\n * of the tag.\n *\n * ```markdown\n * > | a <b c=\"d\"> e\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeValueQuotedAfter(code) {\n if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {\n return tagOpenBetween(code);\n }\n return nok(code);\n }\n\n /**\n * In certain circumstances of a tag where only an `>` is allowed.\n *\n * ```markdown\n * > | a <b c=\"d\"> e\n * ^\n * ```\n *\n * @type {State}\n */\n function end(code) {\n if (code === 62) {\n effects.consume(code);\n effects.exit(\"htmlTextData\");\n effects.exit(\"htmlText\");\n return ok;\n }\n return nok(code);\n }\n\n /**\n * At eol.\n *\n * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about\n * > empty tokens.\n *\n * ```markdown\n * > | a <!--a\n * ^\n * | b-->\n * ```\n *\n * @type {State}\n */\n function lineEndingBefore(code) {\n effects.exit(\"htmlTextData\");\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return lineEndingAfter;\n }\n\n /**\n * After eol, at optional whitespace.\n *\n * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about\n * > empty tokens.\n *\n * ```markdown\n * | a <!--a\n * > | b-->\n * ^\n * ```\n *\n * @type {State}\n */\n function lineEndingAfter(code) {\n // Always populated by defaults.\n\n return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, \"linePrefix\", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : lineEndingAfterPrefix(code);\n }\n\n /**\n * After eol, after optional whitespace.\n *\n * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about\n * > empty tokens.\n *\n * ```markdown\n * | a <!--a\n * > | b-->\n * ^\n * ```\n *\n * @type {State}\n */\n function lineEndingAfterPrefix(code) {\n effects.enter(\"htmlTextData\");\n return returnState(code);\n }\n}","/**\n * @import {\n * Construct,\n * Event,\n * Resolver,\n * State,\n * TokenizeContext,\n * Tokenizer,\n * Token\n * } from 'micromark-util-types'\n */\n\nimport { factoryDestination } from 'micromark-factory-destination';\nimport { factoryLabel } from 'micromark-factory-label';\nimport { factoryTitle } from 'micromark-factory-title';\nimport { factoryWhitespace } from 'micromark-factory-whitespace';\nimport { markdownLineEndingOrSpace } from 'micromark-util-character';\nimport { push, splice } from 'micromark-util-chunked';\nimport { normalizeIdentifier } from 'micromark-util-normalize-identifier';\nimport { resolveAll } from 'micromark-util-resolve-all';\n/** @type {Construct} */\nexport const labelEnd = {\n name: 'labelEnd',\n resolveAll: resolveAllLabelEnd,\n resolveTo: resolveToLabelEnd,\n tokenize: tokenizeLabelEnd\n};\n\n/** @type {Construct} */\nconst resourceConstruct = {\n tokenize: tokenizeResource\n};\n/** @type {Construct} */\nconst referenceFullConstruct = {\n tokenize: tokenizeReferenceFull\n};\n/** @type {Construct} */\nconst referenceCollapsedConstruct = {\n tokenize: tokenizeReferenceCollapsed\n};\n\n/** @type {Resolver} */\nfunction resolveAllLabelEnd(events) {\n let index = -1;\n /** @type {Array<Event>} */\n const newEvents = [];\n while (++index < events.length) {\n const token = events[index][1];\n newEvents.push(events[index]);\n if (token.type === \"labelImage\" || token.type === \"labelLink\" || token.type === \"labelEnd\") {\n // Remove the marker.\n const offset = token.type === \"labelImage\" ? 4 : 2;\n token.type = \"data\";\n index += offset;\n }\n }\n\n // If the events are equal, we don't have to copy newEvents to events\n if (events.length !== newEvents.length) {\n splice(events, 0, events.length, newEvents);\n }\n return events;\n}\n\n/** @type {Resolver} */\nfunction resolveToLabelEnd(events, context) {\n let index = events.length;\n let offset = 0;\n /** @type {Token} */\n let token;\n /** @type {number | undefined} */\n let open;\n /** @type {number | undefined} */\n let close;\n /** @type {Array<Event>} */\n let media;\n\n // Find an opening.\n while (index--) {\n token = events[index][1];\n if (open) {\n // If we see another link, or inactive link label, we’ve been here before.\n if (token.type === \"link\" || token.type === \"labelLink\" && token._inactive) {\n break;\n }\n\n // Mark other link openings as inactive, as we can’t have links in\n // links.\n if (events[index][0] === 'enter' && token.type === \"labelLink\") {\n token._inactive = true;\n }\n } else if (close) {\n if (events[index][0] === 'enter' && (token.type === \"labelImage\" || token.type === \"labelLink\") && !token._balanced) {\n open = index;\n if (token.type !== \"labelLink\") {\n offset = 2;\n break;\n }\n }\n } else if (token.type === \"labelEnd\") {\n close = index;\n }\n }\n const group = {\n type: events[open][1].type === \"labelLink\" ? \"link\" : \"image\",\n start: {\n ...events[open][1].start\n },\n end: {\n ...events[events.length - 1][1].end\n }\n };\n const label = {\n type: \"label\",\n start: {\n ...events[open][1].start\n },\n end: {\n ...events[close][1].end\n }\n };\n const text = {\n type: \"labelText\",\n start: {\n ...events[open + offset + 2][1].end\n },\n end: {\n ...events[close - 2][1].start\n }\n };\n media = [['enter', group, context], ['enter', label, context]];\n\n // Opening marker.\n media = push(media, events.slice(open + 1, open + offset + 3));\n\n // Text open.\n media = push(media, [['enter', text, context]]);\n\n // Always populated by defaults.\n\n // Between.\n media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + offset + 4, close - 3), context));\n\n // Text close, marker close, label close.\n media = push(media, [['exit', text, context], events[close - 2], events[close - 1], ['exit', label, context]]);\n\n // Reference, resource, or so.\n media = push(media, events.slice(close + 1));\n\n // Media close.\n media = push(media, [['exit', group, context]]);\n splice(events, open, events.length, media);\n return events;\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeLabelEnd(effects, ok, nok) {\n const self = this;\n let index = self.events.length;\n /** @type {Token} */\n let labelStart;\n /** @type {boolean} */\n let defined;\n\n // Find an opening.\n while (index--) {\n if ((self.events[index][1].type === \"labelImage\" || self.events[index][1].type === \"labelLink\") && !self.events[index][1]._balanced) {\n labelStart = self.events[index][1];\n break;\n }\n }\n return start;\n\n /**\n * Start of label end.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * > | [a][b] c\n * ^\n * > | [a][] b\n * ^\n * > | [a] b\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // If there is not an okay opening.\n if (!labelStart) {\n return nok(code);\n }\n\n // If the corresponding label (link) start is marked as inactive,\n // it means we’d be wrapping a link, like this:\n //\n // ```markdown\n // > | a [b [c](d) e](f) g.\n // ^\n // ```\n //\n // We can’t have that, so it’s just balanced brackets.\n if (labelStart._inactive) {\n return labelEndNok(code);\n }\n defined = self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize({\n start: labelStart.end,\n end: self.now()\n })));\n effects.enter(\"labelEnd\");\n effects.enter(\"labelMarker\");\n effects.consume(code);\n effects.exit(\"labelMarker\");\n effects.exit(\"labelEnd\");\n return after;\n }\n\n /**\n * After `]`.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * > | [a][b] c\n * ^\n * > | [a][] b\n * ^\n * > | [a] b\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n // Note: `markdown-rs` also parses GFM footnotes here, which for us is in\n // an extension.\n\n // Resource (`[asd](fgh)`)?\n if (code === 40) {\n return effects.attempt(resourceConstruct, labelEndOk, defined ? labelEndOk : labelEndNok)(code);\n }\n\n // Full (`[asd][fgh]`) or collapsed (`[asd][]`) reference?\n if (code === 91) {\n return effects.attempt(referenceFullConstruct, labelEndOk, defined ? referenceNotFull : labelEndNok)(code);\n }\n\n // Shortcut (`[asd]`) reference?\n return defined ? labelEndOk(code) : labelEndNok(code);\n }\n\n /**\n * After `]`, at `[`, but not at a full reference.\n *\n * > 👉 **Note**: we only get here if the label is defined.\n *\n * ```markdown\n * > | [a][] b\n * ^\n * > | [a] b\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceNotFull(code) {\n return effects.attempt(referenceCollapsedConstruct, labelEndOk, labelEndNok)(code);\n }\n\n /**\n * Done, we found something.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * > | [a][b] c\n * ^\n * > | [a][] b\n * ^\n * > | [a] b\n * ^\n * ```\n *\n * @type {State}\n */\n function labelEndOk(code) {\n // Note: `markdown-rs` does a bunch of stuff here.\n return ok(code);\n }\n\n /**\n * Done, it’s nothing.\n *\n * There was an okay opening, but we didn’t match anything.\n *\n * ```markdown\n * > | [a](b c\n * ^\n * > | [a][b c\n * ^\n * > | [a] b\n * ^\n * ```\n *\n * @type {State}\n */\n function labelEndNok(code) {\n labelStart._balanced = true;\n return nok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeResource(effects, ok, nok) {\n return resourceStart;\n\n /**\n * At a resource.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceStart(code) {\n effects.enter(\"resource\");\n effects.enter(\"resourceMarker\");\n effects.consume(code);\n effects.exit(\"resourceMarker\");\n return resourceBefore;\n }\n\n /**\n * In resource, after `(`, at optional whitespace.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceBefore(code) {\n return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceOpen)(code) : resourceOpen(code);\n }\n\n /**\n * In resource, after optional whitespace, at `)` or a destination.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceOpen(code) {\n if (code === 41) {\n return resourceEnd(code);\n }\n return factoryDestination(effects, resourceDestinationAfter, resourceDestinationMissing, \"resourceDestination\", \"resourceDestinationLiteral\", \"resourceDestinationLiteralMarker\", \"resourceDestinationRaw\", \"resourceDestinationString\", 32)(code);\n }\n\n /**\n * In resource, after destination, at optional whitespace.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceDestinationAfter(code) {\n return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceBetween)(code) : resourceEnd(code);\n }\n\n /**\n * At invalid destination.\n *\n * ```markdown\n * > | [a](<<) b\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceDestinationMissing(code) {\n return nok(code);\n }\n\n /**\n * In resource, after destination and whitespace, at `(` or title.\n *\n * ```markdown\n * > | [a](b ) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceBetween(code) {\n if (code === 34 || code === 39 || code === 40) {\n return factoryTitle(effects, resourceTitleAfter, nok, \"resourceTitle\", \"resourceTitleMarker\", \"resourceTitleString\")(code);\n }\n return resourceEnd(code);\n }\n\n /**\n * In resource, after title, at optional whitespace.\n *\n * ```markdown\n * > | [a](b \"c\") d\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceTitleAfter(code) {\n return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceEnd)(code) : resourceEnd(code);\n }\n\n /**\n * In resource, at `)`.\n *\n * ```markdown\n * > | [a](b) d\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceEnd(code) {\n if (code === 41) {\n effects.enter(\"resourceMarker\");\n effects.consume(code);\n effects.exit(\"resourceMarker\");\n effects.exit(\"resource\");\n return ok;\n }\n return nok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeReferenceFull(effects, ok, nok) {\n const self = this;\n return referenceFull;\n\n /**\n * In a reference (full), at the `[`.\n *\n * ```markdown\n * > | [a][b] d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceFull(code) {\n return factoryLabel.call(self, effects, referenceFullAfter, referenceFullMissing, \"reference\", \"referenceMarker\", \"referenceString\")(code);\n }\n\n /**\n * In a reference (full), after `]`.\n *\n * ```markdown\n * > | [a][b] d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceFullAfter(code) {\n return self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1))) ? ok(code) : nok(code);\n }\n\n /**\n * In reference (full) that was missing.\n *\n * ```markdown\n * > | [a][b d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceFullMissing(code) {\n return nok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeReferenceCollapsed(effects, ok, nok) {\n return referenceCollapsedStart;\n\n /**\n * In reference (collapsed), at `[`.\n *\n * > 👉 **Note**: we only get here if the label is defined.\n *\n * ```markdown\n * > | [a][] d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceCollapsedStart(code) {\n // We only attempt a collapsed label if there’s a `[`.\n\n effects.enter(\"reference\");\n effects.enter(\"referenceMarker\");\n effects.consume(code);\n effects.exit(\"referenceMarker\");\n return referenceCollapsedOpen;\n }\n\n /**\n * In reference (collapsed), at `]`.\n *\n * > 👉 **Note**: we only get here if the label is defined.\n *\n * ```markdown\n * > | [a][] d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceCollapsedOpen(code) {\n if (code === 93) {\n effects.enter(\"referenceMarker\");\n effects.consume(code);\n effects.exit(\"referenceMarker\");\n effects.exit(\"reference\");\n return ok;\n }\n return nok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { labelEnd } from './label-end.js';\n\n/** @type {Construct} */\nexport const labelStartImage = {\n name: 'labelStartImage',\n resolveAll: labelEnd.resolveAll,\n tokenize: tokenizeLabelStartImage\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeLabelStartImage(effects, ok, nok) {\n const self = this;\n return start;\n\n /**\n * Start of label (image) start.\n *\n * ```markdown\n * > | a ![b] c\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"labelImage\");\n effects.enter(\"labelImageMarker\");\n effects.consume(code);\n effects.exit(\"labelImageMarker\");\n return open;\n }\n\n /**\n * After `!`, at `[`.\n *\n * ```markdown\n * > | a ![b] c\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (code === 91) {\n effects.enter(\"labelMarker\");\n effects.consume(code);\n effects.exit(\"labelMarker\");\n effects.exit(\"labelImage\");\n return after;\n }\n return nok(code);\n }\n\n /**\n * After `![`.\n *\n * ```markdown\n * > | a ![b] c\n * ^\n * ```\n *\n * This is needed in because, when GFM footnotes are enabled, images never\n * form when started with a `^`.\n * Instead, links form:\n *\n * ```markdown\n * ![^a](b)\n *\n * ![^a][b]\n *\n * [b]: c\n * ```\n *\n * ```html\n * <p>!<a href=\\\"b\\\">^a</a></p>\n * <p>!<a href=\\\"c\\\">^a</a></p>\n * ```\n *\n * @type {State}\n */\n function after(code) {\n // To do: use a new field to do this, this is still needed for\n // `micromark-extension-gfm-footnote`, but the `label-start-link`\n // behavior isn’t.\n // Hidden footnotes hook.\n /* c8 ignore next 3 */\n return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs ? nok(code) : ok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { labelEnd } from './label-end.js';\n\n/** @type {Construct} */\nexport const labelStartLink = {\n name: 'labelStartLink',\n resolveAll: labelEnd.resolveAll,\n tokenize: tokenizeLabelStartLink\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeLabelStartLink(effects, ok, nok) {\n const self = this;\n return start;\n\n /**\n * Start of label (link) start.\n *\n * ```markdown\n * > | a [b] c\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"labelLink\");\n effects.enter(\"labelMarker\");\n effects.consume(code);\n effects.exit(\"labelMarker\");\n effects.exit(\"labelLink\");\n return after;\n }\n\n /** @type {State} */\n function after(code) {\n // To do: this isn’t needed in `micromark-extension-gfm-footnote`,\n // remove.\n // Hidden footnotes hook.\n /* c8 ignore next 3 */\n return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs ? nok(code) : ok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding } from 'micromark-util-character';\n/** @type {Construct} */\nexport const lineEnding = {\n name: 'lineEnding',\n tokenize: tokenizeLineEnding\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeLineEnding(effects, ok) {\n return start;\n\n /** @type {State} */\n function start(code) {\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n return factorySpace(effects, ok, \"linePrefix\");\n }\n}","/**\n * @import {\n * Code,\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nexport const thematicBreak = {\n name: 'thematicBreak',\n tokenize: tokenizeThematicBreak\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeThematicBreak(effects, ok, nok) {\n let size = 0;\n /** @type {NonNullable<Code>} */\n let marker;\n return start;\n\n /**\n * Start of thematic break.\n *\n * ```markdown\n * > | ***\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter(\"thematicBreak\");\n // To do: parse indent like `markdown-rs`.\n return before(code);\n }\n\n /**\n * After optional whitespace, at marker.\n *\n * ```markdown\n * > | ***\n * ^\n * ```\n *\n * @type {State}\n */\n function before(code) {\n marker = code;\n return atBreak(code);\n }\n\n /**\n * After something, before something else.\n *\n * ```markdown\n * > | ***\n * ^\n * ```\n *\n * @type {State}\n */\n function atBreak(code) {\n if (code === marker) {\n effects.enter(\"thematicBreakSequence\");\n return sequence(code);\n }\n if (size >= 3 && (code === null || markdownLineEnding(code))) {\n effects.exit(\"thematicBreak\");\n return ok(code);\n }\n return nok(code);\n }\n\n /**\n * In sequence.\n *\n * ```markdown\n * > | ***\n * ^\n * ```\n *\n * @type {State}\n */\n function sequence(code) {\n if (code === marker) {\n effects.consume(code);\n size++;\n return sequence;\n }\n effects.exit(\"thematicBreakSequence\");\n return markdownSpace(code) ? factorySpace(effects, atBreak, \"whitespace\")(code) : atBreak(code);\n }\n}","/**\n * @import {\n * Code,\n * Construct,\n * Exiter,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { asciiDigit, markdownSpace } from 'micromark-util-character';\nimport { blankLine } from './blank-line.js';\nimport { thematicBreak } from './thematic-break.js';\n\n/** @type {Construct} */\nexport const list = {\n continuation: {\n tokenize: tokenizeListContinuation\n },\n exit: tokenizeListEnd,\n name: 'list',\n tokenize: tokenizeListStart\n};\n\n/** @type {Construct} */\nconst listItemPrefixWhitespaceConstruct = {\n partial: true,\n tokenize: tokenizeListItemPrefixWhitespace\n};\n\n/** @type {Construct} */\nconst indentConstruct = {\n partial: true,\n tokenize: tokenizeIndent\n};\n\n// To do: `markdown-rs` parses list items on their own and later stitches them\n// together.\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeListStart(effects, ok, nok) {\n const self = this;\n const tail = self.events[self.events.length - 1];\n let initialSize = tail && tail[1].type === \"linePrefix\" ? tail[2].sliceSerialize(tail[1], true).length : 0;\n let size = 0;\n return start;\n\n /** @type {State} */\n function start(code) {\n const kind = self.containerState.type || (code === 42 || code === 43 || code === 45 ? \"listUnordered\" : \"listOrdered\");\n if (kind === \"listUnordered\" ? !self.containerState.marker || code === self.containerState.marker : asciiDigit(code)) {\n if (!self.containerState.type) {\n self.containerState.type = kind;\n effects.enter(kind, {\n _container: true\n });\n }\n if (kind === \"listUnordered\") {\n effects.enter(\"listItemPrefix\");\n return code === 42 || code === 45 ? effects.check(thematicBreak, nok, atMarker)(code) : atMarker(code);\n }\n if (!self.interrupt || code === 49) {\n effects.enter(\"listItemPrefix\");\n effects.enter(\"listItemValue\");\n return inside(code);\n }\n }\n return nok(code);\n }\n\n /** @type {State} */\n function inside(code) {\n if (asciiDigit(code) && ++size < 10) {\n effects.consume(code);\n return inside;\n }\n if ((!self.interrupt || size < 2) && (self.containerState.marker ? code === self.containerState.marker : code === 41 || code === 46)) {\n effects.exit(\"listItemValue\");\n return atMarker(code);\n }\n return nok(code);\n }\n\n /**\n * @type {State}\n **/\n function atMarker(code) {\n effects.enter(\"listItemMarker\");\n effects.consume(code);\n effects.exit(\"listItemMarker\");\n self.containerState.marker = self.containerState.marker || code;\n return effects.check(blankLine,\n // Can’t be empty when interrupting.\n self.interrupt ? nok : onBlank, effects.attempt(listItemPrefixWhitespaceConstruct, endOfPrefix, otherPrefix));\n }\n\n /** @type {State} */\n function onBlank(code) {\n self.containerState.initialBlankLine = true;\n initialSize++;\n return endOfPrefix(code);\n }\n\n /** @type {State} */\n function otherPrefix(code) {\n if (markdownSpace(code)) {\n effects.enter(\"listItemPrefixWhitespace\");\n effects.consume(code);\n effects.exit(\"listItemPrefixWhitespace\");\n return endOfPrefix;\n }\n return nok(code);\n }\n\n /** @type {State} */\n function endOfPrefix(code) {\n self.containerState.size = initialSize + self.sliceSerialize(effects.exit(\"listItemPrefix\"), true).length;\n return ok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeListContinuation(effects, ok, nok) {\n const self = this;\n self.containerState._closeFlow = undefined;\n return effects.check(blankLine, onBlank, notBlank);\n\n /** @type {State} */\n function onBlank(code) {\n self.containerState.furtherBlankLines = self.containerState.furtherBlankLines || self.containerState.initialBlankLine;\n\n // We have a blank line.\n // Still, try to consume at most the items size.\n return factorySpace(effects, ok, \"listItemIndent\", self.containerState.size + 1)(code);\n }\n\n /** @type {State} */\n function notBlank(code) {\n if (self.containerState.furtherBlankLines || !markdownSpace(code)) {\n self.containerState.furtherBlankLines = undefined;\n self.containerState.initialBlankLine = undefined;\n return notInCurrentItem(code);\n }\n self.containerState.furtherBlankLines = undefined;\n self.containerState.initialBlankLine = undefined;\n return effects.attempt(indentConstruct, ok, notInCurrentItem)(code);\n }\n\n /** @type {State} */\n function notInCurrentItem(code) {\n // While we do continue, we signal that the flow should be closed.\n self.containerState._closeFlow = true;\n // As we’re closing flow, we’re no longer interrupting.\n self.interrupt = undefined;\n // Always populated by defaults.\n\n return factorySpace(effects, effects.attempt(list, ok, nok), \"linePrefix\", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeIndent(effects, ok, nok) {\n const self = this;\n return factorySpace(effects, afterPrefix, \"listItemIndent\", self.containerState.size + 1);\n\n /** @type {State} */\n function afterPrefix(code) {\n const tail = self.events[self.events.length - 1];\n return tail && tail[1].type === \"listItemIndent\" && tail[2].sliceSerialize(tail[1], true).length === self.containerState.size ? ok(code) : nok(code);\n }\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Exiter}\n */\nfunction tokenizeListEnd(effects) {\n effects.exit(this.containerState.type);\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeListItemPrefixWhitespace(effects, ok, nok) {\n const self = this;\n\n // Always populated by defaults.\n\n return factorySpace(effects, afterPrefix, \"listItemPrefixWhitespace\", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4 + 1);\n\n /** @type {State} */\n function afterPrefix(code) {\n const tail = self.events[self.events.length - 1];\n return !markdownSpace(code) && tail && tail[1].type === \"listItemPrefixWhitespace\" ? ok(code) : nok(code);\n }\n}","/**\n * @import {\n * Code,\n * Construct,\n * Resolver,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nexport const setextUnderline = {\n name: 'setextUnderline',\n resolveTo: resolveToSetextUnderline,\n tokenize: tokenizeSetextUnderline\n};\n\n/** @type {Resolver} */\nfunction resolveToSetextUnderline(events, context) {\n // To do: resolve like `markdown-rs`.\n let index = events.length;\n /** @type {number | undefined} */\n let content;\n /** @type {number | undefined} */\n let text;\n /** @type {number | undefined} */\n let definition;\n\n // Find the opening of the content.\n // It’ll always exist: we don’t tokenize if it isn’t there.\n while (index--) {\n if (events[index][0] === 'enter') {\n if (events[index][1].type === \"content\") {\n content = index;\n break;\n }\n if (events[index][1].type === \"paragraph\") {\n text = index;\n }\n }\n // Exit\n else {\n if (events[index][1].type === \"content\") {\n // Remove the content end (if needed we’ll add it later)\n events.splice(index, 1);\n }\n if (!definition && events[index][1].type === \"definition\") {\n definition = index;\n }\n }\n }\n const heading = {\n type: \"setextHeading\",\n start: {\n ...events[content][1].start\n },\n end: {\n ...events[events.length - 1][1].end\n }\n };\n\n // Change the paragraph to setext heading text.\n events[text][1].type = \"setextHeadingText\";\n\n // If we have definitions in the content, we’ll keep on having content,\n // but we need move it.\n if (definition) {\n events.splice(text, 0, ['enter', heading, context]);\n events.splice(definition + 1, 0, ['exit', events[content][1], context]);\n events[content][1].end = {\n ...events[definition][1].end\n };\n } else {\n events[content][1] = heading;\n }\n\n // Add the heading exit at the end.\n events.push(['exit', heading, context]);\n return events;\n}\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeSetextUnderline(effects, ok, nok) {\n const self = this;\n /** @type {NonNullable<Code>} */\n let marker;\n return start;\n\n /**\n * At start of heading (setext) underline.\n *\n * ```markdown\n * | aa\n * > | ==\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n let index = self.events.length;\n /** @type {boolean | undefined} */\n let paragraph;\n // Find an opening.\n while (index--) {\n // Skip enter/exit of line ending, line prefix, and content.\n // We can now either have a definition or a paragraph.\n if (self.events[index][1].type !== \"lineEnding\" && self.events[index][1].type !== \"linePrefix\" && self.events[index][1].type !== \"content\") {\n paragraph = self.events[index][1].type === \"paragraph\";\n break;\n }\n }\n\n // To do: handle lazy/pierce like `markdown-rs`.\n // To do: parse indent like `markdown-rs`.\n if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) {\n effects.enter(\"setextHeadingLine\");\n marker = code;\n return before(code);\n }\n return nok(code);\n }\n\n /**\n * After optional whitespace, at `-` or `=`.\n *\n * ```markdown\n * | aa\n * > | ==\n * ^\n * ```\n *\n * @type {State}\n */\n function before(code) {\n effects.enter(\"setextHeadingLineSequence\");\n return inside(code);\n }\n\n /**\n * In sequence.\n *\n * ```markdown\n * | aa\n * > | ==\n * ^\n * ```\n *\n * @type {State}\n */\n function inside(code) {\n if (code === marker) {\n effects.consume(code);\n return inside;\n }\n effects.exit(\"setextHeadingLineSequence\");\n return markdownSpace(code) ? factorySpace(effects, after, \"lineSuffix\")(code) : after(code);\n }\n\n /**\n * After sequence, after optional whitespace.\n *\n * ```markdown\n * | aa\n * > | ==\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit(\"setextHeadingLine\");\n return ok(code);\n }\n return nok(code);\n }\n}","/**\n * @import {\n * InitialConstruct,\n * Initializer,\n * State,\n * TokenizeContext\n * } from 'micromark-util-types'\n */\n\nimport { blankLine, content } from 'micromark-core-commonmark';\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding } from 'micromark-util-character';\n/** @type {InitialConstruct} */\nexport const flow = {\n tokenize: initializeFlow\n};\n\n/**\n * @this {TokenizeContext}\n * Self.\n * @type {Initializer}\n * Initializer.\n */\nfunction initializeFlow(effects) {\n const self = this;\n const initial = effects.attempt(\n // Try to parse a blank line.\n blankLine, atBlankEnding,\n // Try to parse initial flow (essentially, only code).\n effects.attempt(this.parser.constructs.flowInitial, afterConstruct, factorySpace(effects, effects.attempt(this.parser.constructs.flow, afterConstruct, effects.attempt(content, afterConstruct)), \"linePrefix\")));\n return initial;\n\n /** @type {State} */\n function atBlankEnding(code) {\n if (code === null) {\n effects.consume(code);\n return;\n }\n effects.enter(\"lineEndingBlank\");\n effects.consume(code);\n effects.exit(\"lineEndingBlank\");\n self.currentConstruct = undefined;\n return initial;\n }\n\n /** @type {State} */\n function afterConstruct(code) {\n if (code === null) {\n effects.consume(code);\n return;\n }\n effects.enter(\"lineEnding\");\n effects.consume(code);\n effects.exit(\"lineEnding\");\n self.currentConstruct = undefined;\n return initial;\n }\n}","/**\n * @import {\n * Code,\n * InitialConstruct,\n * Initializer,\n * Resolver,\n * State,\n * TokenizeContext\n * } from 'micromark-util-types'\n */\n\nexport const resolver = {\n resolveAll: createResolver()\n};\nexport const string = initializeFactory('string');\nexport const text = initializeFactory('text');\n\n/**\n * @param {'string' | 'text'} field\n * Field.\n * @returns {InitialConstruct}\n * Construct.\n */\nfunction initializeFactory(field) {\n return {\n resolveAll: createResolver(field === 'text' ? resolveAllLineSuffixes : undefined),\n tokenize: initializeText\n };\n\n /**\n * @this {TokenizeContext}\n * Context.\n * @type {Initializer}\n */\n function initializeText(effects) {\n const self = this;\n const constructs = this.parser.constructs[field];\n const text = effects.attempt(constructs, start, notText);\n return start;\n\n /** @type {State} */\n function start(code) {\n return atBreak(code) ? text(code) : notText(code);\n }\n\n /** @type {State} */\n function notText(code) {\n if (code === null) {\n effects.consume(code);\n return;\n }\n effects.enter(\"data\");\n effects.consume(code);\n return data;\n }\n\n /** @type {State} */\n function data(code) {\n if (atBreak(code)) {\n effects.exit(\"data\");\n return text(code);\n }\n\n // Data.\n effects.consume(code);\n return data;\n }\n\n /**\n * @param {Code} code\n * Code.\n * @returns {boolean}\n * Whether the code is a break.\n */\n function atBreak(code) {\n if (code === null) {\n return true;\n }\n const list = constructs[code];\n let index = -1;\n if (list) {\n // Always populated by defaults.\n\n while (++index < list.length) {\n const item = list[index];\n if (!item.previous || item.previous.call(self, self.previous)) {\n return true;\n }\n }\n }\n return false;\n }\n }\n}\n\n/**\n * @param {Resolver | undefined} [extraResolver]\n * Resolver.\n * @returns {Resolver}\n * Resolver.\n */\nfunction createResolver(extraResolver) {\n return resolveAllText;\n\n /** @type {Resolver} */\n function resolveAllText(events, context) {\n let index = -1;\n /** @type {number | undefined} */\n let enter;\n\n // A rather boring computation (to merge adjacent `data` events) which\n // improves mm performance by 29%.\n while (++index <= events.length) {\n if (enter === undefined) {\n if (events[index] && events[index][1].type === \"data\") {\n enter = index;\n index++;\n }\n } else if (!events[index] || events[index][1].type !== \"data\") {\n // Don’t do anything if there is one data token.\n if (index !== enter + 2) {\n events[enter][1].end = events[index - 1][1].end;\n events.splice(enter + 2, index - enter - 2);\n index = enter + 2;\n }\n enter = undefined;\n }\n }\n return extraResolver ? extraResolver(events, context) : events;\n }\n}\n\n/**\n * A rather ugly set of instructions which again looks at chunks in the input\n * stream.\n * The reason to do this here is that it is *much* faster to parse in reverse.\n * And that we can’t hook into `null` to split the line suffix before an EOF.\n * To do: figure out if we can make this into a clean utility, or even in core.\n * As it will be useful for GFMs literal autolink extension (and maybe even\n * tables?)\n *\n * @type {Resolver}\n */\nfunction resolveAllLineSuffixes(events, context) {\n let eventIndex = 0; // Skip first.\n\n while (++eventIndex <= events.length) {\n if ((eventIndex === events.length || events[eventIndex][1].type === \"lineEnding\") && events[eventIndex - 1][1].type === \"data\") {\n const data = events[eventIndex - 1][1];\n const chunks = context.sliceStream(data);\n let index = chunks.length;\n let bufferIndex = -1;\n let size = 0;\n /** @type {boolean | undefined} */\n let tabs;\n while (index--) {\n const chunk = chunks[index];\n if (typeof chunk === 'string') {\n bufferIndex = chunk.length;\n while (chunk.charCodeAt(bufferIndex - 1) === 32) {\n size++;\n bufferIndex--;\n }\n if (bufferIndex) break;\n bufferIndex = -1;\n }\n // Number\n else if (chunk === -2) {\n tabs = true;\n size++;\n } else if (chunk === -1) {\n // Empty\n } else {\n // Replacement character, exit.\n index++;\n break;\n }\n }\n\n // Allow final trailing whitespace.\n if (context._contentTypeTextTrailing && eventIndex === events.length) {\n size = 0;\n }\n if (size) {\n const token = {\n type: eventIndex === events.length || tabs || size < 2 ? \"lineSuffix\" : \"hardBreakTrailing\",\n start: {\n _bufferIndex: index ? bufferIndex : data.start._bufferIndex + bufferIndex,\n _index: data.start._index + index,\n line: data.end.line,\n column: data.end.column - size,\n offset: data.end.offset - size\n },\n end: {\n ...data.end\n }\n };\n data.end = {\n ...token.start\n };\n if (data.start.offset === data.end.offset) {\n Object.assign(data, token);\n } else {\n events.splice(eventIndex, 0, ['enter', token, context], ['exit', token, context]);\n eventIndex += 2;\n }\n }\n eventIndex++;\n }\n }\n return events;\n}","/**\n * @import {Extension} from 'micromark-util-types'\n */\n\nimport { attention, autolink, blockQuote, characterEscape, characterReference, codeFenced, codeIndented, codeText, definition, hardBreakEscape, headingAtx, htmlFlow, htmlText, labelEnd, labelStartImage, labelStartLink, lineEnding, list, setextUnderline, thematicBreak } from 'micromark-core-commonmark';\nimport { resolver as resolveText } from './initialize/text.js';\n\n/** @satisfies {Extension['document']} */\nexport const document = {\n [42]: list,\n [43]: list,\n [45]: list,\n [48]: list,\n [49]: list,\n [50]: list,\n [51]: list,\n [52]: list,\n [53]: list,\n [54]: list,\n [55]: list,\n [56]: list,\n [57]: list,\n [62]: blockQuote\n};\n\n/** @satisfies {Extension['contentInitial']} */\nexport const contentInitial = {\n [91]: definition\n};\n\n/** @satisfies {Extension['flowInitial']} */\nexport const flowInitial = {\n [-2]: codeIndented,\n [-1]: codeIndented,\n [32]: codeIndented\n};\n\n/** @satisfies {Extension['flow']} */\nexport const flow = {\n [35]: headingAtx,\n [42]: thematicBreak,\n [45]: [setextUnderline, thematicBreak],\n [60]: htmlFlow,\n [61]: setextUnderline,\n [95]: thematicBreak,\n [96]: codeFenced,\n [126]: codeFenced\n};\n\n/** @satisfies {Extension['string']} */\nexport const string = {\n [38]: characterReference,\n [92]: characterEscape\n};\n\n/** @satisfies {Extension['text']} */\nexport const text = {\n [-5]: lineEnding,\n [-4]: lineEnding,\n [-3]: lineEnding,\n [33]: labelStartImage,\n [38]: characterReference,\n [42]: attention,\n [60]: [autolink, htmlText],\n [91]: labelStartLink,\n [92]: [hardBreakEscape, characterEscape],\n [93]: labelEnd,\n [95]: attention,\n [96]: codeText\n};\n\n/** @satisfies {Extension['insideSpan']} */\nexport const insideSpan = {\n null: [attention, resolveText]\n};\n\n/** @satisfies {Extension['attentionMarkers']} */\nexport const attentionMarkers = {\n null: [42, 95]\n};\n\n/** @satisfies {Extension['disable']} */\nexport const disable = {\n null: []\n};","/**\n * @import {\n * Chunk,\n * Code,\n * ConstructRecord,\n * Construct,\n * Effects,\n * InitialConstruct,\n * ParseContext,\n * Point,\n * State,\n * TokenizeContext,\n * Token\n * } from 'micromark-util-types'\n */\n\n/**\n * @callback Restore\n * Restore the state.\n * @returns {undefined}\n * Nothing.\n *\n * @typedef Info\n * Info.\n * @property {Restore} restore\n * Restore.\n * @property {number} from\n * From.\n *\n * @callback ReturnHandle\n * Handle a successful run.\n * @param {Construct} construct\n * Construct.\n * @param {Info} info\n * Info.\n * @returns {undefined}\n * Nothing.\n */\n\nimport { markdownLineEnding } from 'micromark-util-character';\nimport { push, splice } from 'micromark-util-chunked';\nimport { resolveAll } from 'micromark-util-resolve-all';\n/**\n * Create a tokenizer.\n * Tokenizers deal with one type of data (e.g., containers, flow, text).\n * The parser is the object dealing with it all.\n * `initialize` works like other constructs, except that only its `tokenize`\n * function is used, in which case it doesn’t receive an `ok` or `nok`.\n * `from` can be given to set the point before the first character, although\n * when further lines are indented, they must be set with `defineSkip`.\n *\n * @param {ParseContext} parser\n * Parser.\n * @param {InitialConstruct} initialize\n * Construct.\n * @param {Omit<Point, '_bufferIndex' | '_index'> | undefined} [from]\n * Point (optional).\n * @returns {TokenizeContext}\n * Context.\n */\nexport function createTokenizer(parser, initialize, from) {\n /** @type {Point} */\n let point = {\n _bufferIndex: -1,\n _index: 0,\n line: from && from.line || 1,\n column: from && from.column || 1,\n offset: from && from.offset || 0\n };\n /** @type {Record<string, number>} */\n const columnStart = {};\n /** @type {Array<Construct>} */\n const resolveAllConstructs = [];\n /** @type {Array<Chunk>} */\n let chunks = [];\n /** @type {Array<Token>} */\n let stack = [];\n /** @type {boolean | undefined} */\n let consumed = true;\n\n /**\n * Tools used for tokenizing.\n *\n * @type {Effects}\n */\n const effects = {\n attempt: constructFactory(onsuccessfulconstruct),\n check: constructFactory(onsuccessfulcheck),\n consume,\n enter,\n exit,\n interrupt: constructFactory(onsuccessfulcheck, {\n interrupt: true\n })\n };\n\n /**\n * State and tools for resolving and serializing.\n *\n * @type {TokenizeContext}\n */\n const context = {\n code: null,\n containerState: {},\n defineSkip,\n events: [],\n now,\n parser,\n previous: null,\n sliceSerialize,\n sliceStream,\n write\n };\n\n /**\n * The state function.\n *\n * @type {State | undefined}\n */\n let state = initialize.tokenize.call(context, effects);\n\n /**\n * Track which character we expect to be consumed, to catch bugs.\n *\n * @type {Code}\n */\n let expectedCode;\n if (initialize.resolveAll) {\n resolveAllConstructs.push(initialize);\n }\n return context;\n\n /** @type {TokenizeContext['write']} */\n function write(slice) {\n chunks = push(chunks, slice);\n main();\n\n // Exit if we’re not done, resolve might change stuff.\n if (chunks[chunks.length - 1] !== null) {\n return [];\n }\n addResult(initialize, 0);\n\n // Otherwise, resolve, and exit.\n context.events = resolveAll(resolveAllConstructs, context.events, context);\n return context.events;\n }\n\n //\n // Tools.\n //\n\n /** @type {TokenizeContext['sliceSerialize']} */\n function sliceSerialize(token, expandTabs) {\n return serializeChunks(sliceStream(token), expandTabs);\n }\n\n /** @type {TokenizeContext['sliceStream']} */\n function sliceStream(token) {\n return sliceChunks(chunks, token);\n }\n\n /** @type {TokenizeContext['now']} */\n function now() {\n // This is a hot path, so we clone manually instead of `Object.assign({}, point)`\n const {\n _bufferIndex,\n _index,\n line,\n column,\n offset\n } = point;\n return {\n _bufferIndex,\n _index,\n line,\n column,\n offset\n };\n }\n\n /** @type {TokenizeContext['defineSkip']} */\n function defineSkip(value) {\n columnStart[value.line] = value.column;\n accountForPotentialSkip();\n }\n\n //\n // State management.\n //\n\n /**\n * Main loop (note that `_index` and `_bufferIndex` in `point` are modified by\n * `consume`).\n * Here is where we walk through the chunks, which either include strings of\n * several characters, or numerical character codes.\n * The reason to do this in a loop instead of a call is so the stack can\n * drain.\n *\n * @returns {undefined}\n * Nothing.\n */\n function main() {\n /** @type {number} */\n let chunkIndex;\n while (point._index < chunks.length) {\n const chunk = chunks[point._index];\n\n // If we’re in a buffer chunk, loop through it.\n if (typeof chunk === 'string') {\n chunkIndex = point._index;\n if (point._bufferIndex < 0) {\n point._bufferIndex = 0;\n }\n while (point._index === chunkIndex && point._bufferIndex < chunk.length) {\n go(chunk.charCodeAt(point._bufferIndex));\n }\n } else {\n go(chunk);\n }\n }\n }\n\n /**\n * Deal with one code.\n *\n * @param {Code} code\n * Code.\n * @returns {undefined}\n * Nothing.\n */\n function go(code) {\n consumed = undefined;\n expectedCode = code;\n state = state(code);\n }\n\n /** @type {Effects['consume']} */\n function consume(code) {\n if (markdownLineEnding(code)) {\n point.line++;\n point.column = 1;\n point.offset += code === -3 ? 2 : 1;\n accountForPotentialSkip();\n } else if (code !== -1) {\n point.column++;\n point.offset++;\n }\n\n // Not in a string chunk.\n if (point._bufferIndex < 0) {\n point._index++;\n } else {\n point._bufferIndex++;\n\n // At end of string chunk.\n if (point._bufferIndex ===\n // Points w/ non-negative `_bufferIndex` reference\n // strings.\n /** @type {string} */\n chunks[point._index].length) {\n point._bufferIndex = -1;\n point._index++;\n }\n }\n\n // Expose the previous character.\n context.previous = code;\n\n // Mark as consumed.\n consumed = true;\n }\n\n /** @type {Effects['enter']} */\n function enter(type, fields) {\n /** @type {Token} */\n // @ts-expect-error Patch instead of assign required fields to help GC.\n const token = fields || {};\n token.type = type;\n token.start = now();\n context.events.push(['enter', token, context]);\n stack.push(token);\n return token;\n }\n\n /** @type {Effects['exit']} */\n function exit(type) {\n const token = stack.pop();\n token.end = now();\n context.events.push(['exit', token, context]);\n return token;\n }\n\n /**\n * Use results.\n *\n * @type {ReturnHandle}\n */\n function onsuccessfulconstruct(construct, info) {\n addResult(construct, info.from);\n }\n\n /**\n * Discard results.\n *\n * @type {ReturnHandle}\n */\n function onsuccessfulcheck(_, info) {\n info.restore();\n }\n\n /**\n * Factory to attempt/check/interrupt.\n *\n * @param {ReturnHandle} onreturn\n * Callback.\n * @param {{interrupt?: boolean | undefined} | undefined} [fields]\n * Fields.\n */\n function constructFactory(onreturn, fields) {\n return hook;\n\n /**\n * Handle either an object mapping codes to constructs, a list of\n * constructs, or a single construct.\n *\n * @param {Array<Construct> | ConstructRecord | Construct} constructs\n * Constructs.\n * @param {State} returnState\n * State.\n * @param {State | undefined} [bogusState]\n * State.\n * @returns {State}\n * State.\n */\n function hook(constructs, returnState, bogusState) {\n /** @type {ReadonlyArray<Construct>} */\n let listOfConstructs;\n /** @type {number} */\n let constructIndex;\n /** @type {Construct} */\n let currentConstruct;\n /** @type {Info} */\n let info;\n return Array.isArray(constructs) ? /* c8 ignore next 1 */\n handleListOfConstructs(constructs) : 'tokenize' in constructs ?\n // Looks like a construct.\n handleListOfConstructs([(/** @type {Construct} */constructs)]) : handleMapOfConstructs(constructs);\n\n /**\n * Handle a list of construct.\n *\n * @param {ConstructRecord} map\n * Constructs.\n * @returns {State}\n * State.\n */\n function handleMapOfConstructs(map) {\n return start;\n\n /** @type {State} */\n function start(code) {\n const left = code !== null && map[code];\n const all = code !== null && map.null;\n const list = [\n // To do: add more extension tests.\n /* c8 ignore next 2 */\n ...(Array.isArray(left) ? left : left ? [left] : []), ...(Array.isArray(all) ? all : all ? [all] : [])];\n return handleListOfConstructs(list)(code);\n }\n }\n\n /**\n * Handle a list of construct.\n *\n * @param {ReadonlyArray<Construct>} list\n * Constructs.\n * @returns {State}\n * State.\n */\n function handleListOfConstructs(list) {\n listOfConstructs = list;\n constructIndex = 0;\n if (list.length === 0) {\n return bogusState;\n }\n return handleConstruct(list[constructIndex]);\n }\n\n /**\n * Handle a single construct.\n *\n * @param {Construct} construct\n * Construct.\n * @returns {State}\n * State.\n */\n function handleConstruct(construct) {\n return start;\n\n /** @type {State} */\n function start(code) {\n // To do: not needed to store if there is no bogus state, probably?\n // Currently doesn’t work because `inspect` in document does a check\n // w/o a bogus, which doesn’t make sense. But it does seem to help perf\n // by not storing.\n info = store();\n currentConstruct = construct;\n if (!construct.partial) {\n context.currentConstruct = construct;\n }\n\n // Always populated by defaults.\n\n if (construct.name && context.parser.constructs.disable.null.includes(construct.name)) {\n return nok(code);\n }\n return construct.tokenize.call(\n // If we do have fields, create an object w/ `context` as its\n // prototype.\n // This allows a “live binding”, which is needed for `interrupt`.\n fields ? Object.assign(Object.create(context), fields) : context, effects, ok, nok)(code);\n }\n }\n\n /** @type {State} */\n function ok(code) {\n consumed = true;\n onreturn(currentConstruct, info);\n return returnState;\n }\n\n /** @type {State} */\n function nok(code) {\n consumed = true;\n info.restore();\n if (++constructIndex < listOfConstructs.length) {\n return handleConstruct(listOfConstructs[constructIndex]);\n }\n return bogusState;\n }\n }\n }\n\n /**\n * @param {Construct} construct\n * Construct.\n * @param {number} from\n * From.\n * @returns {undefined}\n * Nothing.\n */\n function addResult(construct, from) {\n if (construct.resolveAll && !resolveAllConstructs.includes(construct)) {\n resolveAllConstructs.push(construct);\n }\n if (construct.resolve) {\n splice(context.events, from, context.events.length - from, construct.resolve(context.events.slice(from), context));\n }\n if (construct.resolveTo) {\n context.events = construct.resolveTo(context.events, context);\n }\n }\n\n /**\n * Store state.\n *\n * @returns {Info}\n * Info.\n */\n function store() {\n const startPoint = now();\n const startPrevious = context.previous;\n const startCurrentConstruct = context.currentConstruct;\n const startEventsIndex = context.events.length;\n const startStack = Array.from(stack);\n return {\n from: startEventsIndex,\n restore\n };\n\n /**\n * Restore state.\n *\n * @returns {undefined}\n * Nothing.\n */\n function restore() {\n point = startPoint;\n context.previous = startPrevious;\n context.currentConstruct = startCurrentConstruct;\n context.events.length = startEventsIndex;\n stack = startStack;\n accountForPotentialSkip();\n }\n }\n\n /**\n * Move the current point a bit forward in the line when it’s on a column\n * skip.\n *\n * @returns {undefined}\n * Nothing.\n */\n function accountForPotentialSkip() {\n if (point.line in columnStart && point.column < 2) {\n point.column = columnStart[point.line];\n point.offset += columnStart[point.line] - 1;\n }\n }\n}\n\n/**\n * Get the chunks from a slice of chunks in the range of a token.\n *\n * @param {ReadonlyArray<Chunk>} chunks\n * Chunks.\n * @param {Pick<Token, 'end' | 'start'>} token\n * Token.\n * @returns {Array<Chunk>}\n * Chunks.\n */\nfunction sliceChunks(chunks, token) {\n const startIndex = token.start._index;\n const startBufferIndex = token.start._bufferIndex;\n const endIndex = token.end._index;\n const endBufferIndex = token.end._bufferIndex;\n /** @type {Array<Chunk>} */\n let view;\n if (startIndex === endIndex) {\n // @ts-expect-error `_bufferIndex` is used on string chunks.\n view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)];\n } else {\n view = chunks.slice(startIndex, endIndex);\n if (startBufferIndex > -1) {\n const head = view[0];\n if (typeof head === 'string') {\n view[0] = head.slice(startBufferIndex);\n /* c8 ignore next 4 -- used to be used, no longer */\n } else {\n view.shift();\n }\n }\n if (endBufferIndex > 0) {\n // @ts-expect-error `_bufferIndex` is used on string chunks.\n view.push(chunks[endIndex].slice(0, endBufferIndex));\n }\n }\n return view;\n}\n\n/**\n * Get the string value of a slice of chunks.\n *\n * @param {ReadonlyArray<Chunk>} chunks\n * Chunks.\n * @param {boolean | undefined} [expandTabs=false]\n * Whether to expand tabs (default: `false`).\n * @returns {string}\n * Result.\n */\nfunction serializeChunks(chunks, expandTabs) {\n let index = -1;\n /** @type {Array<string>} */\n const result = [];\n /** @type {boolean | undefined} */\n let atTab;\n while (++index < chunks.length) {\n const chunk = chunks[index];\n /** @type {string} */\n let value;\n if (typeof chunk === 'string') {\n value = chunk;\n } else switch (chunk) {\n case -5:\n {\n value = \"\\r\";\n break;\n }\n case -4:\n {\n value = \"\\n\";\n break;\n }\n case -3:\n {\n value = \"\\r\" + \"\\n\";\n break;\n }\n case -2:\n {\n value = expandTabs ? \" \" : \"\\t\";\n break;\n }\n case -1:\n {\n if (!expandTabs && atTab) continue;\n value = \" \";\n break;\n }\n default:\n {\n // Currently only replacement character.\n value = String.fromCharCode(chunk);\n }\n }\n atTab = chunk === -2;\n result.push(value);\n }\n return result.join('');\n}","/**\n * @import {\n * Create,\n * FullNormalizedExtension,\n * InitialConstruct,\n * ParseContext,\n * ParseOptions\n * } from 'micromark-util-types'\n */\n\nimport { combineExtensions } from 'micromark-util-combine-extensions';\nimport { content } from './initialize/content.js';\nimport { document } from './initialize/document.js';\nimport { flow } from './initialize/flow.js';\nimport { string, text } from './initialize/text.js';\nimport * as defaultConstructs from './constructs.js';\nimport { createTokenizer } from './create-tokenizer.js';\n\n/**\n * @param {ParseOptions | null | undefined} [options]\n * Configuration (optional).\n * @returns {ParseContext}\n * Parser.\n */\nexport function parse(options) {\n const settings = options || {};\n const constructs = /** @type {FullNormalizedExtension} */\n combineExtensions([defaultConstructs, ...(settings.extensions || [])]);\n\n /** @type {ParseContext} */\n const parser = {\n constructs,\n content: create(content),\n defined: [],\n document: create(document),\n flow: create(flow),\n lazy: {},\n string: create(string),\n text: create(text)\n };\n return parser;\n\n /**\n * @param {InitialConstruct} initial\n * Construct to start with.\n * @returns {Create}\n * Create a tokenizer.\n */\n function create(initial) {\n return creator;\n /** @type {Create} */\n function creator(from) {\n return createTokenizer(parser, initial, from);\n }\n }\n}","/**\n * @import {Event} from 'micromark-util-types'\n */\n\nimport { subtokenize } from 'micromark-util-subtokenize';\n\n/**\n * @param {Array<Event>} events\n * Events.\n * @returns {Array<Event>}\n * Events.\n */\nexport function postprocess(events) {\n while (!subtokenize(events)) {\n // Empty\n }\n return events;\n}","/**\n * @import {Chunk, Code, Encoding, Value} from 'micromark-util-types'\n */\n\n/**\n * @callback Preprocessor\n * Preprocess a value.\n * @param {Value} value\n * Value.\n * @param {Encoding | null | undefined} [encoding]\n * Encoding when `value` is a typed array (optional).\n * @param {boolean | null | undefined} [end=false]\n * Whether this is the last chunk (default: `false`).\n * @returns {Array<Chunk>}\n * Chunks.\n */\n\nconst search = /[\\0\\t\\n\\r]/g;\n\n/**\n * @returns {Preprocessor}\n * Preprocess a value.\n */\nexport function preprocess() {\n let column = 1;\n let buffer = '';\n /** @type {boolean | undefined} */\n let start = true;\n /** @type {boolean | undefined} */\n let atCarriageReturn;\n return preprocessor;\n\n /** @type {Preprocessor} */\n // eslint-disable-next-line complexity\n function preprocessor(value, encoding, end) {\n /** @type {Array<Chunk>} */\n const chunks = [];\n /** @type {RegExpMatchArray | null} */\n let match;\n /** @type {number} */\n let next;\n /** @type {number} */\n let startPosition;\n /** @type {number} */\n let endPosition;\n /** @type {Code} */\n let code;\n value = buffer + (typeof value === 'string' ? value.toString() : new TextDecoder(encoding || undefined).decode(value));\n startPosition = 0;\n buffer = '';\n if (start) {\n // To do: `markdown-rs` actually parses BOMs (byte order mark).\n if (value.charCodeAt(0) === 65279) {\n startPosition++;\n }\n start = undefined;\n }\n while (startPosition < value.length) {\n search.lastIndex = startPosition;\n match = search.exec(value);\n endPosition = match && match.index !== undefined ? match.index : value.length;\n code = value.charCodeAt(endPosition);\n if (!match) {\n buffer = value.slice(startPosition);\n break;\n }\n if (code === 10 && startPosition === endPosition && atCarriageReturn) {\n chunks.push(-3);\n atCarriageReturn = undefined;\n } else {\n if (atCarriageReturn) {\n chunks.push(-5);\n atCarriageReturn = undefined;\n }\n if (startPosition < endPosition) {\n chunks.push(value.slice(startPosition, endPosition));\n column += endPosition - startPosition;\n }\n switch (code) {\n case 0:\n {\n chunks.push(65533);\n column++;\n break;\n }\n case 9:\n {\n next = Math.ceil(column / 4) * 4;\n chunks.push(-2);\n while (column++ < next) chunks.push(-1);\n break;\n }\n case 10:\n {\n chunks.push(-4);\n column = 1;\n break;\n }\n default:\n {\n atCarriageReturn = true;\n column = 1;\n }\n }\n }\n startPosition = endPosition + 1;\n }\n if (end) {\n if (atCarriageReturn) chunks.push(-5);\n if (buffer) chunks.push(buffer);\n chunks.push(null);\n }\n return chunks;\n }\n}","/**\n * @import {Encoding, Value} from 'micromark-util-types'\n */\n\n/**\n * @typedef {import('micromark-util-types').Options} Options\n */\n\nimport { compile } from './lib/compile.js';\nimport { parse } from './lib/parse.js';\nimport { postprocess } from './lib/postprocess.js';\nimport { preprocess } from './lib/preprocess.js';\nexport { compile } from './lib/compile.js';\nexport { parse } from './lib/parse.js';\nexport { postprocess } from './lib/postprocess.js';\nexport { preprocess } from './lib/preprocess.js';\n\n/**\n * Compile markdown to HTML.\n *\n * > Note: which encodings are supported depends on the engine.\n * > For info on Node.js, see:\n * > <https://nodejs.org/api/util.html#whatwg-supported-encodings>.\n *\n * @overload\n * @param {Value} value\n * Markdown to parse (`string` or `Uint8Array`).\n * @param {Encoding | null | undefined} encoding\n * Character encoding to understand `value` as when it’s a `Uint8Array`\n * (`string`, default: `'utf8'`).\n * @param {Options | null | undefined} [options]\n * Configuration.\n * @returns {string}\n * Compiled HTML.\n *\n * @overload\n * @param {Value} value\n * Markdown to parse (`string` or `Uint8Array`).\n * @param {Options | null | undefined} [options]\n * Configuration.\n * @returns {string}\n * Compiled HTML.\n *\n * @param {Value} value\n * Markdown to parse (`string` or `Uint8Array`).\n * @param {Encoding | Options | null | undefined} [encoding]\n * Character encoding to understand `value` as when it’s a `Uint8Array`\n * (`string`, default: `'utf8'`).\n * @param {Options | null | undefined} [options]\n * Configuration.\n * @returns {string}\n * Compiled HTML.\n */\nexport function micromark(value, encoding, options) {\n if (typeof encoding !== 'string') {\n options = encoding;\n encoding = undefined;\n }\n return compile(options)(postprocess(parse(options).document().write(preprocess()(value, encoding, true))));\n}","/**\n * @import {Options} from 'micromark-extension-gfm-strikethrough'\n * @import {Event, Extension, Resolver, State, Token, TokenizeContext, Tokenizer} from 'micromark-util-types'\n */\n\nimport { splice } from 'micromark-util-chunked';\nimport { classifyCharacter } from 'micromark-util-classify-character';\nimport { resolveAll } from 'micromark-util-resolve-all';\n/**\n * Create an extension for `micromark` to enable GFM strikethrough syntax.\n *\n * @param {Options | null | undefined} [options={}]\n * Configuration.\n * @returns {Extension}\n * Extension for `micromark` that can be passed in `extensions`, to\n * enable GFM strikethrough syntax.\n */\nexport function gfmStrikethrough(options) {\n const options_ = options || {};\n let single = options_.singleTilde;\n const tokenizer = {\n name: 'strikethrough',\n tokenize: tokenizeStrikethrough,\n resolveAll: resolveAllStrikethrough\n };\n if (single === null || single === undefined) {\n single = true;\n }\n return {\n text: {\n [126]: tokenizer\n },\n insideSpan: {\n null: [tokenizer]\n },\n attentionMarkers: {\n null: [126]\n }\n };\n\n /**\n * Take events and resolve strikethrough.\n *\n * @type {Resolver}\n */\n function resolveAllStrikethrough(events, context) {\n let index = -1;\n\n // Walk through all events.\n while (++index < events.length) {\n // Find a token that can close.\n if (events[index][0] === 'enter' && events[index][1].type === 'strikethroughSequenceTemporary' && events[index][1]._close) {\n let open = index;\n\n // Now walk back to find an opener.\n while (open--) {\n // Find a token that can open the closer.\n if (events[open][0] === 'exit' && events[open][1].type === 'strikethroughSequenceTemporary' && events[open][1]._open &&\n // If the sizes are the same:\n events[index][1].end.offset - events[index][1].start.offset === events[open][1].end.offset - events[open][1].start.offset) {\n events[index][1].type = 'strikethroughSequence';\n events[open][1].type = 'strikethroughSequence';\n\n /** @type {Token} */\n const strikethrough = {\n type: 'strikethrough',\n start: Object.assign({}, events[open][1].start),\n end: Object.assign({}, events[index][1].end)\n };\n\n /** @type {Token} */\n const text = {\n type: 'strikethroughText',\n start: Object.assign({}, events[open][1].end),\n end: Object.assign({}, events[index][1].start)\n };\n\n // Opening.\n /** @type {Array<Event>} */\n const nextEvents = [['enter', strikethrough, context], ['enter', events[open][1], context], ['exit', events[open][1], context], ['enter', text, context]];\n const insideSpan = context.parser.constructs.insideSpan.null;\n if (insideSpan) {\n // Between.\n splice(nextEvents, nextEvents.length, 0, resolveAll(insideSpan, events.slice(open + 1, index), context));\n }\n\n // Closing.\n splice(nextEvents, nextEvents.length, 0, [['exit', text, context], ['enter', events[index][1], context], ['exit', events[index][1], context], ['exit', strikethrough, context]]);\n splice(events, open - 1, index - open + 3, nextEvents);\n index = open + nextEvents.length - 2;\n break;\n }\n }\n }\n }\n index = -1;\n while (++index < events.length) {\n if (events[index][1].type === 'strikethroughSequenceTemporary') {\n events[index][1].type = \"data\";\n }\n }\n return events;\n }\n\n /**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\n function tokenizeStrikethrough(effects, ok, nok) {\n const previous = this.previous;\n const events = this.events;\n let size = 0;\n return start;\n\n /** @type {State} */\n function start(code) {\n if (previous === 126 && events[events.length - 1][1].type !== \"characterEscape\") {\n return nok(code);\n }\n effects.enter('strikethroughSequenceTemporary');\n return more(code);\n }\n\n /** @type {State} */\n function more(code) {\n const before = classifyCharacter(previous);\n if (code === 126) {\n // If this is the third marker, exit.\n if (size > 1) return nok(code);\n effects.consume(code);\n size++;\n return more;\n }\n if (size < 2 && !single) return nok(code);\n const token = effects.exit('strikethroughSequenceTemporary');\n const after = classifyCharacter(code);\n token._open = !after || after === 2 && Boolean(before);\n token._close = !before || before === 2 && Boolean(after);\n return ok(code);\n }\n }\n}","function extend(destination) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) destination[key] = source[key];\n }\n }\n return destination;\n}\nfunction repeat(character, count) {\n return Array(count + 1).join(character);\n}\nfunction trimLeadingNewlines(string) {\n return string.replace(/^\\n*/, '');\n}\nfunction trimTrailingNewlines(string) {\n // avoid match-at-end regexp bottleneck, see #370\n var indexEnd = string.length;\n while (indexEnd > 0 && string[indexEnd - 1] === '\\n') indexEnd--;\n return string.substring(0, indexEnd);\n}\nfunction trimNewlines(string) {\n return trimTrailingNewlines(trimLeadingNewlines(string));\n}\nvar blockElements = ['ADDRESS', 'ARTICLE', 'ASIDE', 'AUDIO', 'BLOCKQUOTE', 'BODY', 'CANVAS', 'CENTER', 'DD', 'DIR', 'DIV', 'DL', 'DT', 'FIELDSET', 'FIGCAPTION', 'FIGURE', 'FOOTER', 'FORM', 'FRAMESET', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'HEADER', 'HGROUP', 'HR', 'HTML', 'ISINDEX', 'LI', 'MAIN', 'MENU', 'NAV', 'NOFRAMES', 'NOSCRIPT', 'OL', 'OUTPUT', 'P', 'PRE', 'SECTION', 'TABLE', 'TBODY', 'TD', 'TFOOT', 'TH', 'THEAD', 'TR', 'UL'];\nfunction isBlock(node) {\n return is(node, blockElements);\n}\nvar voidElements = ['AREA', 'BASE', 'BR', 'COL', 'COMMAND', 'EMBED', 'HR', 'IMG', 'INPUT', 'KEYGEN', 'LINK', 'META', 'PARAM', 'SOURCE', 'TRACK', 'WBR'];\nfunction isVoid(node) {\n return is(node, voidElements);\n}\nfunction hasVoid(node) {\n return has(node, voidElements);\n}\nvar meaningfulWhenBlankElements = ['A', 'TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TH', 'TD', 'IFRAME', 'SCRIPT', 'AUDIO', 'VIDEO'];\nfunction isMeaningfulWhenBlank(node) {\n return is(node, meaningfulWhenBlankElements);\n}\nfunction hasMeaningfulWhenBlank(node) {\n return has(node, meaningfulWhenBlankElements);\n}\nfunction is(node, tagNames) {\n return tagNames.indexOf(node.nodeName) >= 0;\n}\nfunction has(node, tagNames) {\n return node.getElementsByTagName && tagNames.some(function (tagName) {\n return node.getElementsByTagName(tagName).length;\n });\n}\nvar markdownEscapes = [[/\\\\/g, '\\\\\\\\'], [/\\*/g, '\\\\*'], [/^-/g, '\\\\-'], [/^\\+ /g, '\\\\+ '], [/^(=+)/g, '\\\\$1'], [/^(#{1,6}) /g, '\\\\$1 '], [/`/g, '\\\\`'], [/^~~~/g, '\\\\~~~'], [/\\[/g, '\\\\['], [/\\]/g, '\\\\]'], [/^>/g, '\\\\>'], [/_/g, '\\\\_'], [/^(\\d+)\\. /g, '$1\\\\. ']];\nfunction escapeMarkdown(string) {\n return markdownEscapes.reduce(function (accumulator, escape) {\n return accumulator.replace(escape[0], escape[1]);\n }, string);\n}\n\nvar rules = {};\nrules.paragraph = {\n filter: 'p',\n replacement: function (content) {\n return '\\n\\n' + content + '\\n\\n';\n }\n};\nrules.lineBreak = {\n filter: 'br',\n replacement: function (content, node, options) {\n return options.br + '\\n';\n }\n};\nrules.heading = {\n filter: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],\n replacement: function (content, node, options) {\n var hLevel = Number(node.nodeName.charAt(1));\n if (options.headingStyle === 'setext' && hLevel < 3) {\n var underline = repeat(hLevel === 1 ? '=' : '-', content.length);\n return '\\n\\n' + content + '\\n' + underline + '\\n\\n';\n } else {\n return '\\n\\n' + repeat('#', hLevel) + ' ' + content + '\\n\\n';\n }\n }\n};\nrules.blockquote = {\n filter: 'blockquote',\n replacement: function (content) {\n content = trimNewlines(content).replace(/^/gm, '> ');\n return '\\n\\n' + content + '\\n\\n';\n }\n};\nrules.list = {\n filter: ['ul', 'ol'],\n replacement: function (content, node) {\n var parent = node.parentNode;\n if (parent.nodeName === 'LI' && parent.lastElementChild === node) {\n return '\\n' + content;\n } else {\n return '\\n\\n' + content + '\\n\\n';\n }\n }\n};\nrules.listItem = {\n filter: 'li',\n replacement: function (content, node, options) {\n var prefix = options.bulletListMarker + ' ';\n var parent = node.parentNode;\n if (parent.nodeName === 'OL') {\n var start = parent.getAttribute('start');\n var index = Array.prototype.indexOf.call(parent.children, node);\n prefix = (start ? Number(start) + index : index + 1) + '. ';\n }\n var isParagraph = /\\n$/.test(content);\n content = trimNewlines(content) + (isParagraph ? '\\n' : '');\n content = content.replace(/\\n/gm, '\\n' + ' '.repeat(prefix.length)); // indent\n return prefix + content + (node.nextSibling ? '\\n' : '');\n }\n};\nrules.indentedCodeBlock = {\n filter: function (node, options) {\n return options.codeBlockStyle === 'indented' && node.nodeName === 'PRE' && node.firstChild && node.firstChild.nodeName === 'CODE';\n },\n replacement: function (content, node, options) {\n return '\\n\\n ' + node.firstChild.textContent.replace(/\\n/g, '\\n ') + '\\n\\n';\n }\n};\nrules.fencedCodeBlock = {\n filter: function (node, options) {\n return options.codeBlockStyle === 'fenced' && node.nodeName === 'PRE' && node.firstChild && node.firstChild.nodeName === 'CODE';\n },\n replacement: function (content, node, options) {\n var className = node.firstChild.getAttribute('class') || '';\n var language = (className.match(/language-(\\S+)/) || [null, ''])[1];\n var code = node.firstChild.textContent;\n var fenceChar = options.fence.charAt(0);\n var fenceSize = 3;\n var fenceInCodeRegex = new RegExp('^' + fenceChar + '{3,}', 'gm');\n var match;\n while (match = fenceInCodeRegex.exec(code)) {\n if (match[0].length >= fenceSize) {\n fenceSize = match[0].length + 1;\n }\n }\n var fence = repeat(fenceChar, fenceSize);\n return '\\n\\n' + fence + language + '\\n' + code.replace(/\\n$/, '') + '\\n' + fence + '\\n\\n';\n }\n};\nrules.horizontalRule = {\n filter: 'hr',\n replacement: function (content, node, options) {\n return '\\n\\n' + options.hr + '\\n\\n';\n }\n};\nrules.inlineLink = {\n filter: function (node, options) {\n return options.linkStyle === 'inlined' && node.nodeName === 'A' && node.getAttribute('href');\n },\n replacement: function (content, node) {\n var href = escapeLinkDestination(node.getAttribute('href'));\n var title = escapeLinkTitle(cleanAttribute(node.getAttribute('title')));\n var titlePart = title ? ' \"' + title + '\"' : '';\n return '[' + content + '](' + href + titlePart + ')';\n }\n};\nrules.referenceLink = {\n filter: function (node, options) {\n return options.linkStyle === 'referenced' && node.nodeName === 'A' && node.getAttribute('href');\n },\n replacement: function (content, node, options) {\n var href = escapeLinkDestination(node.getAttribute('href'));\n var title = cleanAttribute(node.getAttribute('title'));\n if (title) title = ' \"' + escapeLinkTitle(title) + '\"';\n var replacement;\n var reference;\n switch (options.linkReferenceStyle) {\n case 'collapsed':\n replacement = '[' + content + '][]';\n reference = '[' + content + ']: ' + href + title;\n break;\n case 'shortcut':\n replacement = '[' + content + ']';\n reference = '[' + content + ']: ' + href + title;\n break;\n default:\n var id = this.references.length + 1;\n replacement = '[' + content + '][' + id + ']';\n reference = '[' + id + ']: ' + href + title;\n }\n this.references.push(reference);\n return replacement;\n },\n references: [],\n append: function (options) {\n var references = '';\n if (this.references.length) {\n references = '\\n\\n' + this.references.join('\\n') + '\\n\\n';\n this.references = []; // Reset references\n }\n return references;\n }\n};\nrules.emphasis = {\n filter: ['em', 'i'],\n replacement: function (content, node, options) {\n if (!content.trim()) return '';\n return options.emDelimiter + content + options.emDelimiter;\n }\n};\nrules.strong = {\n filter: ['strong', 'b'],\n replacement: function (content, node, options) {\n if (!content.trim()) return '';\n return options.strongDelimiter + content + options.strongDelimiter;\n }\n};\nrules.code = {\n filter: function (node) {\n var hasSiblings = node.previousSibling || node.nextSibling;\n var isCodeBlock = node.parentNode.nodeName === 'PRE' && !hasSiblings;\n return node.nodeName === 'CODE' && !isCodeBlock;\n },\n replacement: function (content) {\n if (!content) return '';\n content = content.replace(/\\r?\\n|\\r/g, ' ');\n var extraSpace = /^`|^ .*?[^ ].* $|`$/.test(content) ? ' ' : '';\n var delimiter = '`';\n var matches = content.match(/`+/gm) || [];\n while (matches.indexOf(delimiter) !== -1) delimiter = delimiter + '`';\n return delimiter + extraSpace + content + extraSpace + delimiter;\n }\n};\nrules.image = {\n filter: 'img',\n replacement: function (content, node) {\n var alt = escapeMarkdown(cleanAttribute(node.getAttribute('alt')));\n var src = escapeLinkDestination(node.getAttribute('src') || '');\n var title = cleanAttribute(node.getAttribute('title'));\n var titlePart = title ? ' \"' + escapeLinkTitle(title) + '\"' : '';\n return src ? '![' + alt + ']' + '(' + src + titlePart + ')' : '';\n }\n};\nfunction cleanAttribute(attribute) {\n return attribute ? attribute.replace(/(\\n+\\s*)+/g, '\\n') : '';\n}\nfunction escapeLinkDestination(destination) {\n var escaped = destination.replace(/([<>()])/g, '\\\\$1');\n return escaped.indexOf(' ') >= 0 ? '<' + escaped + '>' : escaped;\n}\nfunction escapeLinkTitle(title) {\n return title.replace(/\"/g, '\\\\\"');\n}\n\n/**\n * Manages a collection of rules used to convert HTML to Markdown\n */\n\nfunction Rules(options) {\n this.options = options;\n this._keep = [];\n this._remove = [];\n this.blankRule = {\n replacement: options.blankReplacement\n };\n this.keepReplacement = options.keepReplacement;\n this.defaultRule = {\n replacement: options.defaultReplacement\n };\n this.array = [];\n for (var key in options.rules) this.array.push(options.rules[key]);\n}\nRules.prototype = {\n add: function (key, rule) {\n this.array.unshift(rule);\n },\n keep: function (filter) {\n this._keep.unshift({\n filter: filter,\n replacement: this.keepReplacement\n });\n },\n remove: function (filter) {\n this._remove.unshift({\n filter: filter,\n replacement: function () {\n return '';\n }\n });\n },\n forNode: function (node) {\n if (node.isBlank) return this.blankRule;\n var rule;\n if (rule = findRule(this.array, node, this.options)) return rule;\n if (rule = findRule(this._keep, node, this.options)) return rule;\n if (rule = findRule(this._remove, node, this.options)) return rule;\n return this.defaultRule;\n },\n forEach: function (fn) {\n for (var i = 0; i < this.array.length; i++) fn(this.array[i], i);\n }\n};\nfunction findRule(rules, node, options) {\n for (var i = 0; i < rules.length; i++) {\n var rule = rules[i];\n if (filterValue(rule, node, options)) return rule;\n }\n return undefined;\n}\nfunction filterValue(rule, node, options) {\n var filter = rule.filter;\n if (typeof filter === 'string') {\n if (filter === node.nodeName.toLowerCase()) return true;\n } else if (Array.isArray(filter)) {\n if (filter.indexOf(node.nodeName.toLowerCase()) > -1) return true;\n } else if (typeof filter === 'function') {\n if (filter.call(rule, node, options)) return true;\n } else {\n throw new TypeError('`filter` needs to be a string, array, or function');\n }\n}\n\n/**\n * The collapseWhitespace function is adapted from collapse-whitespace\n * by Luc Thevenard.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2014 Luc Thevenard <lucthevenard@gmail.com>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n/**\n * collapseWhitespace(options) removes extraneous whitespace from an the given element.\n *\n * @param {Object} options\n */\nfunction collapseWhitespace(options) {\n var element = options.element;\n var isBlock = options.isBlock;\n var isVoid = options.isVoid;\n var isPre = options.isPre || function (node) {\n return node.nodeName === 'PRE';\n };\n if (!element.firstChild || isPre(element)) return;\n var prevText = null;\n var keepLeadingWs = false;\n var prev = null;\n var node = next(prev, element, isPre);\n while (node !== element) {\n if (node.nodeType === 3 || node.nodeType === 4) {\n // Node.TEXT_NODE or Node.CDATA_SECTION_NODE\n var text = node.data.replace(/[ \\r\\n\\t]+/g, ' ');\n if ((!prevText || / $/.test(prevText.data)) && !keepLeadingWs && text[0] === ' ') {\n text = text.substr(1);\n }\n\n // `text` might be empty at this point.\n if (!text) {\n node = remove(node);\n continue;\n }\n node.data = text;\n prevText = node;\n } else if (node.nodeType === 1) {\n // Node.ELEMENT_NODE\n if (isBlock(node) || node.nodeName === 'BR') {\n if (prevText) {\n prevText.data = prevText.data.replace(/ $/, '');\n }\n prevText = null;\n keepLeadingWs = false;\n } else if (isVoid(node) || isPre(node)) {\n // Avoid trimming space around non-block, non-BR void elements and inline PRE.\n prevText = null;\n keepLeadingWs = true;\n } else if (prevText) {\n // Drop protection if set previously.\n keepLeadingWs = false;\n }\n } else {\n node = remove(node);\n continue;\n }\n var nextNode = next(prev, node, isPre);\n prev = node;\n node = nextNode;\n }\n if (prevText) {\n prevText.data = prevText.data.replace(/ $/, '');\n if (!prevText.data) {\n remove(prevText);\n }\n }\n}\n\n/**\n * remove(node) removes the given node from the DOM and returns the\n * next node in the sequence.\n *\n * @param {Node} node\n * @return {Node} node\n */\nfunction remove(node) {\n var next = node.nextSibling || node.parentNode;\n node.parentNode.removeChild(node);\n return next;\n}\n\n/**\n * next(prev, current, isPre) returns the next node in the sequence, given the\n * current and previous nodes.\n *\n * @param {Node} prev\n * @param {Node} current\n * @param {Function} isPre\n * @return {Node}\n */\nfunction next(prev, current, isPre) {\n if (prev && prev.parentNode === current || isPre(current)) {\n return current.nextSibling || current.parentNode;\n }\n return current.firstChild || current.nextSibling || current.parentNode;\n}\n\n/*\n * Set up window for Node.js\n */\n\nvar root = typeof window !== 'undefined' ? window : {};\n\n/*\n * Parsing HTML strings\n */\n\nfunction canParseHTMLNatively() {\n var Parser = root.DOMParser;\n var canParse = false;\n\n // Adapted from https://gist.github.com/1129031\n // Firefox/Opera/IE throw errors on unsupported types\n try {\n // WebKit returns null on unsupported types\n if (new Parser().parseFromString('', 'text/html')) {\n canParse = true;\n }\n } catch (e) {}\n return canParse;\n}\nfunction createHTMLParser() {\n var Parser = function () {};\n {\n if (shouldUseActiveX()) {\n Parser.prototype.parseFromString = function (string) {\n var doc = new window.ActiveXObject('htmlfile');\n doc.designMode = 'on'; // disable on-page scripts\n doc.open();\n doc.write(string);\n doc.close();\n return doc;\n };\n } else {\n Parser.prototype.parseFromString = function (string) {\n var doc = document.implementation.createHTMLDocument('');\n doc.open();\n doc.write(string);\n doc.close();\n return doc;\n };\n }\n }\n return Parser;\n}\nfunction shouldUseActiveX() {\n var useActiveX = false;\n try {\n document.implementation.createHTMLDocument('').open();\n } catch (e) {\n if (root.ActiveXObject) useActiveX = true;\n }\n return useActiveX;\n}\nvar HTMLParser = canParseHTMLNatively() ? root.DOMParser : createHTMLParser();\n\nfunction RootNode(input, options) {\n var root;\n if (typeof input === 'string') {\n var doc = htmlParser().parseFromString(\n // DOM parsers arrange elements in the <head> and <body>.\n // Wrapping in a custom element ensures elements are reliably arranged in\n // a single element.\n '<x-turndown id=\"turndown-root\">' + input + '</x-turndown>', 'text/html');\n root = doc.getElementById('turndown-root');\n } else {\n root = input.cloneNode(true);\n }\n collapseWhitespace({\n element: root,\n isBlock: isBlock,\n isVoid: isVoid,\n isPre: options.preformattedCode ? isPreOrCode : null\n });\n return root;\n}\nvar _htmlParser;\nfunction htmlParser() {\n _htmlParser = _htmlParser || new HTMLParser();\n return _htmlParser;\n}\nfunction isPreOrCode(node) {\n return node.nodeName === 'PRE' || node.nodeName === 'CODE';\n}\n\nfunction Node(node, options) {\n node.isBlock = isBlock(node);\n node.isCode = node.nodeName === 'CODE' || node.parentNode.isCode;\n node.isBlank = isBlank(node);\n node.flankingWhitespace = flankingWhitespace(node, options);\n return node;\n}\nfunction isBlank(node) {\n return !isVoid(node) && !isMeaningfulWhenBlank(node) && /^\\s*$/i.test(node.textContent) && !hasVoid(node) && !hasMeaningfulWhenBlank(node);\n}\nfunction flankingWhitespace(node, options) {\n if (node.isBlock || options.preformattedCode && node.isCode) {\n return {\n leading: '',\n trailing: ''\n };\n }\n var edges = edgeWhitespace(node.textContent);\n\n // abandon leading ASCII WS if left-flanked by ASCII WS\n if (edges.leadingAscii && isFlankedByWhitespace('left', node, options)) {\n edges.leading = edges.leadingNonAscii;\n }\n\n // abandon trailing ASCII WS if right-flanked by ASCII WS\n if (edges.trailingAscii && isFlankedByWhitespace('right', node, options)) {\n edges.trailing = edges.trailingNonAscii;\n }\n return {\n leading: edges.leading,\n trailing: edges.trailing\n };\n}\nfunction edgeWhitespace(string) {\n var m = string.match(/^(([ \\t\\r\\n]*)(\\s*))(?:(?=\\S)[\\s\\S]*\\S)?((\\s*?)([ \\t\\r\\n]*))$/);\n return {\n leading: m[1],\n // whole string for whitespace-only strings\n leadingAscii: m[2],\n leadingNonAscii: m[3],\n trailing: m[4],\n // empty for whitespace-only strings\n trailingNonAscii: m[5],\n trailingAscii: m[6]\n };\n}\nfunction isFlankedByWhitespace(side, node, options) {\n var sibling;\n var regExp;\n var isFlanked;\n if (side === 'left') {\n sibling = node.previousSibling;\n regExp = / $/;\n } else {\n sibling = node.nextSibling;\n regExp = /^ /;\n }\n if (sibling) {\n if (sibling.nodeType === 3) {\n isFlanked = regExp.test(sibling.nodeValue);\n } else if (options.preformattedCode && sibling.nodeName === 'CODE') {\n isFlanked = false;\n } else if (sibling.nodeType === 1 && !isBlock(sibling)) {\n isFlanked = regExp.test(sibling.textContent);\n }\n }\n return isFlanked;\n}\n\nvar reduce = Array.prototype.reduce;\nfunction TurndownService(options) {\n if (!(this instanceof TurndownService)) return new TurndownService(options);\n var defaults = {\n rules: rules,\n headingStyle: 'setext',\n hr: '* * *',\n bulletListMarker: '*',\n codeBlockStyle: 'indented',\n fence: '```',\n emDelimiter: '_',\n strongDelimiter: '**',\n linkStyle: 'inlined',\n linkReferenceStyle: 'full',\n br: ' ',\n preformattedCode: false,\n blankReplacement: function (content, node) {\n return node.isBlock ? '\\n\\n' : '';\n },\n keepReplacement: function (content, node) {\n return node.isBlock ? '\\n\\n' + node.outerHTML + '\\n\\n' : node.outerHTML;\n },\n defaultReplacement: function (content, node) {\n return node.isBlock ? '\\n\\n' + content + '\\n\\n' : content;\n }\n };\n this.options = extend({}, defaults, options);\n this.rules = new Rules(this.options);\n}\nTurndownService.prototype = {\n /**\n * The entry point for converting a string or DOM node to Markdown\n * @public\n * @param {String|HTMLElement} input The string or DOM node to convert\n * @returns A Markdown representation of the input\n * @type String\n */\n\n turndown: function (input) {\n if (!canConvert(input)) {\n throw new TypeError(input + ' is not a string, or an element/document/fragment node.');\n }\n if (input === '') return '';\n var output = process.call(this, new RootNode(input, this.options));\n return postProcess.call(this, output);\n },\n /**\n * Add one or more plugins\n * @public\n * @param {Function|Array} plugin The plugin or array of plugins to add\n * @returns The Turndown instance for chaining\n * @type Object\n */\n\n use: function (plugin) {\n if (Array.isArray(plugin)) {\n for (var i = 0; i < plugin.length; i++) this.use(plugin[i]);\n } else if (typeof plugin === 'function') {\n plugin(this);\n } else {\n throw new TypeError('plugin must be a Function or an Array of Functions');\n }\n return this;\n },\n /**\n * Adds a rule\n * @public\n * @param {String} key The unique key of the rule\n * @param {Object} rule The rule\n * @returns The Turndown instance for chaining\n * @type Object\n */\n\n addRule: function (key, rule) {\n this.rules.add(key, rule);\n return this;\n },\n /**\n * Keep a node (as HTML) that matches the filter\n * @public\n * @param {String|Array|Function} filter The unique key of the rule\n * @returns The Turndown instance for chaining\n * @type Object\n */\n\n keep: function (filter) {\n this.rules.keep(filter);\n return this;\n },\n /**\n * Remove a node that matches the filter\n * @public\n * @param {String|Array|Function} filter The unique key of the rule\n * @returns The Turndown instance for chaining\n * @type Object\n */\n\n remove: function (filter) {\n this.rules.remove(filter);\n return this;\n },\n /**\n * Escapes Markdown syntax\n * @public\n * @param {String} string The string to escape\n * @returns A string with Markdown syntax escaped\n * @type String\n */\n\n escape: function (string) {\n return escapeMarkdown(string);\n }\n};\n\n/**\n * Reduces a DOM node down to its Markdown string equivalent\n * @private\n * @param {HTMLElement} parentNode The node to convert\n * @returns A Markdown representation of the node\n * @type String\n */\n\nfunction process(parentNode) {\n var self = this;\n return reduce.call(parentNode.childNodes, function (output, node) {\n node = new Node(node, self.options);\n var replacement = '';\n if (node.nodeType === 3) {\n replacement = node.isCode ? node.nodeValue : self.escape(node.nodeValue);\n } else if (node.nodeType === 1) {\n replacement = replacementForNode.call(self, node);\n }\n return join(output, replacement);\n }, '');\n}\n\n/**\n * Appends strings as each rule requires and trims the output\n * @private\n * @param {String} output The conversion output\n * @returns A trimmed version of the ouput\n * @type String\n */\n\nfunction postProcess(output) {\n var self = this;\n this.rules.forEach(function (rule) {\n if (typeof rule.append === 'function') {\n output = join(output, rule.append(self.options));\n }\n });\n return output.replace(/^[\\t\\r\\n]+/, '').replace(/[\\t\\r\\n\\s]+$/, '');\n}\n\n/**\n * Converts an element node to its Markdown equivalent\n * @private\n * @param {HTMLElement} node The node to convert\n * @returns A Markdown representation of the node\n * @type String\n */\n\nfunction replacementForNode(node) {\n var rule = this.rules.forNode(node);\n var content = process.call(this, node);\n var whitespace = node.flankingWhitespace;\n if (whitespace.leading || whitespace.trailing) content = content.trim();\n return whitespace.leading + rule.replacement(content, node, this.options) + whitespace.trailing;\n}\n\n/**\n * Joins replacement to the current output with appropriate number of new lines\n * @private\n * @param {String} output The current conversion output\n * @param {String} replacement The string to append to the output\n * @returns Joined output\n * @type String\n */\n\nfunction join(output, replacement) {\n var s1 = trimTrailingNewlines(output);\n var s2 = trimLeadingNewlines(replacement);\n var nls = Math.max(output.length - s1.length, replacement.length - s2.length);\n var separator = '\\n\\n'.substring(0, nls);\n return s1 + separator + s2;\n}\n\n/**\n * Determines whether an input can be converted\n * @private\n * @param {String|HTMLElement} input Describe this parameter\n * @returns Describe what it returns\n * @type String|Object|Array|Boolean|Number\n */\n\nfunction canConvert(input) {\n return input != null && (typeof input === 'string' || input.nodeType && (input.nodeType === 1 || input.nodeType === 9 || input.nodeType === 11));\n}\n\nexport { TurndownService as default };\n","/**\n * @typedef {import('mdast').Nodes} Nodes\n *\n * @typedef Options\n * Configuration (optional).\n * @property {boolean | null | undefined} [includeImageAlt=true]\n * Whether to use `alt` for `image`s (default: `true`).\n * @property {boolean | null | undefined} [includeHtml=true]\n * Whether to use `value` of HTML (default: `true`).\n */\n\n/** @type {Options} */\nconst emptyOptions = {}\n\n/**\n * Get the text content of a node or list of nodes.\n *\n * Prefers the node’s plain-text fields, otherwise serializes its children,\n * and if the given value is an array, serialize the nodes in it.\n *\n * @param {unknown} [value]\n * Thing to serialize, typically `Node`.\n * @param {Options | null | undefined} [options]\n * Configuration (optional).\n * @returns {string}\n * Serialized `value`.\n */\nexport function toString(value, options) {\n const settings = options || emptyOptions\n const includeImageAlt =\n typeof settings.includeImageAlt === 'boolean'\n ? settings.includeImageAlt\n : true\n const includeHtml =\n typeof settings.includeHtml === 'boolean' ? settings.includeHtml : true\n\n return one(value, includeImageAlt, includeHtml)\n}\n\n/**\n * One node or several nodes.\n *\n * @param {unknown} value\n * Thing to serialize.\n * @param {boolean} includeImageAlt\n * Include image `alt`s.\n * @param {boolean} includeHtml\n * Include HTML.\n * @returns {string}\n * Serialized node.\n */\nfunction one(value, includeImageAlt, includeHtml) {\n if (node(value)) {\n if ('value' in value) {\n return value.type === 'html' && !includeHtml ? '' : value.value\n }\n\n if (includeImageAlt && 'alt' in value && value.alt) {\n return value.alt\n }\n\n if ('children' in value) {\n return all(value.children, includeImageAlt, includeHtml)\n }\n }\n\n if (Array.isArray(value)) {\n return all(value, includeImageAlt, includeHtml)\n }\n\n return ''\n}\n\n/**\n * Serialize a list of nodes.\n *\n * @param {Array<unknown>} values\n * Thing to serialize.\n * @param {boolean} includeImageAlt\n * Include image `alt`s.\n * @param {boolean} includeHtml\n * Include HTML.\n * @returns {string}\n * Serialized nodes.\n */\nfunction all(values, includeImageAlt, includeHtml) {\n /** @type {Array<string>} */\n const result = []\n let index = -1\n\n while (++index < values.length) {\n result[index] = one(values[index], includeImageAlt, includeHtml)\n }\n\n return result.join('')\n}\n\n/**\n * Check if `value` looks like a node.\n *\n * @param {unknown} value\n * Thing.\n * @returns {value is Nodes}\n * Whether `value` is a node.\n */\nfunction node(value) {\n return Boolean(value && typeof value === 'object')\n}\n","import { decodeNamedCharacterReference } from 'decode-named-character-reference';\nimport { decodeNumericCharacterReference } from 'micromark-util-decode-numeric-character-reference';\nconst characterEscapeOrReference = /\\\\([!-/:-@[-`{-~])|&(#(?:\\d{1,7}|x[\\da-f]{1,6})|[\\da-z]{1,31});/gi;\n\n/**\n * Decode markdown strings (which occur in places such as fenced code info\n * strings, destinations, labels, and titles).\n *\n * The “string” content type allows character escapes and -references.\n * This decodes those.\n *\n * @param {string} value\n * Value to decode.\n * @returns {string}\n * Decoded value.\n */\nexport function decodeString(value) {\n return value.replace(characterEscapeOrReference, decode);\n}\n\n/**\n * @param {string} $0\n * Match.\n * @param {string} $1\n * Character escape.\n * @param {string} $2\n * Character reference.\n * @returns {string}\n * Decoded value\n */\nfunction decode($0, $1, $2) {\n if ($1) {\n // Escape.\n return $1;\n }\n\n // Reference.\n const head = $2.charCodeAt(0);\n if (head === 35) {\n const head = $2.charCodeAt(1);\n const hex = head === 120 || head === 88;\n return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10);\n }\n return decodeNamedCharacterReference($2) || $0;\n}","/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Point} Point\n * @typedef {import('unist').Position} Position\n */\n\n/**\n * @typedef NodeLike\n * @property {string} type\n * @property {PositionLike | null | undefined} [position]\n *\n * @typedef PointLike\n * @property {number | null | undefined} [line]\n * @property {number | null | undefined} [column]\n * @property {number | null | undefined} [offset]\n *\n * @typedef PositionLike\n * @property {PointLike | null | undefined} [start]\n * @property {PointLike | null | undefined} [end]\n */\n\n/**\n * Serialize the positional info of a point, position (start and end points),\n * or node.\n *\n * @param {Node | NodeLike | Point | PointLike | Position | PositionLike | null | undefined} [value]\n * Node, position, or point.\n * @returns {string}\n * Pretty printed positional info of a node (`string`).\n *\n * In the format of a range `ls:cs-le:ce` (when given `node` or `position`)\n * or a point `l:c` (when given `point`), where `l` stands for line, `c` for\n * column, `s` for `start`, and `e` for end.\n * An empty string (`''`) is returned if the given value is neither `node`,\n * `position`, nor `point`.\n */\nexport function stringifyPosition(value) {\n // Nothing.\n if (!value || typeof value !== 'object') {\n return ''\n }\n\n // Node.\n if ('position' in value || 'type' in value) {\n return position(value.position)\n }\n\n // Position.\n if ('start' in value || 'end' in value) {\n return position(value)\n }\n\n // Point.\n if ('line' in value || 'column' in value) {\n return point(value)\n }\n\n // ?\n return ''\n}\n\n/**\n * @param {Point | PointLike | null | undefined} point\n * @returns {string}\n */\nfunction point(point) {\n return index(point && point.line) + ':' + index(point && point.column)\n}\n\n/**\n * @param {Position | PositionLike | null | undefined} pos\n * @returns {string}\n */\nfunction position(pos) {\n return point(pos && pos.start) + '-' + point(pos && pos.end)\n}\n\n/**\n * @param {number | null | undefined} value\n * @returns {number}\n */\nfunction index(value) {\n return value && typeof value === 'number' ? value : 1\n}\n","/**\n * @import {\n * Break,\n * Blockquote,\n * Code,\n * Definition,\n * Emphasis,\n * Heading,\n * Html,\n * Image,\n * InlineCode,\n * Link,\n * ListItem,\n * List,\n * Nodes,\n * Paragraph,\n * PhrasingContent,\n * ReferenceType,\n * Root,\n * Strong,\n * Text,\n * ThematicBreak\n * } from 'mdast'\n * @import {\n * Encoding,\n * Event,\n * Token,\n * Value\n * } from 'micromark-util-types'\n * @import {Point} from 'unist'\n * @import {\n * CompileContext,\n * CompileData,\n * Config,\n * Extension,\n * Handle,\n * OnEnterError,\n * Options\n * } from './types.js'\n */\n\nimport { toString } from 'mdast-util-to-string';\nimport { parse, postprocess, preprocess } from 'micromark';\nimport { decodeNumericCharacterReference } from 'micromark-util-decode-numeric-character-reference';\nimport { decodeString } from 'micromark-util-decode-string';\nimport { normalizeIdentifier } from 'micromark-util-normalize-identifier';\nimport { decodeNamedCharacterReference } from 'decode-named-character-reference';\nimport { stringifyPosition } from 'unist-util-stringify-position';\nconst own = {}.hasOwnProperty;\n\n/**\n * Turn markdown into a syntax tree.\n *\n * @overload\n * @param {Value} value\n * @param {Encoding | null | undefined} [encoding]\n * @param {Options | null | undefined} [options]\n * @returns {Root}\n *\n * @overload\n * @param {Value} value\n * @param {Options | null | undefined} [options]\n * @returns {Root}\n *\n * @param {Value} value\n * Markdown to parse.\n * @param {Encoding | Options | null | undefined} [encoding]\n * Character encoding for when `value` is `Buffer`.\n * @param {Options | null | undefined} [options]\n * Configuration.\n * @returns {Root}\n * mdast tree.\n */\nexport function fromMarkdown(value, encoding, options) {\n if (encoding && typeof encoding === 'object') {\n options = encoding;\n encoding = undefined;\n }\n return compiler(options)(postprocess(parse(options).document().write(preprocess()(value, encoding, true))));\n}\n\n/**\n * Note this compiler only understand complete buffering, not streaming.\n *\n * @param {Options | null | undefined} [options]\n */\nfunction compiler(options) {\n /** @type {Config} */\n const config = {\n transforms: [],\n canContainEols: ['emphasis', 'fragment', 'heading', 'paragraph', 'strong'],\n enter: {\n autolink: opener(link),\n autolinkProtocol: onenterdata,\n autolinkEmail: onenterdata,\n atxHeading: opener(heading),\n blockQuote: opener(blockQuote),\n characterEscape: onenterdata,\n characterReference: onenterdata,\n codeFenced: opener(codeFlow),\n codeFencedFenceInfo: buffer,\n codeFencedFenceMeta: buffer,\n codeIndented: opener(codeFlow, buffer),\n codeText: opener(codeText, buffer),\n codeTextData: onenterdata,\n data: onenterdata,\n codeFlowValue: onenterdata,\n definition: opener(definition),\n definitionDestinationString: buffer,\n definitionLabelString: buffer,\n definitionTitleString: buffer,\n emphasis: opener(emphasis),\n hardBreakEscape: opener(hardBreak),\n hardBreakTrailing: opener(hardBreak),\n htmlFlow: opener(html, buffer),\n htmlFlowData: onenterdata,\n htmlText: opener(html, buffer),\n htmlTextData: onenterdata,\n image: opener(image),\n label: buffer,\n link: opener(link),\n listItem: opener(listItem),\n listItemValue: onenterlistitemvalue,\n listOrdered: opener(list, onenterlistordered),\n listUnordered: opener(list),\n paragraph: opener(paragraph),\n reference: onenterreference,\n referenceString: buffer,\n resourceDestinationString: buffer,\n resourceTitleString: buffer,\n setextHeading: opener(heading),\n strong: opener(strong),\n thematicBreak: opener(thematicBreak)\n },\n exit: {\n atxHeading: closer(),\n atxHeadingSequence: onexitatxheadingsequence,\n autolink: closer(),\n autolinkEmail: onexitautolinkemail,\n autolinkProtocol: onexitautolinkprotocol,\n blockQuote: closer(),\n characterEscapeValue: onexitdata,\n characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker,\n characterReferenceMarkerNumeric: onexitcharacterreferencemarker,\n characterReferenceValue: onexitcharacterreferencevalue,\n characterReference: onexitcharacterreference,\n codeFenced: closer(onexitcodefenced),\n codeFencedFence: onexitcodefencedfence,\n codeFencedFenceInfo: onexitcodefencedfenceinfo,\n codeFencedFenceMeta: onexitcodefencedfencemeta,\n codeFlowValue: onexitdata,\n codeIndented: closer(onexitcodeindented),\n codeText: closer(onexitcodetext),\n codeTextData: onexitdata,\n data: onexitdata,\n definition: closer(),\n definitionDestinationString: onexitdefinitiondestinationstring,\n definitionLabelString: onexitdefinitionlabelstring,\n definitionTitleString: onexitdefinitiontitlestring,\n emphasis: closer(),\n hardBreakEscape: closer(onexithardbreak),\n hardBreakTrailing: closer(onexithardbreak),\n htmlFlow: closer(onexithtmlflow),\n htmlFlowData: onexitdata,\n htmlText: closer(onexithtmltext),\n htmlTextData: onexitdata,\n image: closer(onexitimage),\n label: onexitlabel,\n labelText: onexitlabeltext,\n lineEnding: onexitlineending,\n link: closer(onexitlink),\n listItem: closer(),\n listOrdered: closer(),\n listUnordered: closer(),\n paragraph: closer(),\n referenceString: onexitreferencestring,\n resourceDestinationString: onexitresourcedestinationstring,\n resourceTitleString: onexitresourcetitlestring,\n resource: onexitresource,\n setextHeading: closer(onexitsetextheading),\n setextHeadingLineSequence: onexitsetextheadinglinesequence,\n setextHeadingText: onexitsetextheadingtext,\n strong: closer(),\n thematicBreak: closer()\n }\n };\n configure(config, (options || {}).mdastExtensions || []);\n\n /** @type {CompileData} */\n const data = {};\n return compile;\n\n /**\n * Turn micromark events into an mdast tree.\n *\n * @param {Array<Event>} events\n * Events.\n * @returns {Root}\n * mdast tree.\n */\n function compile(events) {\n /** @type {Root} */\n let tree = {\n type: 'root',\n children: []\n };\n /** @type {Omit<CompileContext, 'sliceSerialize'>} */\n const context = {\n stack: [tree],\n tokenStack: [],\n config,\n enter,\n exit,\n buffer,\n resume,\n data\n };\n /** @type {Array<number>} */\n const listStack = [];\n let index = -1;\n while (++index < events.length) {\n // We preprocess lists to add `listItem` tokens, and to infer whether\n // items the list itself are spread out.\n if (events[index][1].type === \"listOrdered\" || events[index][1].type === \"listUnordered\") {\n if (events[index][0] === 'enter') {\n listStack.push(index);\n } else {\n const tail = listStack.pop();\n index = prepareList(events, tail, index);\n }\n }\n }\n index = -1;\n while (++index < events.length) {\n const handler = config[events[index][0]];\n if (own.call(handler, events[index][1].type)) {\n handler[events[index][1].type].call(Object.assign({\n sliceSerialize: events[index][2].sliceSerialize\n }, context), events[index][1]);\n }\n }\n\n // Handle tokens still being open.\n if (context.tokenStack.length > 0) {\n const tail = context.tokenStack[context.tokenStack.length - 1];\n const handler = tail[1] || defaultOnError;\n handler.call(context, undefined, tail[0]);\n }\n\n // Figure out `root` position.\n tree.position = {\n start: point(events.length > 0 ? events[0][1].start : {\n line: 1,\n column: 1,\n offset: 0\n }),\n end: point(events.length > 0 ? events[events.length - 2][1].end : {\n line: 1,\n column: 1,\n offset: 0\n })\n };\n\n // Call transforms.\n index = -1;\n while (++index < config.transforms.length) {\n tree = config.transforms[index](tree) || tree;\n }\n return tree;\n }\n\n /**\n * @param {Array<Event>} events\n * @param {number} start\n * @param {number} length\n * @returns {number}\n */\n function prepareList(events, start, length) {\n let index = start - 1;\n let containerBalance = -1;\n let listSpread = false;\n /** @type {Token | undefined} */\n let listItem;\n /** @type {number | undefined} */\n let lineIndex;\n /** @type {number | undefined} */\n let firstBlankLineIndex;\n /** @type {boolean | undefined} */\n let atMarker;\n while (++index <= length) {\n const event = events[index];\n switch (event[1].type) {\n case \"listUnordered\":\n case \"listOrdered\":\n case \"blockQuote\":\n {\n if (event[0] === 'enter') {\n containerBalance++;\n } else {\n containerBalance--;\n }\n atMarker = undefined;\n break;\n }\n case \"lineEndingBlank\":\n {\n if (event[0] === 'enter') {\n if (listItem && !atMarker && !containerBalance && !firstBlankLineIndex) {\n firstBlankLineIndex = index;\n }\n atMarker = undefined;\n }\n break;\n }\n case \"linePrefix\":\n case \"listItemValue\":\n case \"listItemMarker\":\n case \"listItemPrefix\":\n case \"listItemPrefixWhitespace\":\n {\n // Empty.\n\n break;\n }\n default:\n {\n atMarker = undefined;\n }\n }\n if (!containerBalance && event[0] === 'enter' && event[1].type === \"listItemPrefix\" || containerBalance === -1 && event[0] === 'exit' && (event[1].type === \"listUnordered\" || event[1].type === \"listOrdered\")) {\n if (listItem) {\n let tailIndex = index;\n lineIndex = undefined;\n while (tailIndex--) {\n const tailEvent = events[tailIndex];\n if (tailEvent[1].type === \"lineEnding\" || tailEvent[1].type === \"lineEndingBlank\") {\n if (tailEvent[0] === 'exit') continue;\n if (lineIndex) {\n events[lineIndex][1].type = \"lineEndingBlank\";\n listSpread = true;\n }\n tailEvent[1].type = \"lineEnding\";\n lineIndex = tailIndex;\n } else if (tailEvent[1].type === \"linePrefix\" || tailEvent[1].type === \"blockQuotePrefix\" || tailEvent[1].type === \"blockQuotePrefixWhitespace\" || tailEvent[1].type === \"blockQuoteMarker\" || tailEvent[1].type === \"listItemIndent\") {\n // Empty\n } else {\n break;\n }\n }\n if (firstBlankLineIndex && (!lineIndex || firstBlankLineIndex < lineIndex)) {\n listItem._spread = true;\n }\n\n // Fix position.\n listItem.end = Object.assign({}, lineIndex ? events[lineIndex][1].start : event[1].end);\n events.splice(lineIndex || index, 0, ['exit', listItem, event[2]]);\n index++;\n length++;\n }\n\n // Create a new list item.\n if (event[1].type === \"listItemPrefix\") {\n /** @type {Token} */\n const item = {\n type: 'listItem',\n _spread: false,\n start: Object.assign({}, event[1].start),\n // @ts-expect-error: we’ll add `end` in a second.\n end: undefined\n };\n listItem = item;\n events.splice(index, 0, ['enter', item, event[2]]);\n index++;\n length++;\n firstBlankLineIndex = undefined;\n atMarker = true;\n }\n }\n }\n events[start][1]._spread = listSpread;\n return length;\n }\n\n /**\n * Create an opener handle.\n *\n * @param {(token: Token) => Nodes} create\n * Create a node.\n * @param {Handle | undefined} [and]\n * Optional function to also run.\n * @returns {Handle}\n * Handle.\n */\n function opener(create, and) {\n return open;\n\n /**\n * @this {CompileContext}\n * @param {Token} token\n * @returns {undefined}\n */\n function open(token) {\n enter.call(this, create(token), token);\n if (and) and.call(this, token);\n }\n }\n\n /**\n * @type {CompileContext['buffer']}\n */\n function buffer() {\n this.stack.push({\n type: 'fragment',\n children: []\n });\n }\n\n /**\n * @type {CompileContext['enter']}\n */\n function enter(node, token, errorHandler) {\n const parent = this.stack[this.stack.length - 1];\n /** @type {Array<Nodes>} */\n const siblings = parent.children;\n siblings.push(node);\n this.stack.push(node);\n this.tokenStack.push([token, errorHandler || undefined]);\n node.position = {\n start: point(token.start),\n // @ts-expect-error: `end` will be patched later.\n end: undefined\n };\n }\n\n /**\n * Create a closer handle.\n *\n * @param {Handle | undefined} [and]\n * Optional function to also run.\n * @returns {Handle}\n * Handle.\n */\n function closer(and) {\n return close;\n\n /**\n * @this {CompileContext}\n * @param {Token} token\n * @returns {undefined}\n */\n function close(token) {\n if (and) and.call(this, token);\n exit.call(this, token);\n }\n }\n\n /**\n * @type {CompileContext['exit']}\n */\n function exit(token, onExitError) {\n const node = this.stack.pop();\n const open = this.tokenStack.pop();\n if (!open) {\n throw new Error('Cannot close `' + token.type + '` (' + stringifyPosition({\n start: token.start,\n end: token.end\n }) + '): it’s not open');\n } else if (open[0].type !== token.type) {\n if (onExitError) {\n onExitError.call(this, token, open[0]);\n } else {\n const handler = open[1] || defaultOnError;\n handler.call(this, token, open[0]);\n }\n }\n node.position.end = point(token.end);\n }\n\n /**\n * @type {CompileContext['resume']}\n */\n function resume() {\n return toString(this.stack.pop());\n }\n\n //\n // Handlers.\n //\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterlistordered() {\n this.data.expectingFirstListItemValue = true;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterlistitemvalue(token) {\n if (this.data.expectingFirstListItemValue) {\n const ancestor = this.stack[this.stack.length - 2];\n ancestor.start = Number.parseInt(this.sliceSerialize(token), 10);\n this.data.expectingFirstListItemValue = undefined;\n }\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefencedfenceinfo() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.lang = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefencedfencemeta() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.meta = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefencedfence() {\n // Exit if this is the closing fence.\n if (this.data.flowCodeInside) return;\n this.buffer();\n this.data.flowCodeInside = true;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefenced() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.value = data.replace(/^(\\r?\\n|\\r)|(\\r?\\n|\\r)$/g, '');\n this.data.flowCodeInside = undefined;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodeindented() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.value = data.replace(/(\\r?\\n|\\r)$/g, '');\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitionlabelstring(token) {\n const label = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.label = label;\n node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitiontitlestring() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.title = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitiondestinationstring() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.url = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitatxheadingsequence(token) {\n const node = this.stack[this.stack.length - 1];\n if (!node.depth) {\n const depth = this.sliceSerialize(token).length;\n node.depth = depth;\n }\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheadingtext() {\n this.data.setextHeadingSlurpLineEnding = true;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheadinglinesequence(token) {\n const node = this.stack[this.stack.length - 1];\n node.depth = this.sliceSerialize(token).codePointAt(0) === 61 ? 1 : 2;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheading() {\n this.data.setextHeadingSlurpLineEnding = undefined;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onenterdata(token) {\n const node = this.stack[this.stack.length - 1];\n /** @type {Array<Nodes>} */\n const siblings = node.children;\n let tail = siblings[siblings.length - 1];\n if (!tail || tail.type !== 'text') {\n // Add a new text node.\n tail = text();\n tail.position = {\n start: point(token.start),\n // @ts-expect-error: we’ll add `end` later.\n end: undefined\n };\n siblings.push(tail);\n }\n this.stack.push(tail);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitdata(token) {\n const tail = this.stack.pop();\n tail.value += this.sliceSerialize(token);\n tail.position.end = point(token.end);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitlineending(token) {\n const context = this.stack[this.stack.length - 1];\n // If we’re at a hard break, include the line ending in there.\n if (this.data.atHardBreak) {\n const tail = context.children[context.children.length - 1];\n tail.position.end = point(token.end);\n this.data.atHardBreak = undefined;\n return;\n }\n if (!this.data.setextHeadingSlurpLineEnding && config.canContainEols.includes(context.type)) {\n onenterdata.call(this, token);\n onexitdata.call(this, token);\n }\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexithardbreak() {\n this.data.atHardBreak = true;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexithtmlflow() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.value = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexithtmltext() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.value = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitcodetext() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.value = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitlink() {\n const node = this.stack[this.stack.length - 1];\n // Note: there are also `identifier` and `label` fields on this link node!\n // These are used / cleaned here.\n\n // To do: clean.\n if (this.data.inReference) {\n /** @type {ReferenceType} */\n const referenceType = this.data.referenceType || 'shortcut';\n node.type += 'Reference';\n // @ts-expect-error: mutate.\n node.referenceType = referenceType;\n // @ts-expect-error: mutate.\n delete node.url;\n delete node.title;\n } else {\n // @ts-expect-error: mutate.\n delete node.identifier;\n // @ts-expect-error: mutate.\n delete node.label;\n }\n this.data.referenceType = undefined;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitimage() {\n const node = this.stack[this.stack.length - 1];\n // Note: there are also `identifier` and `label` fields on this link node!\n // These are used / cleaned here.\n\n // To do: clean.\n if (this.data.inReference) {\n /** @type {ReferenceType} */\n const referenceType = this.data.referenceType || 'shortcut';\n node.type += 'Reference';\n // @ts-expect-error: mutate.\n node.referenceType = referenceType;\n // @ts-expect-error: mutate.\n delete node.url;\n delete node.title;\n } else {\n // @ts-expect-error: mutate.\n delete node.identifier;\n // @ts-expect-error: mutate.\n delete node.label;\n }\n this.data.referenceType = undefined;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitlabeltext(token) {\n const string = this.sliceSerialize(token);\n const ancestor = this.stack[this.stack.length - 2];\n // @ts-expect-error: stash this on the node, as it might become a reference\n // later.\n ancestor.label = decodeString(string);\n // @ts-expect-error: same as above.\n ancestor.identifier = normalizeIdentifier(string).toLowerCase();\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitlabel() {\n const fragment = this.stack[this.stack.length - 1];\n const value = this.resume();\n const node = this.stack[this.stack.length - 1];\n // Assume a reference.\n this.data.inReference = true;\n if (node.type === 'link') {\n /** @type {Array<PhrasingContent>} */\n const children = fragment.children;\n node.children = children;\n } else {\n node.alt = value;\n }\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitresourcedestinationstring() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.url = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitresourcetitlestring() {\n const data = this.resume();\n const node = this.stack[this.stack.length - 1];\n node.title = data;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitresource() {\n this.data.inReference = undefined;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onenterreference() {\n this.data.referenceType = 'collapsed';\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitreferencestring(token) {\n const label = this.resume();\n const node = this.stack[this.stack.length - 1];\n // @ts-expect-error: stash this on the node, as it might become a reference\n // later.\n node.label = label;\n // @ts-expect-error: same as above.\n node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();\n this.data.referenceType = 'full';\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitcharacterreferencemarker(token) {\n this.data.characterReferenceType = token.type;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcharacterreferencevalue(token) {\n const data = this.sliceSerialize(token);\n const type = this.data.characterReferenceType;\n /** @type {string} */\n let value;\n if (type) {\n value = decodeNumericCharacterReference(data, type === \"characterReferenceMarkerNumeric\" ? 10 : 16);\n this.data.characterReferenceType = undefined;\n } else {\n const result = decodeNamedCharacterReference(data);\n value = result;\n }\n const tail = this.stack[this.stack.length - 1];\n tail.value += value;\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcharacterreference(token) {\n const tail = this.stack.pop();\n tail.position.end = point(token.end);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitautolinkprotocol(token) {\n onexitdata.call(this, token);\n const node = this.stack[this.stack.length - 1];\n node.url = this.sliceSerialize(token);\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitautolinkemail(token) {\n onexitdata.call(this, token);\n const node = this.stack[this.stack.length - 1];\n node.url = 'mailto:' + this.sliceSerialize(token);\n }\n\n //\n // Creaters.\n //\n\n /** @returns {Blockquote} */\n function blockQuote() {\n return {\n type: 'blockquote',\n children: []\n };\n }\n\n /** @returns {Code} */\n function codeFlow() {\n return {\n type: 'code',\n lang: null,\n meta: null,\n value: ''\n };\n }\n\n /** @returns {InlineCode} */\n function codeText() {\n return {\n type: 'inlineCode',\n value: ''\n };\n }\n\n /** @returns {Definition} */\n function definition() {\n return {\n type: 'definition',\n identifier: '',\n label: null,\n title: null,\n url: ''\n };\n }\n\n /** @returns {Emphasis} */\n function emphasis() {\n return {\n type: 'emphasis',\n children: []\n };\n }\n\n /** @returns {Heading} */\n function heading() {\n return {\n type: 'heading',\n // @ts-expect-error `depth` will be set later.\n depth: 0,\n children: []\n };\n }\n\n /** @returns {Break} */\n function hardBreak() {\n return {\n type: 'break'\n };\n }\n\n /** @returns {Html} */\n function html() {\n return {\n type: 'html',\n value: ''\n };\n }\n\n /** @returns {Image} */\n function image() {\n return {\n type: 'image',\n title: null,\n url: '',\n alt: null\n };\n }\n\n /** @returns {Link} */\n function link() {\n return {\n type: 'link',\n title: null,\n url: '',\n children: []\n };\n }\n\n /**\n * @param {Token} token\n * @returns {List}\n */\n function list(token) {\n return {\n type: 'list',\n ordered: token.type === 'listOrdered',\n start: null,\n spread: token._spread,\n children: []\n };\n }\n\n /**\n * @param {Token} token\n * @returns {ListItem}\n */\n function listItem(token) {\n return {\n type: 'listItem',\n spread: token._spread,\n checked: null,\n children: []\n };\n }\n\n /** @returns {Paragraph} */\n function paragraph() {\n return {\n type: 'paragraph',\n children: []\n };\n }\n\n /** @returns {Strong} */\n function strong() {\n return {\n type: 'strong',\n children: []\n };\n }\n\n /** @returns {Text} */\n function text() {\n return {\n type: 'text',\n value: ''\n };\n }\n\n /** @returns {ThematicBreak} */\n function thematicBreak() {\n return {\n type: 'thematicBreak'\n };\n }\n}\n\n/**\n * Copy a point-like value.\n *\n * @param {Point} d\n * Point-like value.\n * @returns {Point}\n * unist point.\n */\nfunction point(d) {\n return {\n line: d.line,\n column: d.column,\n offset: d.offset\n };\n}\n\n/**\n * @param {Config} combined\n * @param {Array<Array<Extension> | Extension>} extensions\n * @returns {undefined}\n */\nfunction configure(combined, extensions) {\n let index = -1;\n while (++index < extensions.length) {\n const value = extensions[index];\n if (Array.isArray(value)) {\n configure(combined, value);\n } else {\n extension(combined, value);\n }\n }\n}\n\n/**\n * @param {Config} combined\n * @param {Extension} extension\n * @returns {undefined}\n */\nfunction extension(combined, extension) {\n /** @type {keyof Extension} */\n let key;\n for (key in extension) {\n if (own.call(extension, key)) {\n switch (key) {\n case 'canContainEols':\n {\n const right = extension[key];\n if (right) {\n combined[key].push(...right);\n }\n break;\n }\n case 'transforms':\n {\n const right = extension[key];\n if (right) {\n combined[key].push(...right);\n }\n break;\n }\n case 'enter':\n case 'exit':\n {\n const right = extension[key];\n if (right) {\n Object.assign(combined[key], right);\n }\n break;\n }\n // No default\n }\n }\n }\n}\n\n/** @type {OnEnterError} */\nfunction defaultOnError(left, right) {\n if (left) {\n throw new Error('Cannot close `' + left.type + '` (' + stringifyPosition({\n start: left.start,\n end: left.end\n }) + '): a different token (`' + right.type + '`, ' + stringifyPosition({\n start: right.start,\n end: right.end\n }) + ') is open');\n } else {\n throw new Error('Cannot close document, a token (`' + right.type + '`, ' + stringifyPosition({\n start: right.start,\n end: right.end\n }) + ') is still open');\n }\n}","/**\n * @typedef {import('mdast').Delete} Delete\n *\n * @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext\n * @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension\n * @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle\n *\n * @typedef {import('mdast-util-to-markdown').ConstructName} ConstructName\n * @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle\n * @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension\n */\n\n/**\n * List of constructs that occur in phrasing (paragraphs, headings), but cannot\n * contain strikethrough.\n * So they sort of cancel each other out.\n * Note: could use a better name.\n *\n * Note: keep in sync with: <https://github.com/syntax-tree/mdast-util-to-markdown/blob/8ce8dbf/lib/unsafe.js#L14>\n *\n * @type {Array<ConstructName>}\n */\nconst constructsWithoutStrikethrough = [\n 'autolink',\n 'destinationLiteral',\n 'destinationRaw',\n 'reference',\n 'titleQuote',\n 'titleApostrophe'\n]\n\nhandleDelete.peek = peekDelete\n\n/**\n * Create an extension for `mdast-util-from-markdown` to enable GFM\n * strikethrough in markdown.\n *\n * @returns {FromMarkdownExtension}\n * Extension for `mdast-util-from-markdown` to enable GFM strikethrough.\n */\nexport function gfmStrikethroughFromMarkdown() {\n return {\n canContainEols: ['delete'],\n enter: {strikethrough: enterStrikethrough},\n exit: {strikethrough: exitStrikethrough}\n }\n}\n\n/**\n * Create an extension for `mdast-util-to-markdown` to enable GFM\n * strikethrough in markdown.\n *\n * @returns {ToMarkdownExtension}\n * Extension for `mdast-util-to-markdown` to enable GFM strikethrough.\n */\nexport function gfmStrikethroughToMarkdown() {\n return {\n unsafe: [\n {\n character: '~',\n inConstruct: 'phrasing',\n notInConstruct: constructsWithoutStrikethrough\n }\n ],\n handlers: {delete: handleDelete}\n }\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterStrikethrough(token) {\n this.enter({type: 'delete', children: []}, token)\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitStrikethrough(token) {\n this.exit(token)\n}\n\n/**\n * @type {ToMarkdownHandle}\n * @param {Delete} node\n */\nfunction handleDelete(node, _, state, info) {\n const tracker = state.createTracker(info)\n const exit = state.enter('strikethrough')\n let value = tracker.move('~~')\n value += state.containerPhrasing(node, {\n ...tracker.current(),\n before: value,\n after: '~'\n })\n value += tracker.move('~~')\n exit()\n return value\n}\n\n/** @type {ToMarkdownHandle} */\nfunction peekDelete() {\n return '~'\n}\n","/**\n * @import {Node, Parent} from 'unist'\n */\n\n/**\n * @template Fn\n * @template Fallback\n * @typedef {Fn extends (value: any) => value is infer Thing ? Thing : Fallback} Predicate\n */\n\n/**\n * @callback Check\n * Check that an arbitrary value is a node.\n * @param {unknown} this\n * The given context.\n * @param {unknown} [node]\n * Anything (typically a node).\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {boolean}\n * Whether this is a node and passes a test.\n *\n * @typedef {Record<string, unknown> | Node} Props\n * Object to check for equivalence.\n *\n * Note: `Node` is included as it is common but is not indexable.\n *\n * @typedef {Array<Props | TestFunction | string> | ReadonlyArray<Props | TestFunction | string> | Props | TestFunction | string | null | undefined} Test\n * Check for an arbitrary node.\n *\n * @callback TestFunction\n * Check if a node passes a test.\n * @param {unknown} this\n * The given context.\n * @param {Node} node\n * A node.\n * @param {number | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | undefined} [parent]\n * The node’s parent.\n * @returns {boolean | undefined | void}\n * Whether this node passes the test.\n *\n * Note: `void` is included until TS sees no return as `undefined`.\n */\n\n/**\n * Check if `node` is a `Node` and whether it passes the given test.\n *\n * @param {unknown} node\n * Thing to check, typically `Node`.\n * @param {Test} test\n * A check for a specific node.\n * @param {number | null | undefined} index\n * The node’s position in its parent.\n * @param {Parent | null | undefined} parent\n * The node’s parent.\n * @param {unknown} context\n * Context object (`this`) to pass to `test` functions.\n * @returns {boolean}\n * Whether `node` is a node and passes a test.\n */\nexport const is =\n // Note: overloads in JSDoc can’t yet use different `@template`s.\n /**\n * @type {(\n * (<Condition extends ReadonlyArray<string>>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition[number]}) &\n * (<Condition extends Array<string>>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition[number]}) &\n * (<Condition extends string>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &\n * (<Condition extends Props>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &\n * (<Condition extends TestFunction>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &\n * ((node?: null | undefined) => false) &\n * ((node: unknown, test?: null | undefined, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &\n * ((node: unknown, test?: Test, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => boolean)\n * )}\n */\n (\n /**\n * @param {unknown} [node]\n * @param {Test} [test]\n * @param {number | null | undefined} [index]\n * @param {Parent | null | undefined} [parent]\n * @param {unknown} [context]\n * @returns {boolean}\n */\n // eslint-disable-next-line max-params\n function (node, test, index, parent, context) {\n const check = convert(test)\n\n if (\n index !== undefined &&\n index !== null &&\n (typeof index !== 'number' ||\n index < 0 ||\n index === Number.POSITIVE_INFINITY)\n ) {\n throw new Error('Expected positive finite index')\n }\n\n if (\n parent !== undefined &&\n parent !== null &&\n (!is(parent) || !parent.children)\n ) {\n throw new Error('Expected parent node')\n }\n\n if (\n (parent === undefined || parent === null) !==\n (index === undefined || index === null)\n ) {\n throw new Error('Expected both parent and index')\n }\n\n return looksLikeANode(node)\n ? check.call(context, node, index, parent)\n : false\n }\n )\n\n/**\n * Generate an assertion from a test.\n *\n * Useful if you’re going to test many nodes, for example when creating a\n * utility where something else passes a compatible test.\n *\n * The created function is a bit faster because it expects valid input only:\n * a `node`, `index`, and `parent`.\n *\n * @param {Test} test\n * * when nullish, checks if `node` is a `Node`.\n * * when `string`, works like passing `(node) => node.type === test`.\n * * when `function` checks if function passed the node is true.\n * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.\n * * when `array`, checks if any one of the subtests pass.\n * @returns {Check}\n * An assertion.\n */\nexport const convert =\n // Note: overloads in JSDoc can’t yet use different `@template`s.\n /**\n * @type {(\n * (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &\n * (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &\n * (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &\n * ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &\n * ((test?: Test) => Check)\n * )}\n */\n (\n /**\n * @param {Test} [test]\n * @returns {Check}\n */\n function (test) {\n if (test === null || test === undefined) {\n return ok\n }\n\n if (typeof test === 'function') {\n return castFactory(test)\n }\n\n if (typeof test === 'object') {\n return Array.isArray(test)\n ? anyFactory(test)\n : // Cast because `ReadonlyArray` goes into the above but `isArray`\n // narrows to `Array`.\n propertiesFactory(/** @type {Props} */ (test))\n }\n\n if (typeof test === 'string') {\n return typeFactory(test)\n }\n\n throw new Error('Expected function, string, or object as test')\n }\n )\n\n/**\n * @param {Array<Props | TestFunction | string>} tests\n * @returns {Check}\n */\nfunction anyFactory(tests) {\n /** @type {Array<Check>} */\n const checks = []\n let index = -1\n\n while (++index < tests.length) {\n checks[index] = convert(tests[index])\n }\n\n return castFactory(any)\n\n /**\n * @this {unknown}\n * @type {TestFunction}\n */\n function any(...parameters) {\n let index = -1\n\n while (++index < checks.length) {\n if (checks[index].apply(this, parameters)) return true\n }\n\n return false\n }\n}\n\n/**\n * Turn an object into a test for a node with a certain fields.\n *\n * @param {Props} check\n * @returns {Check}\n */\nfunction propertiesFactory(check) {\n const checkAsRecord = /** @type {Record<string, unknown>} */ (check)\n\n return castFactory(all)\n\n /**\n * @param {Node} node\n * @returns {boolean}\n */\n function all(node) {\n const nodeAsRecord = /** @type {Record<string, unknown>} */ (\n /** @type {unknown} */ (node)\n )\n\n /** @type {string} */\n let key\n\n for (key in check) {\n if (nodeAsRecord[key] !== checkAsRecord[key]) return false\n }\n\n return true\n }\n}\n\n/**\n * Turn a string into a test for a node with a certain type.\n *\n * @param {string} check\n * @returns {Check}\n */\nfunction typeFactory(check) {\n return castFactory(type)\n\n /**\n * @param {Node} node\n */\n function type(node) {\n return node && node.type === check\n }\n}\n\n/**\n * Turn a custom test into a test for a node that passes that test.\n *\n * @param {TestFunction} testFunction\n * @returns {Check}\n */\nfunction castFactory(testFunction) {\n return check\n\n /**\n * @this {unknown}\n * @type {Check}\n */\n function check(value, index, parent) {\n return Boolean(\n looksLikeANode(value) &&\n testFunction.call(\n this,\n value,\n typeof index === 'number' ? index : undefined,\n parent || undefined\n )\n )\n }\n}\n\nfunction ok() {\n return true\n}\n\n/**\n * @param {unknown} value\n * @returns {value is Node}\n */\nfunction looksLikeANode(value) {\n return value !== null && typeof value === 'object' && 'type' in value\n}\n","/**\n * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n/**\n * @typedef {(\n * Fn extends (value: any) => value is infer Thing\n * ? Thing\n * : Fallback\n * )} Predicate\n * Get the value of a type guard `Fn`.\n * @template Fn\n * Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n * Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n * Check extends null | undefined // No test.\n * ? Value\n * : Value extends {type: Check} // String (type) test.\n * ? Value\n * : Value extends Check // Partial test.\n * ? Value\n * : Check extends Function // Function test.\n * ? Predicate<Check, Value> extends Value\n * ? Predicate<Check, Value>\n * : never\n * : never // Some other test?\n * )} MatchesOne\n * Check whether a node matches a primitive check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n * Check extends ReadonlyArray<infer T>\n * ? MatchesOne<Value, T>\n * : Check extends Array<infer T>\n * ? MatchesOne<Value, T>\n * : MatchesOne<Value, Check>\n * )} Matches\n * Check whether a node matches a check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n * Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n * Increment a number in the type system.\n * @template {Uint} [I=0]\n * Index.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array<infer Children>}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Depth extends Max\n * ? never\n * :\n * | InternalParent<Node, Child>\n * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>\n * )} InternalAncestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {InternalAncestor<InclusiveDescendant<Tree>, Child>} Ancestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Tree extends UnistParent\n * ? Depth extends Max\n * ? Tree\n * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>\n * : Tree\n * )} InclusiveDescendant\n * Collect all (inclusive) descendants of `Tree`.\n *\n * > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n * > recurse without actually running into an infinite loop, which the\n * > previous version did.\n * >\n * > Practically, a max of `2` is typically enough assuming a `Root` is\n * > passed, but it doesn’t improve performance.\n * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n * > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n * Tree type.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {'skip' | boolean} Action\n * Union of the action types.\n *\n * @typedef {number} Index\n * Move to the sibling at `index` next (after node itself is completely\n * traversed).\n *\n * Useful if mutating the tree, such as removing the node the visitor is\n * currently on, or any of its previous siblings.\n * Results less than 0 or greater than or equal to `children.length` stop\n * traversing the parent.\n *\n * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple\n * List with one or two values, the first an action, the second an index.\n *\n * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult\n * Any value that can be returned from a visitor.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform the parent of node (the last of `ancestors`).\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of an ancestor still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Array<VisitedParents>} ancestors\n * Ancestors of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [VisitedParents=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @typedef {Visitor<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parents`.\n * @template {UnistNode} [Tree=UnistNode]\n * Tree type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {convert} from 'unist-util-is'\nimport {color} from 'unist-util-visit-parents/do-not-use-color'\n\n/** @type {Readonly<ActionTuple>} */\nconst empty = []\n\n/**\n * Continue traversing as normal.\n */\nexport const CONTINUE = true\n\n/**\n * Stop traversing immediately.\n */\nexport const EXIT = false\n\n/**\n * Do not traverse this node’s children.\n */\nexport const SKIP = 'skip'\n\n/**\n * Visit nodes, with ancestral information.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor<Tree, Check>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor<Tree>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Test} test\n * `unist-util-is`-compatible test\n * @param {Visitor | boolean | null | undefined} [visitor]\n * Handle each node.\n * @param {boolean | null | undefined} [reverse]\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visitParents(tree, test, visitor, reverse) {\n /** @type {Test} */\n let check\n\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n // @ts-expect-error no visitor given, so `visitor` is test.\n visitor = test\n } else {\n // @ts-expect-error visitor given, so `test` isn’t a visitor.\n check = test\n }\n\n const is = convert(check)\n const step = reverse ? -1 : 1\n\n factory(tree, undefined, [])()\n\n /**\n * @param {UnistNode} node\n * @param {number | undefined} index\n * @param {Array<UnistParent>} parents\n */\n function factory(node, index, parents) {\n const value = /** @type {Record<string, unknown>} */ (\n node && typeof node === 'object' ? node : {}\n )\n\n if (typeof value.type === 'string') {\n const name =\n // `hast`\n typeof value.tagName === 'string'\n ? value.tagName\n : // `xast`\n typeof value.name === 'string'\n ? value.name\n : undefined\n\n Object.defineProperty(visit, 'name', {\n value:\n 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'\n })\n }\n\n return visit\n\n function visit() {\n /** @type {Readonly<ActionTuple>} */\n let result = empty\n /** @type {Readonly<ActionTuple>} */\n let subresult\n /** @type {number} */\n let offset\n /** @type {Array<UnistParent>} */\n let grandparents\n\n if (!test || is(node, index, parents[parents.length - 1] || undefined)) {\n // @ts-expect-error: `visitor` is now a visitor.\n result = toResult(visitor(node, parents))\n\n if (result[0] === EXIT) {\n return result\n }\n }\n\n if ('children' in node && node.children) {\n const nodeAsParent = /** @type {UnistParent} */ (node)\n\n if (nodeAsParent.children && result[0] !== SKIP) {\n offset = (reverse ? nodeAsParent.children.length : -1) + step\n grandparents = parents.concat(nodeAsParent)\n\n while (offset > -1 && offset < nodeAsParent.children.length) {\n const child = nodeAsParent.children[offset]\n\n subresult = factory(child, offset, grandparents)()\n\n if (subresult[0] === EXIT) {\n return subresult\n }\n\n offset =\n typeof subresult[1] === 'number' ? subresult[1] : offset + step\n }\n }\n }\n\n return result\n }\n }\n}\n\n/**\n * Turn a return value into a clean result.\n *\n * @param {VisitorResult} value\n * Valid return values from visitors.\n * @returns {Readonly<ActionTuple>}\n * Clean result.\n */\nfunction toResult(value) {\n if (Array.isArray(value)) {\n return value\n }\n\n if (typeof value === 'number') {\n return [CONTINUE, value]\n }\n\n return value === null || value === undefined ? empty : [value]\n}\n","/**\n * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n * @import {VisitorResult} from 'unist-util-visit-parents'\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n// To do: use types from `unist-util-visit-parents` when it’s released.\n\n/**\n * @typedef {(\n * Fn extends (value: any) => value is infer Thing\n * ? Thing\n * : Fallback\n * )} Predicate\n * Get the value of a type guard `Fn`.\n * @template Fn\n * Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n * Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n * Check extends null | undefined // No test.\n * ? Value\n * : Value extends {type: Check} // String (type) test.\n * ? Value\n * : Value extends Check // Partial test.\n * ? Value\n * : Check extends Function // Function test.\n * ? Predicate<Check, Value> extends Value\n * ? Predicate<Check, Value>\n * : never\n * : never // Some other test?\n * )} MatchesOne\n * Check whether a node matches a primitive check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n * Check extends ReadonlyArray<any>\n * ? MatchesOne<Value, Check[number]>\n * : MatchesOne<Value, Check>\n * )} Matches\n * Check whether a node matches a check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n * Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n * Increment a number in the type system.\n * @template {Uint} [I=0]\n * Index.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array<infer Children>}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Depth extends Max\n * ? never\n * :\n * | InternalParent<Node, Child>\n * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>\n * )} InternalAncestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {(\n * Tree extends UnistParent\n * ? Depth extends Max\n * ? Tree\n * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>\n * : Tree\n * )} InclusiveDescendant\n * Collect all (inclusive) descendants of `Tree`.\n *\n * > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n * > recurse without actually running into an infinite loop, which the\n * > previous version did.\n * >\n * > Practically, a max of `2` is typically enough assuming a `Root` is\n * > passed, but it doesn’t improve performance.\n * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n * > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n * Tree type.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform `parent`.\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of `parent` still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends UnistNode ? number | undefined : never} index\n * Index of `node` in `parent`.\n * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent\n * Parent of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch\n * Build a typed `Visitor` function from a node and all possible parents.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Visited\n * Node type.\n * @template {UnistParent} Ancestor\n * Parent type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromMatch<\n * Matches<Descendant, Check>,\n * Extract<Descendant, UnistParent>\n * >\n * )} BuildVisitorFromDescendants\n * Build a typed `Visitor` function from a list of descendants and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Descendant\n * Node type.\n * @template {Test} Check\n * Test type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromDescendants<\n * InclusiveDescendant<Tree>,\n * Check\n * >\n * )} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} [Tree=UnistNode]\n * Node type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n\n/**\n * Visit nodes.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor<Tree, Check>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor<Tree>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Test} testOrVisitor\n * `unist-util-is`-compatible test (optional, omit to pass a visitor).\n * @param {Visitor | boolean | null | undefined} [visitorOrReverse]\n * Handle each node (when test is omitted, pass `reverse`).\n * @param {boolean | null | undefined} [maybeReverse=false]\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {\n /** @type {boolean | null | undefined} */\n let reverse\n /** @type {Test} */\n let test\n /** @type {Visitor} */\n let visitor\n\n if (\n typeof testOrVisitor === 'function' &&\n typeof visitorOrReverse !== 'function'\n ) {\n test = undefined\n visitor = testOrVisitor\n reverse = visitorOrReverse\n } else {\n // @ts-expect-error: assume the overload with test was given.\n test = testOrVisitor\n // @ts-expect-error: assume the overload with test was given.\n visitor = visitorOrReverse\n reverse = maybeReverse\n }\n\n visitParents(tree, test, overload, reverse)\n\n /**\n * @param {UnistNode} node\n * @param {Array<UnistParent>} parents\n */\n function overload(node, parents) {\n const parent = parents[parents.length - 1]\n const index = parent ? parent.children.indexOf(node) : undefined\n return visitor(node, index, parent)\n }\n}\n","import type { Decoration } from '@rcarls/rc-textarea';\n\nimport type { ActiveFormats, HeadingLevel } from './types.js';\n\n/**\n * Replaces the language token on the opening fence of the code block containing\n * `selectionStart`. Returns the updated string, or `null` if the cursor is not\n * inside a fenced code block.\n *\n * @param value - Full source editor value.\n * @param selectionStart - Cursor offset used to locate the containing fence.\n * @param language - Language string to write (empty string removes the token).\n */\nexport function setCodeBlockLanguage(\n value: string,\n selectionStart: number,\n language: string,\n): string | null {\n const before = value.slice(0, selectionStart);\n const fencePattern = /^```[^\\n]*(?:\\n|$)/gm;\n let openingFence: RegExpExecArray | null = null;\n let fenceMatch: RegExpExecArray | null;\n\n while ((fenceMatch = fencePattern.exec(before)) !== null) {\n openingFence = openingFence === null ? fenceMatch : null;\n }\n\n if (openingFence === null) {\n return null;\n }\n\n const fenceStart = openingFence.index;\n const newlineIndex = openingFence[0].indexOf('\\n');\n const fenceEnd = fenceStart + (newlineIndex === -1 ? openingFence[0].length : newlineIndex + 1);\n\n return value.slice(0, fenceStart) + '```' + language + '\\n' + value.slice(fenceEnd);\n}\n\n/**\n * Derives active inline and block formats from the decoration array at a given\n * selection range in the markdown source editor. Used for toolbar state sync in\n * source mode.\n */\nexport function getFormatsFromDecorations(\n decorations: readonly Decoration[],\n start: number,\n end: number,\n): Omit<ActiveFormats, 'codeLanguage'> {\n const marks = decorations.filter(\n (d): d is Extract<Decoration, { type: 'mark' }> =>\n d.type === 'mark' && d.from <= start && d.to >= end,\n );\n\n const headingMark = marks.find((d) => d.className?.startsWith('rme-heading-'));\n const headingLevel = headingMark?.className?.replace('rme-heading-', '') as\n | HeadingLevel\n | undefined;\n\n return {\n bold: marks.some((d) => d.bold),\n italic: marks.some((d) => d.italic),\n underline: marks.some((d) => d.className === 'rme-underline'),\n strikethrough: marks.some((d) => d.className === 'rme-strikethrough'),\n code: marks.some((d) => d.className === 'rme-code'),\n link: marks.some((d) => d.className === 'rme-link'),\n heading: headingLevel ?? null,\n blockquote: marks.some((d) => d.className === 'rme-blockquote'),\n bulletList: marks.some((d) => d.className === 'rme-list-bullet'),\n orderedList: marks.some((d) => d.className === 'rme-list-ordered'),\n codeBlock: marks.some((d) => d.className === 'rme-code-block'),\n };\n}\n","import { css } from 'lit';\n\nexport const rmeStyles = css`\n :host {\n position: relative;\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n }\n\n #rich-view {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n box-sizing: border-box;\n outline: none;\n /* Consumer themes via CSS custom properties */\n font-family: var(--rme-font-family, inherit);\n font-size: var(--rme-font-size, inherit);\n line-height: var(--rme-line-height, 1.6);\n padding: var(--rme-padding, 0.75em 1em);\n background: var(--rme-background, Canvas);\n color: var(--rme-color, CanvasText);\n border: var(--rme-border, 1px solid ButtonBorder);\n border-top: none;\n border-radius: var(--rme-border-radius, 0 0 4px 4px);\n }\n\n #rich-view:focus {\n outline: var(--rme-focus-outline, 2px solid Highlight);\n outline-offset: -2px;\n }\n\n #rich-view[hidden] {\n display: none;\n }\n\n /* Block-level spacing within the rich view */\n #rich-view > :first-child {\n margin-top: 0;\n }\n #rich-view > :last-child {\n margin-bottom: 0;\n }\n\n /* Source mode wrapper */\n #source-wrapper {\n flex: 1 1 auto;\n min-height: 0;\n display: flex;\n flex-direction: column;\n }\n\n #source-wrapper[hidden] {\n display: none;\n }\n\n #source-editor {\n flex: 1 1 auto;\n display: block;\n font-family: var(--rme-src-font-family, 'Cascadia Code', 'Fira Code', ui-monospace, monospace);\n --rc-textarea-border-radius: 0 0 4px 4px;\n --rc-textarea-border-top: none;\n }\n\n rc-editor-toolbar rc-toolbar {\n display: block;\n inline-size: 100%;\n --rc-toolbar-flex-wrap: wrap;\n --rc-toolbar-gap-inline: var(--rme-toolbar-gap, 1px);\n --rc-toolbar-padding-block: var(--rme-toolbar-padding, 4px);\n --rc-toolbar-padding-inline: var(--rme-toolbar-padding, 4px);\n --rc-toolbar-radius: var(--rme-toolbar-radius, 4px 4px 0 0);\n }\n\n rc-editor-toolbar rc-toolbar::part(root) {\n border: var(--rme-toolbar-border, 1px solid ButtonBorder);\n background: var(--rme-toolbar-background, Canvas);\n color: var(--rme-toolbar-color, CanvasText);\n }\n\n rc-editor-toolbar rc-button {\n --rc-button-bg: var(--rme-toolbar-button-background, transparent);\n --rc-button-color: var(--rme-toolbar-button-color, ButtonText);\n --rc-button-border: var(--rme-toolbar-button-border, 1px solid transparent);\n --rc-button-radius: var(--rme-toolbar-button-radius, 3px);\n --rc-button-block-size: var(--rme-toolbar-button-size, 2rem);\n --rc-button-icon-size: var(--rme-toolbar-button-size, 2rem);\n --rc-button-padding-block: 0;\n --rc-button-padding-inline: 0;\n --rc-button-font: inherit;\n --rc-button-state-layer-bg: currentColor;\n --rc-button-hover-state-layer-opacity: var(--rme-toolbar-button-hover-opacity, 0.08);\n --rc-button-focus-state-layer-opacity: var(--rme-toolbar-button-focus-opacity, 0.12);\n --rc-button-pressed-state-layer-opacity: var(--rme-toolbar-button-pressed-opacity, 0.12);\n }\n\n rc-editor-toolbar rc-button.toolbar-active {\n --rc-button-bg: var(--rme-toolbar-button-active-background, Highlight);\n --rc-button-color: var(--rme-toolbar-button-active-color, HighlightText);\n --rc-button-border: var(--rme-toolbar-button-active-border, 1px solid Highlight);\n }\n\n rc-editor-toolbar rc-button > button:focus-visible {\n outline: var(--rme-toolbar-focus-outline, 2px solid Highlight);\n outline-offset: var(--rme-toolbar-focus-outline-offset, 1px);\n }\n\n rc-editor-toolbar [data-rc-button-icon] svg {\n inline-size: 1.15em;\n block-size: 1.15em;\n flex-shrink: 0;\n }\n\n /* Heading select */\n rc-editor-toolbar rc-select {\n font-size: 0.8125em;\n --rc-select-padding-block: 0.25em;\n --rc-select-padding-inline: 0.35em;\n --rc-select-border: var(--rme-toolbar-select-border, 1px solid ButtonBorder);\n --rc-select-radius: var(--rme-toolbar-select-radius, 3px);\n }\n\n rc-editor-toolbar rc-select::part(trigger) {\n min-width: 0;\n background: var(--rme-toolbar-select-background, ButtonFace);\n color: var(--rme-toolbar-select-color, ButtonText);\n cursor: pointer;\n }\n\n rc-editor-toolbar rc-select::part(listbox) {\n border-radius: 3px;\n }\n\n rc-editor-toolbar rc-select.toolbar-active::part(trigger) {\n background: var(--rme-toolbar-select-active-background, Highlight);\n color: var(--rme-toolbar-select-active-color, HighlightText);\n border-color: var(--rme-toolbar-select-active-border-color, Highlight);\n }\n\n /* Code block language input */\n rc-editor-toolbar .lang-input {\n padding: 0.25em 0.5em;\n border: var(--rme-toolbar-input-border, 1px solid ButtonBorder);\n border-radius: var(--rme-toolbar-input-radius, 3px);\n background: var(--rme-toolbar-input-background, Field);\n color: var(--rme-toolbar-input-color, FieldText);\n font: inherit;\n font-size: 0.8125em;\n width: 8em;\n }\n\n rc-editor-toolbar .lang-input:focus {\n outline: var(--rme-toolbar-focus-outline, 2px solid Highlight);\n outline-offset: var(--rme-toolbar-focus-outline-offset, 1px);\n }\n\n rc-editor-toolbar .lang-input::placeholder {\n color: GrayText;\n }\n\n #rich-view a {\n cursor: pointer;\n text-decoration: underline;\n }\n\n #rich-view blockquote {\n margin: 0.5em 0;\n padding-left: 1em;\n border-left: 3px solid ButtonBorder;\n color: GrayText;\n }\n\n #rich-view pre {\n margin: 0.5em 0;\n padding: 0.65em 0.85em;\n background: Field;\n border: 1px solid ButtonBorder;\n border-radius: 4px;\n overflow-x: auto;\n }\n\n #rich-view pre code {\n font-family: 'Cascadia Code', 'Fira Code', ui-monospace, monospace;\n font-size: 0.875em;\n }\n\n #rich-view ul,\n #rich-view ol {\n margin: 0.5em 0;\n padding-left: 1.75em;\n }\n\n #rich-view li {\n margin: 0.2em 0;\n }\n\n .link-popover {\n position: absolute;\n z-index: 10;\n display: flex;\n align-items: center;\n gap: 2px;\n padding: 4px;\n background: Canvas;\n border: 1px solid ButtonBorder;\n border-radius: 4px;\n box-shadow: 0 2px 8px color-mix(in srgb, CanvasText 15%, transparent);\n }\n\n .link-popover-input {\n min-inline-size: 16em;\n padding: 0.25em 0.4em;\n border: 1px solid ButtonBorder;\n border-radius: 3px;\n background: Field;\n color: FieldText;\n font: inherit;\n font-size: 0.875em;\n }\n\n .link-popover-input:focus {\n outline: 2px solid Highlight;\n outline-offset: 1px;\n }\n\n .link-popover-btn {\n appearance: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-inline-size: 1.75rem;\n min-block-size: 1.75rem;\n padding: 0.15em;\n border: 1px solid transparent;\n border-radius: 3px;\n background: transparent;\n color: ButtonText;\n font: inherit;\n font-size: 0.875em;\n cursor: pointer;\n line-height: 1;\n }\n\n .link-popover-btn:hover:not(:disabled) {\n background: ButtonFace;\n border-color: ButtonBorder;\n }\n\n .link-popover-btn:focus-visible {\n outline: 2px solid Highlight;\n outline-offset: 1px;\n }\n\n .link-popover-btn:disabled {\n opacity: 0.4;\n cursor: default;\n }\n\n ::slotted(textarea) {\n display: none !important;\n }\n\n ::slotted(label) {\n display: block;\n margin-bottom: 0.25em;\n font-size: 0.875em;\n }\n`;\n","import { LitElement, html, nothing } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { micromark } from 'micromark';\nimport { gfmStrikethrough } from 'micromark-extension-gfm-strikethrough';\nimport TurndownService from 'turndown';\nimport { fromMarkdown } from 'mdast-util-from-markdown';\nimport { gfmStrikethroughFromMarkdown } from 'mdast-util-gfm-strikethrough';\nimport { visit } from 'unist-util-visit';\n\nimport type { RCTextarea, RCTextareaPluginAPI, DecorationInput } from '@rcarls/rc-textarea';\nimport type {\n ActiveFormats,\n EditorMode,\n EditorToolbarAction,\n EditorToolbarActionDetail,\n HeadingLevel,\n} from './types.js';\nimport { getFormatsFromDecorations, setCodeBlockLanguage } from './formatting.js';\n\nimport { rmeStyles } from './rc-markdown-editor.styles.js';\n\n// Syntax-highlight stylesheet for the source editor, injected into rc-textarea's\n// shadow via adoptStyleSheet. CSS custom properties inherit through the shadow\n// boundary so consumers can override individual colors.\nconst _sourceHighlightSheet = new CSSStyleSheet();\n\n_sourceHighlightSheet.replaceSync(`\n .rme-heading-h1,\n .rme-heading-h2,\n .rme-heading-h3,\n .rme-heading-h4,\n .rme-heading-h5,\n .rme-heading-h6 {\n color: var(--rme-src-heading-color, light-dark(#1d6fc4, #82b4f5));\n }\n\n .rme-code,\n .rme-code-block {\n color: var(--rme-src-code-color, light-dark(#c94a1a, #f09060));\n }\n\n .rme-link {\n color: var(--rme-src-link-color, light-dark(#0370b0, #60b8e8));\n }\n\n .rme-blockquote {\n color: var(--rme-src-blockquote-color, light-dark(#2d7a42, #70b880));\n }\n\n .rme-list-bullet,\n .rme-list-ordered {\n color: var(--rme-src-list-color, light-dark(#7a5c0a, #d4ac48));\n }\n\n .rme-strikethrough {\n text-decoration: line-through;\n color: var(--rme-src-dim-color, GrayText);\n }\n\n .rme-underline {\n text-decoration: underline;\n }\n`);\n\n// preserves <u> underline passthrough; renders ~~text~~ as <del>\nconst MICROMARK_OPTIONS = {\n allowDangerousHtml: true,\n extensions: [gfmStrikethrough()],\n};\n\nconst MDAST_OPTIONS = {\n extensions: [gfmStrikethrough()],\n mdastExtensions: [gfmStrikethroughFromMarkdown()],\n};\n\nconst SAFE_RICH_ELEMENTS = new Set([\n 'A',\n 'BLOCKQUOTE',\n 'BR',\n 'CODE',\n 'DEL',\n 'EM',\n 'H1',\n 'H2',\n 'H3',\n 'H4',\n 'H5',\n 'H6',\n 'HR',\n 'LI',\n 'OL',\n 'P',\n 'PRE',\n 'S',\n 'STRONG',\n 'U',\n 'UL',\n]);\n\nfunction isSafeLinkHref(href: string): boolean {\n const trimmed = href.trim();\n\n if (/^(?:#|\\/|\\.\\/|\\.\\.\\/)/.test(trimmed)) {\n return true;\n }\n\n try {\n const url = new URL(trimmed, document.baseURI);\n\n return url.protocol === 'http:' || url.protocol === 'https:' || url.protocol === 'mailto:';\n } catch {\n return false;\n }\n}\n\nfunction sanitizeRichMarkup(markup: string): string {\n const doc = new DOMParser().parseFromString(markup, 'text/html');\n\n for (const element of [...doc.body.querySelectorAll('*')]) {\n if (!SAFE_RICH_ELEMENTS.has(element.tagName)) {\n element.replaceWith(doc.createTextNode(element.textContent ?? ''));\n\n continue;\n }\n\n for (const attribute of [...element.attributes]) {\n const keepAttribute =\n (element.tagName === 'A' && attribute.name === 'href' && isSafeLinkHref(attribute.value)) ||\n (element.tagName === 'A' && attribute.name === 'title') ||\n (element.tagName === 'PRE' && attribute.name === 'data-lang');\n\n if (!keepAttribute) {\n element.removeAttribute(attribute.name);\n }\n }\n }\n\n return doc.body.innerHTML;\n}\n\nconst _turndown = new TurndownService({\n headingStyle: 'atx',\n bulletListMarker: '-',\n codeBlockStyle: 'fenced',\n fence: '```',\n emDelimiter: '*',\n strongDelimiter: '**',\n});\n\n_turndown.addRule('inlineCode', {\n filter: (node) => node.nodeName === 'CODE' && node.parentElement?.nodeName !== 'PRE',\n replacement: (content) => '`' + content + '`',\n});\n\n// Underline: preserve <u> as HTML (no markdown equivalent)\n_turndown.addRule('underline', {\n filter: ['u'],\n replacement: (content) => '<u>' + content + '</u>',\n});\n\n_turndown.addRule('strikethrough', {\n filter: (node) => ['S', 'DEL', 'STRIKE'].includes(node.nodeName),\n replacement: (content) => '~~' + content + '~~',\n});\n\n// Code blocks with language: read data-lang from <pre>, emit fenced block\n_turndown.addRule('codeBlockWithLang', {\n filter: (node) => node.nodeName === 'PRE' && !!node.querySelector('code'),\n replacement: (_content, node) => {\n const $pre = node as HTMLElement;\n const $code = $pre.querySelector('code');\n const lang = $pre.dataset['lang'] ?? '';\n\n return '\\n\\n```' + lang + '\\n' + ($code?.textContent ?? '') + '\\n```\\n\\n';\n },\n});\n\ntype PartialDecoration = Partial<Omit<DecorationInput, 'type' | 'from' | 'to'>>;\n\nconst DECORATION_MAP: Record<string, PartialDecoration> = {\n // className applied per depth in _setupSourcePlugin, not here\n heading: { bold: true },\n\n emphasis: { italic: true },\n strong: { bold: true },\n inlineCode: { className: 'rme-code' },\n link: { underline: 'solid', className: 'rme-link' },\n blockquote: { className: 'rme-blockquote' },\n\n // fenced code block (AST node.type === 'code')\n code: { className: 'rme-code-block' },\n\n // GFM ~~text~~ (AST node.type === 'delete')\n delete: { className: 'rme-strikethrough' },\n\n // list and html (underline) nodes are handled dynamically in _setupSourcePlugin\n};\n\n/**\n * Rich/source Markdown editor with a formatting toolbar, backed by rc-textarea.\n *\n * - **Rich mode (default)**: A `contenteditable` div shows micromark-rendered\n * HTML. DOM mutations are converted back to markdown via turndown and\n * written to the backing `<textarea>` for form participation.\n * - **Source mode**: An `<rc-textarea>` instance shows the markdown source\n * with live decorations. Toggle via `source-mode` attribute or Ctrl+Shift+S.\n *\n * Consumer markup follows the same progressive-enhancement contract as\n * `<rc-textarea>`:\n *\n * ```html\n * <rc-markdown-editor>\n * <label for=\"body\">Content</label>\n * <textarea id=\"body\" name=\"body\"></textarea>\n * </rc-markdown-editor>\n * ```\n *\n * @see {@link https://richardcarls.github.io/rc-webcomponents/components/rc-markdown-editor rc-markdown-editor docs}\n *\n * @slot - Accepts a native `<textarea>` element (and optional `<label>`) for form wiring.\n *\n * @fires rc-change - Value changed. Detail: `{ value: string }`.\n * @fires rc-mode-change - Mode toggled. Detail: `{ mode: EditorMode }`.\n * @fires rc-formatting-change - Active formats at cursor changed. Detail: `ActiveFormats`.\n *\n * @csspart toolbar - The `<rc-editor-toolbar>` element.\n * @csspart rich-view - The contenteditable rich-text view.\n *\n * @attr toolbar - Show the formatting toolbar.\n * @attr source-mode - Controlled: show the markdown source editor.\n * @attr default-source-mode - Uncontrolled initial source-mode state.\n * @attr read-only - Make the editor read-only.\n * @attr value - Current Markdown value.\n * @attr default-value - Initial uncontrolled Markdown value.\n *\n * @cssprop [--rme-font-family=inherit] - Font family of the rich-text view\n * @cssprop [--rme-font-size=inherit] - Font size of the rich-text view\n * @cssprop [--rme-line-height=1.6] - Line height of the rich-text view\n * @cssprop [--rme-padding=0.75em 1em] - Padding inside the rich-text view\n * @cssprop [--rme-background=Canvas] - Background color of the rich-text view\n * @cssprop [--rme-color=CanvasText] - Text color of the rich-text view\n * @cssprop [--rme-border=1px solid ButtonBorder] - Border around the rich-text view\n * @cssprop [--rme-border-radius=0 0 4px 4px] - Border radius of the rich-text view\n * @cssprop [--rme-focus-outline=2px solid Highlight] - Focus ring outline on the rich-text view\n * @cssprop [--rme-src-font-family='Cascadia Code', 'Fira Code', ui-monospace, monospace] - Font family of the source editor\n * @cssprop [--rme-toolbar-gap=1px] - Gap between toolbar buttons\n * @cssprop [--rme-toolbar-button-size=2rem] - Minimum inline and block size of toolbar buttons\n * @cssprop [--rme-src-heading-color=light-dark(#1d6fc4, #82b4f5)] - Source-mode heading token color\n * @cssprop [--rme-src-code-color=light-dark(#c94a1a, #f09060)] - Source-mode inline/fenced code token color\n * @cssprop [--rme-src-link-color=light-dark(#0370b0, #60b8e8)] - Source-mode link token color\n * @cssprop [--rme-src-blockquote-color=light-dark(#2d7a42, #70b880)] - Source-mode blockquote token color\n * @cssprop [--rme-src-list-color=light-dark(#7a5c0a, #d4ac48)] - Source-mode list marker token color\n * @cssprop [--rme-src-dim-color=GrayText] - Source-mode strikethrough token color\n */\nexport class RcMarkdownEditor extends LitElement {\n static override styles = rmeStyles;\n\n private _value: string | undefined;\n private _defaultValue = '';\n private _valueInitialized = false;\n\n /** Initial uncontrolled Markdown value. */\n @property({ type: String, attribute: 'default-value' })\n get defaultValue(): string {\n return this._defaultValue;\n }\n\n set defaultValue(v: string) {\n this._defaultValue = v;\n\n if (!this._valueInitialized) {\n this.requestUpdate('defaultValue');\n }\n }\n\n /** Current Markdown value. Host writes are silent. */\n @property({ type: String })\n get value(): string {\n return this._value ?? this._defaultValue;\n }\n\n set value(v: string) {\n const old = this._value;\n\n this._value = v;\n this._valueInitialized = true;\n\n if (old !== v) {\n this._syncNativeTextarea();\n this.requestUpdate('value', old);\n }\n }\n\n private _sourceMode: boolean | undefined;\n private _defaultSourceMode = false;\n private _sourceModeInitialized = false;\n\n /** Initial uncontrolled source-mode state. */\n @property({ type: Boolean, attribute: 'default-source-mode' })\n get defaultSourceMode(): boolean {\n return this._defaultSourceMode;\n }\n\n set defaultSourceMode(v: boolean) {\n const old = this._defaultSourceMode;\n\n this._defaultSourceMode = v;\n\n if (!this._sourceModeInitialized && this._sourceMode === undefined) {\n this.requestUpdate('defaultSourceMode', old);\n }\n }\n\n /**\n * Controlled: show the markdown source editor instead of the rich view.\n * Host writes are silent; toolbar/keyboard toggles dispatch `rc-mode-change`.\n */\n @property({ type: Boolean, reflect: true, attribute: 'source-mode' })\n get sourceMode(): boolean {\n return this._sourceMode ?? this._defaultSourceMode;\n }\n\n set sourceMode(v: boolean) {\n const old = this._sourceMode;\n\n this._sourceMode = v;\n this._sourceModeInitialized = true;\n this.requestUpdate('sourceMode', old);\n }\n\n /** Show the formatting toolbar. */\n @property({ type: Boolean, reflect: true }) toolbar = true;\n\n /** Make the editor read-only. */\n @property({ type: Boolean, reflect: true, attribute: 'read-only' }) readOnly = false;\n\n @query('#rich-view')\n protected _$richView!: HTMLDivElement;\n\n @query('#source-editor')\n protected _$sourceEditor!: RCTextarea;\n\n @query('rc-editor-toolbar')\n protected _$toolbar?: HTMLElement;\n\n protected _observer: MutationObserver | null = null;\n protected _$savedRange: Range | null = null;\n protected _activeFormats: ActiveFormats = {};\n protected _syncTimer: ReturnType<typeof setTimeout> | null = null;\n protected _pluginApi: RCTextareaPluginAPI | null = null;\n protected _ignoreRichMutations = false;\n protected _richViewRendered = false;\n protected _cachedTree: ReturnType<typeof fromMarkdown> | null = null;\n protected _renderedMode: EditorMode | null = null;\n\n // Lit calls updated() before firstUpdated() on the first cycle — guard\n // against mode switches before the initial content setup is done.\n protected _firstUpdatedDone = false;\n\n @query('.link-popover')\n protected _$linkPopover?: HTMLDivElement;\n\n @query('.link-popover-input')\n protected _$linkPopoverInput?: HTMLInputElement;\n\n @state()\n protected _linkPopoverOpen = false;\n\n @state()\n protected _linkPopoverHref = '';\n\n override connectedCallback() {\n super.connectedCallback();\n document.addEventListener('selectionchange', this._onSelectionChange);\n document.addEventListener('click', this._onDocumentClick);\n this.addEventListener('keydown', this._onKeyDown);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n document.removeEventListener('selectionchange', this._onSelectionChange);\n document.removeEventListener('click', this._onDocumentClick);\n this.removeEventListener('keydown', this._onKeyDown);\n this._$richView?.removeEventListener('click', this._onRichViewClick);\n this._observer?.disconnect();\n\n if (this._syncTimer !== null) {\n clearTimeout(this._syncTimer);\n }\n }\n\n override firstUpdated() {\n // Read initial value from the slotted textarea BEFORE syncing it back.\n // Without this, _syncNativeTextarea() overwrites the authored content\n // with an empty string (the unset defaultValue).\n if (!this._valueInitialized) {\n const $textarea = this.querySelector<HTMLTextAreaElement>('textarea');\n\n if ($textarea?.value) {\n this._defaultValue = $textarea.value;\n }\n }\n\n this._observer = new MutationObserver(() => {\n if (!this._ignoreRichMutations) {\n this._scheduleMarkdownSync();\n }\n });\n\n this._observer.observe(this._$richView, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n\n this._$richView.addEventListener('click', this._onRichViewClick);\n this._setupSourcePlugin();\n\n // firstUpdated() handles the initial mode directly so updated() does not\n // switch modes on the first cycle.\n if (this.sourceMode) {\n this._$sourceEditor.value = this.value;\n } else {\n this._setRichViewContent(this.value);\n }\n\n this._renderedMode = this.sourceMode ? 'source' : 'rich';\n\n this._syncNativeTextarea();\n this._connectLabel();\n this._firstUpdatedDone = true;\n }\n\n override updated(changed: Map<string, unknown>) {\n if (changed.has('sourceMode') || changed.has('defaultSourceMode')) {\n if (this._firstUpdatedDone) {\n const nextMode: EditorMode = this.sourceMode ? 'source' : 'rich';\n\n if (nextMode !== this._renderedMode) {\n if (nextMode === 'source') {\n this._switchToSource();\n } else {\n this._switchToRich();\n }\n\n this._renderedMode = nextMode;\n }\n }\n\n // Keep source-button aria-pressed in sync for programmatic mode changes.\n this._pushToolbarState();\n }\n\n if (changed.has('value') && !this.sourceMode && this._richViewRendered) {\n this._setRichViewContent(this.value);\n }\n\n if (changed.has('_linkPopoverOpen') && this._linkPopoverOpen) {\n this._positionLinkPopover();\n this._$linkPopoverInput?.focus();\n this._$linkPopoverInput?.select();\n }\n }\n\n override render() {\n return html`\n <slot></slot>\n\n ${this.toolbar\n ? html`<rc-editor-toolbar\n part=\"toolbar\"\n @rc-toolbar-action=${this._onToolbarAction}\n ></rc-editor-toolbar>`\n : nothing}\n\n <div\n id=\"rich-view\"\n part=\"rich-view\"\n contenteditable=${this.readOnly ? 'false' : 'true'}\n role=\"textbox\"\n aria-multiline=\"true\"\n spellcheck=\"true\"\n ?hidden=${this.sourceMode}\n ></div>\n\n <div id=\"source-wrapper\" ?hidden=${!this.sourceMode}>\n <rc-textarea\n id=\"source-editor\"\n word-wrap\n ?read-only=${this.readOnly}\n @rc-change=${this._onSourceChange}\n ></rc-textarea>\n </div>\n\n ${this._linkPopoverOpen\n ? html`\n <div class=\"link-popover\" role=\"dialog\" aria-label=\"Link\">\n <input\n type=\"url\"\n class=\"link-popover-input\"\n .value=${this._linkPopoverHref}\n placeholder=\"https://\"\n aria-label=\"URL\"\n @input=${(e: Event) => {\n this._linkPopoverHref = (e.target as HTMLInputElement).value;\n }}\n @keydown=${this._onLinkPopoverKeyDown}\n />\n <button\n type=\"button\"\n class=\"link-popover-btn\"\n title=\"Apply (Enter)\"\n @click=${this._applyLink}\n >\n ↵\n </button>\n <button\n type=\"button\"\n class=\"link-popover-btn\"\n title=\"Open link\"\n ?disabled=${!this._linkPopoverHref}\n @click=${this._openLinkHref}\n >\n ↗\n </button>\n <button\n type=\"button\"\n class=\"link-popover-btn\"\n title=\"Remove link\"\n @click=${this._removeLink}\n >\n ✕\n </button>\n </div>\n `\n : nothing}\n `;\n }\n\n protected _setRichViewContent(markdown: string) {\n if (!this._$richView) {\n return;\n }\n\n this._ignoreRichMutations = true;\n this._$richView.innerHTML = this._renderMarkdown(markdown);\n this._ignoreRichMutations = false;\n this._richViewRendered = true;\n }\n\n protected _renderMarkdown(markdown: string): string {\n const markup = micromark(markdown, MICROMARK_OPTIONS);\n const tree = fromMarkdown(markdown, MDAST_OPTIONS);\n const langs: (string | null)[] = [];\n\n visit(tree, 'code', (node: { lang?: string | null }) => {\n langs.push(node.lang ?? null);\n });\n\n if (langs.length === 0) {\n return sanitizeRichMarkup(markup);\n }\n\n const doc = new DOMParser().parseFromString(markup, 'text/html');\n const $pres = doc.querySelectorAll('pre');\n\n langs.forEach((lang, i) => {\n if ($pres[i] && lang) {\n $pres[i].dataset['lang'] = lang;\n }\n });\n\n return sanitizeRichMarkup(doc.body.innerHTML);\n }\n\n protected _scheduleMarkdownSync() {\n if (this.sourceMode) {\n return;\n }\n\n if (this._syncTimer !== null) {\n clearTimeout(this._syncTimer);\n }\n\n this._syncTimer = setTimeout(() => {\n this._syncMarkdownFromRichView();\n this._syncTimer = null;\n }, 150);\n }\n\n protected _syncMarkdownFromRichView() {\n if (!this._$richView || this.sourceMode) {\n return;\n }\n\n const md = _turndown.turndown(this._$richView.innerHTML);\n\n if (md === this.value) {\n return;\n }\n\n this._value = md;\n this._syncNativeTextarea();\n this._dispatchChange(md);\n }\n\n protected _switchToSource() {\n if (!this._$richView || !this._$sourceEditor) {\n return;\n }\n\n // Flush any pending rich-view sync. _syncMarkdownFromRichView() guards on\n // `this.sourceMode`, which is already `true` by the time updated() calls\n // this method, so it would bail immediately — inline the flush instead.\n if (this._syncTimer !== null) {\n clearTimeout(this._syncTimer);\n this._syncTimer = null;\n\n const md = _turndown.turndown(this._$richView.innerHTML);\n\n if (md !== this.value) {\n this._value = md;\n this._syncNativeTextarea();\n this._dispatchChange(md);\n }\n }\n\n this._$sourceEditor.value = this.value;\n // Reset undo history so the first Ctrl+Z undoes to the pre-edit state\n // rather than to the end of a previous source-mode session.\n this._$sourceEditor.clearHistory();\n }\n\n protected _switchToRich() {\n if (!this._$richView) {\n return;\n }\n\n const md = this._$sourceEditor?.value ?? this.value;\n\n this._value = md;\n this._setRichViewContent(md);\n this._syncNativeTextarea();\n }\n\n protected _setupSourcePlugin() {\n this._$sourceEditor.usePlugin({\n mount: (api: RCTextareaPluginAPI) => {\n this._pluginApi = api;\n api.adoptStyleSheet(_sourceHighlightSheet);\n\n api.onCursorMove((start: number, end: number) => {\n if (!this.sourceMode) {\n return;\n }\n\n const formats = getFormatsFromDecorations(api.getDecorations(), start, end);\n const lang =\n formats.codeBlock && this._cachedTree\n ? this._getCodeBlockLanguage(this._cachedTree, start)\n : null;\n\n this._activeFormats = { ...formats, codeLanguage: lang };\n this._pushToolbarState();\n });\n },\n destroy: () => {\n this._pluginApi = null;\n this._cachedTree = null;\n },\n update: (value: string, api: RCTextareaPluginAPI) => {\n const tree = fromMarkdown(value, MDAST_OPTIONS);\n const decorations: DecorationInput[] = [];\n\n this._cachedTree = tree;\n\n visit(\n tree,\n (node: {\n type: string;\n depth?: number;\n ordered?: boolean | null;\n position?: { start: { offset?: number }; end: { offset?: number } };\n }) => {\n const from = node.position?.start.offset;\n const to = node.position?.end.offset;\n\n if (from === undefined || to === undefined) {\n return;\n }\n\n if (node.type === 'list') {\n decorations.push({\n type: 'mark',\n from,\n to,\n className: node.ordered ? 'rme-list-ordered' : 'rme-list-bullet',\n } as DecorationInput);\n\n return;\n }\n\n const style = DECORATION_MAP[node.type];\n\n if (!style) {\n return;\n }\n\n const dec: DecorationInput = { type: 'mark', from, to, ...style };\n\n if (node.type === 'heading' && node.depth) {\n dec.className = `rme-heading-h${node.depth}`;\n }\n\n decorations.push(dec);\n },\n );\n\n api.setDecorations(decorations);\n },\n });\n }\n\n protected _getCodeBlockLanguage(\n tree: ReturnType<typeof fromMarkdown>,\n offset: number,\n ): string | null {\n let lang: string | null = null;\n\n visit(\n tree,\n 'code',\n (node: {\n lang?: string | null;\n position?: { start: { offset?: number }; end: { offset?: number } };\n }) => {\n const from = node.position?.start.offset;\n const to = node.position?.end.offset;\n\n if (from !== undefined && to !== undefined && from <= offset && to >= offset) {\n lang = node.lang ?? '';\n }\n },\n );\n\n return lang;\n }\n\n protected _onSourceChange = (_e: Event) => {\n // The hidden source editor may emit while it initializes. Only the active\n // source surface is allowed to become the Markdown value; otherwise an\n // empty initialization event can erase controlled rich-view content.\n if (!this.sourceMode) {\n return;\n }\n\n const md = this._$sourceEditor?.value ?? '';\n\n if (md === this.value) {\n return;\n }\n\n this._value = md;\n this._syncNativeTextarea();\n this._dispatchChange(md);\n };\n\n protected _onToolbarAction = (e: CustomEvent<EditorToolbarActionDetail>) => {\n const { action, headingLevel, codeLanguage } = e.detail;\n\n if (action === 'source') {\n const nextSourceMode = !this.sourceMode;\n\n this.sourceMode = nextSourceMode;\n this._dispatchModeChange(nextSourceMode ? 'source' : 'rich');\n\n return;\n }\n\n if (action === 'code-block-language') {\n if (this.sourceMode) {\n this._setSourceCodeBlockLanguage(codeLanguage ?? '');\n } else {\n this._setRichCodeBlockLanguage(codeLanguage ?? '');\n }\n\n return;\n }\n\n if (action === 'heading' && headingLevel !== undefined) {\n if (this.sourceMode) {\n this._setSourceHeadingLevel(headingLevel);\n } else {\n document.execCommand('formatBlock', false, headingLevel ?? 'p');\n }\n\n return;\n }\n\n if (this.sourceMode) {\n this._applySourceFormat(action);\n } else {\n this._applyRichFormat(action);\n }\n };\n\n protected _applyRichFormat(action: EditorToolbarAction) {\n if (this.readOnly || !this._$richView) {\n return;\n }\n\n // Restore saved selection before applying command (toolbar click stole focus)\n this._$richView.focus();\n\n if (this._$savedRange) {\n const sel = window.getSelection();\n\n if (sel) {\n sel.removeAllRanges();\n sel.addRange(this._$savedRange.cloneRange());\n }\n }\n\n // For character-scope actions, expand a collapsed cursor to the word at cursor\n const CHAR_SCOPE = new Set<EditorToolbarAction>([\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n 'code',\n 'link',\n ]);\n\n if (CHAR_SCOPE.has(action)) {\n this._expandRichSelectionToWord();\n\n const sel = window.getSelection();\n\n if (sel?.rangeCount) {\n this._$savedRange = sel.getRangeAt(0).cloneRange();\n }\n }\n\n switch (action) {\n case 'bold':\n document.execCommand('bold');\n break;\n case 'italic':\n document.execCommand('italic');\n break;\n case 'underline':\n document.execCommand('underline');\n break;\n case 'strikethrough':\n this._wrapRichSelection('s');\n break;\n case 'code':\n this._wrapRichSelection('code');\n break;\n\n case 'blockquote': {\n const newTag = this._activeFormats.blockquote ? 'p' : 'blockquote';\n\n document.execCommand('formatBlock', false, newTag);\n break;\n }\n\n case 'bullet-list':\n document.execCommand('insertUnorderedList');\n break;\n case 'ordered-list':\n document.execCommand('insertOrderedList');\n break;\n case 'code-block':\n this._toggleRichCodeBlock();\n break;\n\n case 'link': {\n const sel = window.getSelection();\n const $anchor = sel?.rangeCount ? sel.getRangeAt(0).commonAncestorContainer : null;\n const $el = $anchor\n ? $anchor.nodeType === Node.TEXT_NODE\n ? ($anchor as Text).parentElement\n : ($anchor as Element)\n : null;\n\n this._linkPopoverHref = $el?.closest<HTMLAnchorElement>('a[href]')?.href ?? '';\n this._linkPopoverOpen = true;\n break;\n }\n }\n }\n\n protected _applySourceFormat(action: EditorToolbarAction) {\n const editor = this._$sourceEditor;\n const api = this._pluginApi;\n\n if (!editor) {\n return;\n }\n\n // For character-scope wraps with a collapsed cursor, expand to word at cursor\n const WORD_WRAP: Partial<Record<EditorToolbarAction, [string, string]>> = {\n bold: ['**', '**'],\n italic: ['*', '*'],\n strikethrough: ['~~', '~~'],\n code: ['`', '`'],\n };\n const wrap = WORD_WRAP[action];\n\n if (wrap && api && api.selectionStart === api.selectionEnd) {\n const wordInfo = api.getWordAtCursor();\n\n if (wordInfo) {\n const [pre, suf] = wrap;\n\n editor.value =\n api.value.slice(0, wordInfo.from) +\n pre +\n wordInfo.word +\n suf +\n api.value.slice(wordInfo.to);\n\n return;\n }\n }\n\n switch (action) {\n case 'bold':\n editor.wrapSelection('**', '**');\n break;\n case 'italic':\n editor.wrapSelection('*', '*');\n break;\n case 'underline':\n editor.wrapSelection('<u>', '</u>');\n break;\n case 'strikethrough':\n editor.wrapSelection('~~', '~~');\n break;\n case 'code':\n editor.wrapSelection('`', '`');\n break;\n case 'link':\n editor.replaceSelection('[](url)');\n break;\n case 'blockquote':\n this._toggleLinePrefix('> ');\n break;\n case 'bullet-list':\n this._toggleLinePrefix('- ');\n break;\n case 'ordered-list':\n this._toggleLinePrefix('1. ');\n break;\n case 'code-block':\n this._toggleSourceCodeFence();\n break;\n }\n }\n\n /** Sets the heading level on the cursor's line in source mode. null = paragraph. */\n protected _setSourceHeadingLevel(level: HeadingLevel | null) {\n const api = this._pluginApi;\n const editor = this._$sourceEditor;\n\n if (!api || !editor) {\n return;\n }\n\n const { value, selectionStart } = api;\n const lineStart = value.lastIndexOf('\\n', selectionStart - 1) + 1;\n\n const stripped = value.slice(lineStart).replace(/^#{1,6} /, '');\n const prefix = level ? '#'.repeat(parseInt(level[1]!)) + ' ' : '';\n\n editor.value =\n value.slice(0, lineStart) +\n prefix +\n stripped +\n value.slice(lineStart + (value.slice(lineStart).length - stripped.length));\n }\n\n /** Updates the language of the code block at the cursor in source mode. */\n protected _setSourceCodeBlockLanguage(lang: string) {\n const api = this._pluginApi;\n const editor = this._$sourceEditor;\n\n if (!api || !editor) {\n return;\n }\n\n const nextValue = setCodeBlockLanguage(api.value, api.selectionStart, lang);\n\n if (nextValue === null) {\n return;\n }\n\n editor.value = nextValue;\n }\n\n /** Updates the `data-lang` attribute on the `<pre>` at the cursor in rich mode. */\n protected _setRichCodeBlockLanguage(lang: string) {\n const sel = window.getSelection();\n\n if (!sel || sel.rangeCount === 0) {\n return;\n }\n\n const $anchor = sel.getRangeAt(0).commonAncestorContainer;\n const $el: Element | null =\n $anchor.nodeType === Node.TEXT_NODE ? ($anchor as Text).parentElement : ($anchor as Element);\n\n const $pre = $el?.closest('pre');\n\n if (!$pre) {\n return;\n }\n\n if (lang) {\n $pre.dataset['lang'] = lang;\n } else {\n delete $pre.dataset['lang'];\n }\n }\n\n /** Toggles a line prefix (e.g. `'> '`, `'- '`) on the cursor's line. */\n protected _toggleLinePrefix(prefix: string) {\n const api = this._pluginApi;\n const editor = this._$sourceEditor;\n\n if (!api || !editor) {\n return;\n }\n\n const { value, selectionStart } = api;\n const lineStart = value.lastIndexOf('\\n', selectionStart - 1) + 1;\n\n if (value.startsWith(prefix, lineStart)) {\n editor.value = value.slice(0, lineStart) + value.slice(lineStart + prefix.length);\n } else {\n editor.value = value.slice(0, lineStart) + prefix + value.slice(lineStart);\n }\n }\n\n /** Wraps the current selection (or cursor line) with a fenced code block. */\n protected _toggleSourceCodeFence() {\n const api = this._pluginApi;\n const editor = this._$sourceEditor;\n\n if (!api || !editor) {\n return;\n }\n\n const { value, selectionStart, selectionEnd } = api;\n const fence = '```';\n\n const lineStart = value.lastIndexOf('\\n', selectionStart - 1) + 1;\n const lineEndIdx = value.indexOf('\\n', selectionEnd);\n const lineEnd = lineEndIdx === -1 ? value.length : lineEndIdx;\n\n const prevNewline = value.lastIndexOf('\\n', lineStart - 2);\n const prevLine = prevNewline === -1 ? '' : value.slice(prevNewline + 1, lineStart - 1);\n const afterEnd = lineEnd + 1;\n const nextNewline = value.indexOf('\\n', afterEnd);\n const nextLine = value.slice(afterEnd, nextNewline === -1 ? undefined : nextNewline);\n\n if (prevLine.trim() === fence && nextLine.trim() === fence) {\n const unwrapStart = prevNewline === -1 ? 0 : prevNewline + 1;\n const unwrapEnd = nextNewline === -1 ? value.length : nextNewline + 1;\n const inner = value.slice(lineStart, lineEnd);\n\n editor.value = value.slice(0, unwrapStart) + inner + '\\n' + value.slice(unwrapEnd);\n\n return;\n }\n\n const selected = value.slice(lineStart, lineEnd);\n\n editor.value =\n value.slice(0, lineStart) + fence + '\\n' + selected + '\\n' + fence + value.slice(lineEnd);\n }\n\n protected _wrapRichSelection(tag: string) {\n const sel = window.getSelection();\n\n if (!sel || sel.rangeCount === 0) {\n return;\n }\n\n const range = sel.getRangeAt(0);\n\n if (range.collapsed) {\n return;\n }\n\n const $el = document.createElement(tag);\n\n try {\n range.surroundContents($el);\n } catch {\n // surroundContents fails when the range partially overlaps existing elements\n const fragment = range.extractContents();\n\n $el.appendChild(fragment);\n range.insertNode($el);\n }\n\n sel.removeAllRanges();\n sel.addRange(range);\n }\n\n protected _toggleRichCodeBlock() {\n const sel = window.getSelection();\n\n if (!sel || sel.rangeCount === 0) {\n return;\n }\n\n const range = sel.getRangeAt(0);\n const $anchor = range.commonAncestorContainer;\n const $el: Element | null =\n $anchor.nodeType === Node.TEXT_NODE ? ($anchor as Text).parentElement : ($anchor as Element);\n\n const $existingPre = $el?.closest('pre');\n\n if ($existingPre) {\n const $p = document.createElement('p');\n\n $p.textContent = $existingPre.textContent ?? '';\n $existingPre.replaceWith($p);\n\n const unwrapRange = document.createRange();\n\n unwrapRange.selectNodeContents($p);\n unwrapRange.collapse(false);\n sel.removeAllRanges();\n sel.addRange(unwrapRange);\n\n return;\n }\n\n const $pre = document.createElement('pre');\n const $code = document.createElement('code');\n\n $pre.appendChild($code);\n\n try {\n const fragment = range.extractContents();\n\n $code.appendChild(fragment);\n range.insertNode($pre);\n } catch {\n if ($el && $el !== this._$richView) {\n $code.textContent = $el.textContent ?? '';\n $el.replaceWith($pre);\n }\n }\n\n // insertNode leaves the selection spanning <pre>; collapse cursor into <code>\n // so the next keystroke types inside the block rather than replacing it.\n const innerRange = document.createRange();\n\n innerRange.selectNodeContents($code);\n innerRange.collapse(false);\n sel.removeAllRanges();\n sel.addRange(innerRange);\n }\n\n protected _onKeyDown = (e: KeyboardEvent) => {\n if (!e.ctrlKey && !e.metaKey) {\n return;\n }\n\n if (e.shiftKey && e.key === 'S') {\n e.preventDefault();\n\n const nextSourceMode = !this.sourceMode;\n\n this.sourceMode = nextSourceMode;\n this._dispatchModeChange(nextSourceMode ? 'source' : 'rich');\n\n return;\n }\n\n if (e.shiftKey) {\n return;\n }\n\n let action: EditorToolbarAction | null = null;\n\n switch (e.key) {\n case 'b':\n action = 'bold';\n break;\n case 'i':\n action = 'italic';\n break;\n case 'u':\n action = 'underline';\n break;\n case '`':\n action = 'code';\n break;\n case 'k':\n action = 'link';\n break;\n }\n\n if (action) {\n e.preventDefault();\n\n if (this.sourceMode) {\n this._applySourceFormat(action);\n } else {\n this._applyRichFormat(action);\n }\n }\n };\n\n protected _onSelectionChange = () => {\n // Chrome shadow-adjusts window.getSelection() to the nearest light-DOM ancestor\n // for selections inside a shadow root — use shadowRoot.getSelection() when available.\n const sel =\n (this.shadowRoot as unknown as { getSelection?: () => Selection | null }).getSelection?.() ??\n window.getSelection();\n\n if (!sel || sel.rangeCount === 0) {\n return;\n }\n\n const range = sel.getRangeAt(0);\n const $anchor = range.commonAncestorContainer;\n const $el: Element | null =\n $anchor.nodeType === Node.TEXT_NODE ? ($anchor as Text).parentElement : ($anchor as Element);\n\n if (!this._$richView?.contains($el)) {\n return;\n }\n\n this._$savedRange = range.cloneRange();\n\n if (this.sourceMode) {\n return;\n }\n\n const $pre = $el?.closest('pre');\n\n this._activeFormats = {\n bold: !!$el?.closest('strong, b'),\n italic: !!$el?.closest('em, i'),\n underline: !!$el?.closest('u'),\n strikethrough: !!$el?.closest('s, del, strike'),\n code: !$pre && !!$el?.closest('code'),\n link: !!$el?.closest('a'),\n heading: ($el?.closest('h1,h2,h3,h4,h5,h6')?.tagName.toLowerCase() ??\n null) as HeadingLevel | null,\n blockquote: !!$el?.closest('blockquote'),\n bulletList: !!$el?.closest('ul'),\n orderedList: !!$el?.closest('ol'),\n codeBlock: !!$pre,\n codeLanguage: $pre ? ($pre.dataset['lang'] ?? '') : null,\n };\n\n this._pushToolbarState();\n };\n\n protected _pushToolbarState() {\n const $toolbar = this._$toolbar as\n | (HTMLElement & {\n activeBold?: boolean;\n activeItalic?: boolean;\n activeUnderline?: boolean;\n activeStrikethrough?: boolean;\n activeCode?: boolean;\n activeLink?: boolean;\n activeHeading?: HeadingLevel | null;\n activeBlockquote?: boolean;\n activeBulletList?: boolean;\n activeOrderedList?: boolean;\n activeCodeBlock?: boolean;\n codeLanguage?: string | null;\n sourceMode?: boolean;\n })\n | undefined;\n\n if ($toolbar) {\n $toolbar.activeBold = !!this._activeFormats.bold;\n $toolbar.activeItalic = !!this._activeFormats.italic;\n $toolbar.activeUnderline = !!this._activeFormats.underline;\n $toolbar.activeStrikethrough = !!this._activeFormats.strikethrough;\n $toolbar.activeCode = !!this._activeFormats.code;\n $toolbar.activeLink = !!this._activeFormats.link;\n $toolbar.activeHeading = this._activeFormats.heading ?? null;\n $toolbar.activeBlockquote = !!this._activeFormats.blockquote;\n $toolbar.activeBulletList = !!this._activeFormats.bulletList;\n $toolbar.activeOrderedList = !!this._activeFormats.orderedList;\n $toolbar.activeCodeBlock = !!this._activeFormats.codeBlock;\n $toolbar.codeLanguage = this._activeFormats.codeLanguage ?? null;\n $toolbar.sourceMode = this.sourceMode;\n }\n\n this.dispatchEvent(\n new CustomEvent<ActiveFormats>('rc-formatting-change', {\n bubbles: true,\n composed: true,\n detail: { ...this._activeFormats },\n }),\n );\n }\n\n protected _syncNativeTextarea() {\n const $textarea = this.querySelector<HTMLTextAreaElement>('textarea');\n\n if ($textarea) {\n $textarea.value = this.value;\n }\n }\n\n protected _connectLabel() {\n const $textarea = this.querySelector<HTMLTextAreaElement>('textarea');\n\n if (!$textarea) {\n return;\n }\n\n // Mirror label text to the rich view for accessibility\n const $label = $textarea.id\n ? this.querySelector<HTMLLabelElement>(`label[for=\"${CSS.escape($textarea.id)}\"]`)\n : null;\n\n if ($label && this._$richView) {\n this._$richView.setAttribute('aria-label', $label.textContent?.trim() ?? '');\n }\n\n // Forward label click to the active editor surface\n $label?.addEventListener('click', () => {\n if (this.sourceMode) {\n this._$sourceEditor?.focus();\n } else {\n this._$richView?.focus();\n }\n });\n }\n\n protected _onRichViewClick = (e: MouseEvent) => {\n if (!e.ctrlKey && !e.metaKey) {\n return;\n }\n\n const $a = (e.target as Element).closest<HTMLAnchorElement>('a[href]');\n\n if (!$a) {\n return;\n }\n\n e.preventDefault();\n window.open($a.href, '_blank', 'noopener,noreferrer');\n };\n\n protected _onDocumentClick = (e: MouseEvent) => {\n if (!this._linkPopoverOpen) {\n return;\n }\n\n const $popover = this.shadowRoot?.querySelector('.link-popover');\n\n if ($popover && e.composedPath().includes($popover)) {\n return;\n }\n\n this._linkPopoverOpen = false;\n };\n\n protected _expandRichSelectionToWord(): void {\n const sel = window.getSelection();\n\n if (!sel?.isCollapsed) {\n return;\n }\n\n const modify = (\n sel as unknown as { modify?: (alter: string, dir: string, unit: string) => void }\n ).modify;\n\n if (typeof modify !== 'function') {\n return;\n }\n\n modify.call(sel, 'move', 'backward', 'word');\n modify.call(sel, 'extend', 'forward', 'word');\n }\n\n protected _positionLinkPopover(): void {\n if (!this._$savedRange || !this._$linkPopover) {\n return;\n }\n\n const rangeRect = this._$savedRange.getBoundingClientRect();\n const hostRect = this.getBoundingClientRect();\n\n this._$linkPopover.style.top = `${rangeRect.bottom - hostRect.top + 4}px`;\n this._$linkPopover.style.left = `${Math.max(0, rangeRect.left - hostRect.left)}px`;\n }\n\n protected _applyLink = () => {\n this._linkPopoverOpen = false;\n\n if (!this._linkPopoverHref) {\n return;\n }\n\n this._$richView?.focus();\n\n if (this._$savedRange) {\n const sel = window.getSelection();\n\n if (sel) {\n sel.removeAllRanges();\n sel.addRange(this._$savedRange.cloneRange());\n }\n }\n\n document.execCommand('createLink', false, this._linkPopoverHref);\n };\n\n protected _removeLink = () => {\n this._linkPopoverOpen = false;\n this._$richView?.focus();\n\n if (this._$savedRange) {\n const sel = window.getSelection();\n\n if (sel) {\n sel.removeAllRanges();\n sel.addRange(this._$savedRange.cloneRange());\n }\n }\n\n document.execCommand('unlink');\n };\n\n protected _openLinkHref = () => {\n if (this._linkPopoverHref) {\n window.open(this._linkPopoverHref, '_blank', 'noopener,noreferrer');\n }\n };\n\n protected _onLinkPopoverKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n this._applyLink();\n } else if (e.key === 'Escape') {\n this._linkPopoverOpen = false;\n this._$richView?.focus();\n }\n };\n\n protected _dispatchChange(value: string) {\n this.dispatchEvent(\n new CustomEvent<{ value: string }>('rc-change', {\n bubbles: true,\n composed: true,\n detail: { value },\n }),\n );\n }\n\n protected _dispatchModeChange(mode: EditorMode) {\n this.dispatchEvent(\n new CustomEvent<{ mode: EditorMode }>('rc-mode-change', {\n bubbles: true,\n composed: true,\n detail: { mode },\n }),\n );\n }\n}\n","/**\n * Bootstrap Icons v1.x (MIT) used for `<rc-editor-toolbar>`.\n * Icons source: https://icons.getbootstrap.com/\n * License: MIT — https://github.com/twbs/icons/blob/main/LICENSE\n *\n * All icons use `currentColor` so they inherit button text colour,\n * including forced-colours mode. ViewBox is 0 0 16 16; rendered at\n * 1em so they scale with the button's font-size.\n */\n\nimport { svg, type SVGTemplateResult } from 'lit';\n\nconst icon = (content: SVGTemplateResult) => svg`\n <svg\n viewBox=\"0 0 16 16\"\n width=\"1em\"\n height=\"1em\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >${content}</svg>\n`;\n\nexport const icons = {\n bold: icon(svg`\n <path fill=\"currentColor\" d=\"M8.21 13c2.106 0 3.412-1.087 3.412-2.823c0-1.306-.984-2.283-2.324-2.386v-.055a2.176 2.176 0 0 0 1.852-2.14c0-1.51-1.162-2.46-3.014-2.46H3.843V13zM5.908 4.674h1.696c.963 0 1.517.451 1.517 1.244c0 .834-.629 1.32-1.73 1.32H5.908V4.673zm0 6.788V8.598h1.73c1.217 0 1.88.492 1.88 1.415c0 .943-.643 1.449-1.832 1.449H5.907z\"/>\n `),\n\n italic: icon(svg`\n <path fill=\"currentColor\" d=\"M7.991 11.674L9.53 4.455c.123-.595.246-.71 1.347-.807l.11-.52H7.211l-.11.52c1.06.096 1.128.212 1.005.807L6.57 11.674c-.123.595-.246.71-1.346.806l-.11.52h3.774l.11-.52c-1.06-.095-1.129-.211-1.006-.806z\"/>\n `),\n\n underline: icon(svg`\n <path fill=\"currentColor\" d=\"M5.313 3.136h-1.23V9.54c0 2.105 1.47 3.623 3.917 3.623s3.917-1.518 3.917-3.623V3.136h-1.23v6.323c0 1.49-.978 2.57-2.687 2.57s-2.687-1.08-2.687-2.57zM12.5 15h-9v-1h9z\"/>\n `),\n\n strikethrough: icon(svg`\n <path fill=\"currentColor\" d=\"M6.333 5.686c0 .31.083.581.27.814H5.166a2.8 2.8 0 0 1-.099-.76c0-1.627 1.436-2.768 3.48-2.768c1.969 0 3.39 1.175 3.445 2.85h-1.23c-.11-1.08-.964-1.743-2.25-1.743c-1.23 0-2.18.602-2.18 1.607zm2.194 7.478c-2.153 0-3.589-1.107-3.705-2.81h1.23c.144 1.06 1.129 1.703 2.544 1.703c1.34 0 2.31-.705 2.31-1.675c0-.827-.547-1.374-1.914-1.675L8.046 8.5H1v-1h14v1h-3.504c.468.437.675.994.675 1.697c0 1.826-1.436 2.967-3.644 2.967\"/>\n `),\n\n code: icon(svg`\n <path fill=\"currentColor\" d=\"M5.854 4.854a.5.5 0 1 0-.708-.708l-3.5 3.5a.5.5 0 0 0 0 .708l3.5 3.5a.5.5 0 0 0 .708-.708L2.707 8zm4.292 0a.5.5 0 0 1 .708-.708l3.5 3.5a.5.5 0 0 1 0 .708l-3.5 3.5a.5.5 0 0 1-.708-.708L13.293 8z\"/>\n `),\n\n link: icon(svg`\n <g fill=\"currentColor\">\n <path d=\"M4.715 6.542L3.343 7.914a3 3 0 1 0 4.243 4.243l1.828-1.829A3 3 0 0 0 8.586 5.5L8 6.086a1 1 0 0 0-.154.199a2 2 0 0 1 .861 3.337L6.88 11.45a2 2 0 1 1-2.83-2.83l.793-.792a4 4 0 0 1-.128-1.287z\"/>\n <path d=\"M6.586 4.672A3 3 0 0 0 7.414 9.5l.775-.776a2 2 0 0 1-.896-3.346L9.12 3.55a2 2 0 1 1 2.83 2.83l-.793.792c.112.42.155.855.128 1.287l1.372-1.372a3 3 0 1 0-4.243-4.243z\"/>\n </g>\n `),\n\n blockquote: icon(svg`\n <path fill=\"currentColor\" d=\"M2.5 3a.5.5 0 0 0 0 1h11a.5.5 0 0 0 0-1zm5 3a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm0 3a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm-5 3a.5.5 0 0 0 0 1h11a.5.5 0 0 0 0-1zm.79-5.373q.168-.117.444-.275L3.524 6q-.183.111-.452.287q-.27.176-.51.428a2.4 2.4 0 0 0-.398.562Q2 7.587 2 7.969q0 .54.217.873q.217.328.72.328q.322 0 .504-.211a.7.7 0 0 0 .188-.463q0-.345-.211-.521q-.205-.182-.568-.182h-.282q.036-.305.123-.498a1.4 1.4 0 0 1 .252-.37a2 2 0 0 1 .346-.298zm2.167 0q.17-.117.445-.275L5.692 6q-.183.111-.452.287q-.27.176-.51.428a2.4 2.4 0 0 0-.398.562q-.165.31-.164.692q0 .54.217.873q.217.328.72.328q.322 0 .504-.211a.7.7 0 0 0 .188-.463q0-.345-.211-.521q-.205-.182-.568-.182h-.282a1.8 1.8 0 0 1 .118-.492q.087-.194.257-.375a2 2 0 0 1 .346-.3z\"/>\n `),\n\n bulletList: icon(svg`\n <path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m-3 1a1 1 0 1 0 0-2a1 1 0 0 0 0 2m0 4a1 1 0 1 0 0-2a1 1 0 0 0 0 2m0 4a1 1 0 1 0 0-2a1 1 0 0 0 0 2\"/>\n `),\n\n orderedList: icon(svg`\n <g fill=\"currentColor\">\n <path fill-rule=\"evenodd\" d=\"M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5\"/>\n <path d=\"M1.713 11.865v-.474H2c.217 0 .363-.137.363-.317c0-.185-.158-.31-.361-.31c-.223 0-.367.152-.373.31h-.59c.016-.467.373-.787.986-.787c.588-.002.954.291.957.703a.595.595 0 0 1-.492.594v.033a.615.615 0 0 1 .569.631c.003.533-.502.8-1.051.8c-.656 0-1-.37-1.008-.794h.582c.008.178.186.306.422.309c.254 0 .424-.145.422-.35c-.002-.195-.155-.348-.414-.348h-.3zm-.004-4.699h-.604v-.035c0-.408.295-.844.958-.844c.583 0 .96.326.96.756c0 .389-.257.617-.476.848l-.537.572v.03h1.054V9H1.143v-.395l.957-.99c.138-.142.293-.304.293-.508c0-.18-.147-.32-.342-.32a.33.33 0 0 0-.342.338zM2.564 5h-.635V2.924h-.031l-.598.42v-.567l.629-.443h.635z\"/>\n </g>\n `),\n\n codeBlock: icon(svg`\n <path fill=\"currentColor\" d=\"M2.114 8.063V7.9c1.005-.102 1.497-.615 1.497-1.6V4.503c0-1.094.39-1.538 1.354-1.538h.273V2h-.376C3.25 2 2.49 2.759 2.49 4.352v1.524c0 1.094-.376 1.456-1.49 1.456v1.299c1.114 0 1.49.362 1.49 1.456v1.524c0 1.593.759 2.352 2.372 2.352h.376v-.964h-.273c-.964 0-1.354-.444-1.354-1.538V9.663c0-.984-.492-1.497-1.497-1.6M13.886 7.9v.163c-1.005.103-1.497.616-1.497 1.6v1.798c0 1.094-.39 1.538-1.354 1.538h-.273v.964h.376c1.613 0 2.372-.759 2.372-2.352v-1.524c0-1.094.376-1.456 1.49-1.456V7.332c-1.114 0-1.49-.362-1.49-1.456V4.352C13.51 2.759 12.75 2 11.138 2h-.376v.964h.273c.964 0 1.354.444 1.354 1.538V6.3c0 .984.492 1.497 1.497 1.6\"/>\n `),\n\n source: icon(svg`\n <g fill=\"currentColor\">\n <path d=\"M14 3a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM2 2a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2z\"/>\n <path fill-rule=\"evenodd\" d=\"M9.146 8.146a.5.5 0 0 1 .708 0L11.5 9.793l1.646-1.647a.5.5 0 0 1 .708.708l-2 2a.5.5 0 0 1-.708 0l-2-2a.5.5 0 0 1 0-.708\"/>\n <path fill-rule=\"evenodd\" d=\"M11.5 5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0v-4a.5.5 0 0 1 .5-.5\"/>\n <path d=\"M3.56 11V7.01h.056l1.428 3.239h.774l1.42-3.24h.056V11h1.073V5.001h-1.2l-1.71 3.894h-.039l-1.71-3.894H2.5V11z\"/>\n </g>\n `),\n};\n","import { LitElement, html, nothing, type SVGTemplateResult, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport '@rcarls/rc-button/define';\nimport '@rcarls/rc-select/define';\nimport '@rcarls/rc-toolbar/define';\nimport { icons } from './icons.js';\nimport type { EditorToolbarAction, EditorToolbarActionDetail, HeadingLevel } from './types.js';\n\nconst HEADING_OPTIONS: Array<{ value: HeadingLevel | 'p'; label: string }> = [\n { value: 'p', label: 'Paragraph' },\n { value: 'h1', label: 'Heading 1' },\n { value: 'h2', label: 'Heading 2' },\n { value: 'h3', label: 'Heading 3' },\n { value: 'h4', label: 'Heading 4' },\n { value: 'h5', label: 'Heading 5' },\n { value: 'h6', label: 'Heading 6' },\n];\n\n/**\n * Formatting toolbar for `<rc-markdown-editor>`. Renders themed `rc-button`,\n * `rc-select`, and `rc-toolbar` controls into its own light DOM so the parent\n * editor can provide their shared appearance.\n *\n * Active-format properties are set by the parent editor and reflected as\n * `aria-pressed` on the corresponding buttons. Heading level is shown via an\n * `<rc-select>`. Code-block language is shown via a `<input>` when active.\n *\n * @see {@link https://richardcarls.github.io/rc-webcomponents/components/rc-markdown-editor rc-markdown-editor docs}\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/ WAI-ARIA Toolbar pattern}\n *\n * @fires rc-toolbar-action - When a formatting button or select is activated.\n *\n * @attr label - Accessible label applied to the `rc-toolbar` container.\n * @attr active-bold - Reflects Bold as active at the cursor.\n * @attr active-italic - Reflects Italic as active at the cursor.\n * @attr active-underline - Reflects Underline as active at the cursor.\n * @attr active-strikethrough - Reflects Strikethrough as active at the cursor.\n * @attr active-code - Reflects inline Code as active at the cursor.\n * @attr active-link - Reflects Link as active at the cursor.\n * @attr active-heading - Heading level active at the cursor, or absent for paragraph text.\n * @attr active-blockquote - Reflects Blockquote as active at the cursor.\n * @attr active-bullet-list - Reflects Bullet List as active at the cursor.\n * @attr active-ordered-list - Reflects Ordered List as active at the cursor.\n * @attr active-code-block - Reflects Code Block as active at the cursor.\n * @attr code-language - Language of the code block at the cursor; absent when not in a code block.\n * @attr source-mode - Whether the parent editor is in source mode.\n */\nexport class RcEditorToolbar extends LitElement {\n /** Accessible label applied to the `rc-toolbar` container. */\n @property({ type: String })\n label = 'Formatting';\n\n /** Whether Bold formatting is active at the cursor. */\n @property({ type: Boolean, reflect: true, attribute: 'active-bold' })\n activeBold = false;\n\n /** Whether Italic formatting is active at the cursor. */\n @property({ type: Boolean, reflect: true, attribute: 'active-italic' })\n activeItalic = false;\n\n /** Whether Underline formatting is active at the cursor. */\n @property({ type: Boolean, reflect: true, attribute: 'active-underline' })\n activeUnderline = false;\n\n /** Whether Strikethrough formatting is active at the cursor. */\n @property({ type: Boolean, reflect: true, attribute: 'active-strikethrough' })\n activeStrikethrough = false;\n\n /** Whether inline Code formatting is active at the cursor. */\n @property({ type: Boolean, reflect: true, attribute: 'active-code' })\n activeCode = false;\n\n /** Whether the cursor is inside a Link. */\n @property({ type: Boolean, reflect: true, attribute: 'active-link' })\n activeLink = false;\n\n /** Heading level active at the cursor, or `null` for paragraph text. */\n @property({ attribute: 'active-heading' })\n activeHeading: HeadingLevel | null = null;\n\n /** Whether the cursor is inside a Blockquote. */\n @property({ type: Boolean, reflect: true, attribute: 'active-blockquote' })\n activeBlockquote = false;\n\n /** Whether the cursor is inside a Bullet List. */\n @property({ type: Boolean, reflect: true, attribute: 'active-bullet-list' })\n activeBulletList = false;\n\n /** Whether the cursor is inside an Ordered List. */\n @property({ type: Boolean, reflect: true, attribute: 'active-ordered-list' })\n activeOrderedList = false;\n\n /** Whether the cursor is inside a Code Block. */\n @property({ type: Boolean, reflect: true, attribute: 'active-code-block' })\n activeCodeBlock = false;\n\n /**\n * Language of the code block at the cursor. `null` means not in a code block\n * (hides the language input). `''` means no language is set.\n */\n @property({ attribute: 'code-language' })\n codeLanguage: string | null = null;\n\n /** Whether the editor is in source mode. */\n @property({ type: Boolean, reflect: true, attribute: 'source-mode' })\n sourceMode = false;\n\n @state()\n protected _langInputValue = '';\n\n override createRenderRoot(): HTMLElement {\n return this;\n }\n\n override updated(changed: Map<string, unknown>): void {\n if (changed.has('codeLanguage') && this.codeLanguage !== null) {\n this._langInputValue = this.codeLanguage;\n }\n }\n\n protected _dispatch(\n action: EditorToolbarAction,\n extra?: Partial<EditorToolbarActionDetail>,\n ): void {\n this.dispatchEvent(\n new CustomEvent<EditorToolbarActionDetail>('rc-toolbar-action', {\n bubbles: true,\n composed: true,\n detail: { action, ...extra },\n }),\n );\n }\n\n protected _onClick = (e: MouseEvent) => {\n const $btn = (e.target as Element).closest<HTMLButtonElement>('button[data-action]');\n\n if (!$btn) {\n return;\n }\n\n this._dispatch($btn.dataset['action'] as EditorToolbarAction);\n };\n\n protected _onHeadingChange = (e: Event) => {\n const value = (e as CustomEvent<{ value: string }>).detail.value as HeadingLevel | 'p';\n\n this._dispatch('heading', { headingLevel: value === 'p' ? null : value });\n };\n\n protected _onLangInput = (e: Event) => {\n this._langInputValue = (e.target as HTMLInputElement).value;\n };\n\n protected _onLangCommit = () => {\n this._dispatch('code-block-language', { codeLanguage: this._langInputValue.trim() });\n };\n\n protected _onLangKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n this._onLangCommit();\n }\n };\n\n protected _renderActionButton(\n action: EditorToolbarAction,\n label: string,\n title: string,\n active: boolean,\n icon: SVGTemplateResult,\n ): TemplateResult {\n return html`\n <rc-button icon-only class=${active ? 'toolbar-active' : nothing}>\n <button\n type=\"button\"\n data-action=${action}\n title=${title}\n aria-label=${label}\n aria-pressed=${String(active)}\n >\n <span data-rc-button-icon>${icon}</span>\n </button>\n </rc-button>\n `;\n }\n\n override render() {\n return html`\n <rc-toolbar label=${this.label} @click=${this._onClick}>\n ${this._renderActionButton('bold', 'Bold', 'Bold (Ctrl+B)', this.activeBold, icons.bold)}\n ${this._renderActionButton(\n 'italic',\n 'Italic',\n 'Italic (Ctrl+I)',\n this.activeItalic,\n icons.italic,\n )}\n ${this._renderActionButton(\n 'underline',\n 'Underline',\n 'Underline (Ctrl+U)',\n this.activeUnderline,\n icons.underline,\n )}\n ${this._renderActionButton(\n 'strikethrough',\n 'Strikethrough',\n 'Strikethrough',\n this.activeStrikethrough,\n icons.strikethrough,\n )}\n ${this._renderActionButton(\n 'code',\n 'Inline Code',\n 'Inline Code (Ctrl+`)',\n this.activeCode,\n icons.code,\n )}\n ${this._renderActionButton('link', 'Link', 'Link (Ctrl+K)', this.activeLink, icons.link)}\n\n <rc-select\n title=\"Heading level\"\n placeholder=\"Heading level\"\n class=${this.activeHeading ? 'toolbar-active' : ''}\n .value=${this.activeHeading ?? 'p'}\n @rc-select-change=${this._onHeadingChange}\n >\n <select aria-label=\"Heading level\">\n ${HEADING_OPTIONS.map(\n ({ value, label }) => html` <option value=${value}>${label}</option> `,\n )}\n </select>\n </rc-select>\n\n ${this._renderActionButton(\n 'blockquote',\n 'Blockquote',\n 'Blockquote',\n this.activeBlockquote,\n icons.blockquote,\n )}\n ${this._renderActionButton(\n 'bullet-list',\n 'Bullet List',\n 'Bullet List',\n this.activeBulletList,\n icons.bulletList,\n )}\n ${this._renderActionButton(\n 'ordered-list',\n 'Ordered List',\n 'Ordered List',\n this.activeOrderedList,\n icons.orderedList,\n )}\n ${this._renderActionButton(\n 'code-block',\n 'Code Block',\n 'Code Block',\n this.activeCodeBlock,\n icons.codeBlock,\n )}\n ${this.activeCodeBlock && this.codeLanguage !== null\n ? html`\n <input\n type=\"text\"\n class=\"lang-input\"\n aria-label=\"Code block language\"\n placeholder=\"Language\"\n title=\"Syntax language (e.g. TypeScript, Rust)\"\n .value=${this._langInputValue}\n @input=${this._onLangInput}\n @blur=${this._onLangCommit}\n @keydown=${this._onLangKeyDown}\n @click=${(e: Event) => e.stopPropagation()}\n />\n `\n : nothing}\n ${this._renderActionButton(\n 'source',\n 'Source Mode',\n 'Toggle Markdown Source (Ctrl+Shift+S)',\n this.sourceMode,\n icons.source,\n )}\n </rc-toolbar>\n `;\n }\n}\n"],"names":["element","decodeNamedCharacterReference","value","characterReference","character","splice","list","start","remove","items","end","chunkStart","parameters","push","hasOwnProperty","combineExtensions","extensions","all","index","syntaxExtension","extension","hook","left","right","code","constructs","existing","before","combineHtmlExtensions","htmlExtensions","handlers","htmlExtension","type","decodeNumericCharacterReference","base","characterReferences","encode","replace","normalizeIdentifier","asciiAlpha","regexCheck","asciiAlphanumeric","asciiAtext","asciiControl","asciiDigit","asciiHexDigit","asciiPunctuation","markdownLineEnding","markdownLineEndingOrSpace","markdownSpace","unicodePunctuation","unicodeWhitespace","regex","check","sanitizeUri","url","protocol","normalizeUri","colon","questionMark","numberSign","slash","result","skip","next","protocolHref","protocolSource","compile","options","settings","tags","definitions","buffers","mediaStack","tightStack","onenterblockquote","onentercodefenced","buffer","onentercodeindented","onentercodetext","onentercontent","onenterdefinition","onenterdefinitiondestinationstring","onenteremphasis","onenterhtmlflow","onenterhtml","onenterimage","onenterlink","onenterlistitemmarker","onenterlistitemvalue","onenterlistordered","onenterlistunordered","onenterparagraph","onenterresource","onenterresourcedestinationstring","onentersetextheading","onenterstrong","onexitatxheading","onexitatxheadingsequence","onexitautolinkemail","onexitautolinkprotocol","onexitblockquote","onexitdata","onexitcharacterreferencemarker","onexitcharacterreferencevalue","onexitflowcode","onexitcodefencedfence","onexitcodefencedfenceinfo","onresumedrop","onexitcodeflowvalue","onexitcodetext","onexitdefinition","onexitdefinitiondestinationstring","onexitdefinitionlabelstring","onexitdefinitiontitlestring","onexitemphasis","onexithardbreak","onexithtml","onexitmedia","onexitlabel","onexitlabeltext","onexitlineending","onexitlistordered","onexitlistunordered","onexitparagraph","onexitreferencestring","onexitresourcedestinationstring","onexitresourcetitlestring","onexitsetextheading","onexitsetextheadinglinesequence","onexitsetextheadingtext","onexitstrong","onexitthematicbreak","data","context","getData","lineEndingIfNeeded","raw","resume","setData","tag","lineEndingStyle","events","listStack","head","body","prepareList","handles","kind","handle","slice","length","containerBalance","loose","atMarker","event","key","lineEnding","previous","_encode","token","onexitlistitem","count","media","id","decoded","uri","factorySpace","effects","ok","max","limit","size","prefix","content","initializeContent","contentStart","afterContentStartConstruct","paragraphInitial","lineStart","document","initializeDocument","containerConstruct","tokenizeContainer","self","stack","continued","childFlow","childToken","lineStartOffset","item","documentContinue","checkNewContainers","closeFlow","indexBeforeExits","indexBeforeFlow","point","exitContainers","documentContinued","flowStart","thereIsANewContainer","thereIsNoNewContainer","containerContinue","flowContinue","writeToChild","endOfFile","stream","seen","entry","nok","classifyCharacter","resolveAll","called","resolve","attention","resolveAllAttention","tokenizeAttention","open","group","text","openingSequence","closingSequence","use","nextEvents","offset","movePoint","attentionMarkers","marker","inside","after","close","autolink","tokenizeAutolink","schemeOrEmailAtext","emailAtext","schemeInsideOrEmailAtext","urlInside","emailAtSignOrDot","emailLabel","emailValue","blankLine","tokenizeBlankLine","blockQuote","tokenizeBlockQuoteContinuation","exit","tokenizeBlockQuoteStart","state","contStart","contBefore","characterEscape","tokenizeCharacterEscape","tokenizeCharacterReference","test","numeric","nonLazyContinuation","tokenizeNonLazyContinuation","codeFenced","tokenizeCodeFenced","closeStart","tokenizeCloseStart","initialPrefix","sizeOpen","beforeSequenceOpen","tail","sequenceOpen","infoBefore","atNonLazyBreak","info","metaBefore","meta","contentBefore","beforeContentChunk","contentChunk","startBefore","beforeSequenceClose","sequenceClose","sequenceCloseAfter","codeIndented","tokenizeCodeIndented","furtherStart","tokenizeFurtherStart","afterPrefix","atBreak","codeText","resolveCodeText","tokenizeCodeText","tailExitIndex","headEnterIndex","enter","between","SpliceBuffer","initial","stop","deleteCount","removed","chunkedPush","n","subtokenize","eventsArray","jumps","lineIndex","otherIndex","otherEvent","subevents","more","subcontent","eventIndex","startPosition","startPositions","tokenizer","childEvents","gaps","current","adjust","breaks","resolveContent","tokenizeContent","continuationConstruct","tokenizeContinuation","chunkInside","contentEnd","contentContinue","startLookahead","prefixed","factoryDestination","literalType","literalMarkerType","rawType","stringType","balance","enclosedBefore","enclosed","enclosedEscape","rawEscape","factoryLabel","markerType","labelInside","labelEscape","factoryTitle","begin","escape","factoryWhitespace","definition","tokenizeDefinition","titleBefore","tokenizeTitleBefore","identifier","labelAfter","markerAfter","destinationBefore","destinationAfter","afterWhitespace","beforeMarker","titleAfter","titleAfterOptionalWhitespace","hardBreakEscape","tokenizeHardBreakEscape","headingAtx","resolveHeadingAtx","tokenizeHeadingAtx","sequenceFurther","htmlBlockNames","htmlRawNames","htmlFlow","resolveToHtmlFlow","tokenizeHtmlFlow","blankLineBefore","tokenizeBlankLineBefore","nonLazyContinuationStart","tokenizeNonLazyContinuationStart","closingTag","markerB","declarationOpen","tagCloseStart","continuationDeclarationInside","tagName","commentOpenInside","cdataOpenInside","continuation","name","basicSelfClosing","completeClosingTagAfter","completeAttributeNameBefore","completeEnd","completeAttributeName","completeAttributeNameAfter","completeAttributeValueBefore","completeAttributeValueQuoted","completeAttributeValueUnquoted","completeAttributeValueQuotedAfter","completeAfter","continuationCommentInside","continuationRawTagOpen","continuationClose","continuationCdataInside","continuationAfter","continuationStart","continuationStartNonLazy","continuationBefore","continuationRawEndTag","htmlText","tokenizeHtmlText","returnState","instruction","tagOpen","declaration","commentEnd","comment","commentClose","lineEndingBefore","cdata","cdataClose","cdataEnd","instructionClose","tagClose","tagCloseBetween","tagOpenBetween","tagOpenAttributeName","tagOpenAttributeNameAfter","tagOpenAttributeValueBefore","tagOpenAttributeValueQuoted","tagOpenAttributeValueUnquoted","tagOpenAttributeValueQuotedAfter","lineEndingAfter","lineEndingAfterPrefix","labelEnd","resolveAllLabelEnd","resolveToLabelEnd","tokenizeLabelEnd","resourceConstruct","tokenizeResource","referenceFullConstruct","tokenizeReferenceFull","referenceCollapsedConstruct","tokenizeReferenceCollapsed","newEvents","label","labelStart","defined","labelEndNok","labelEndOk","referenceNotFull","resourceStart","resourceBefore","resourceOpen","resourceEnd","resourceDestinationAfter","resourceDestinationMissing","resourceBetween","resourceTitleAfter","referenceFull","referenceFullAfter","referenceFullMissing","referenceCollapsedStart","referenceCollapsedOpen","labelStartImage","tokenizeLabelStartImage","labelStartLink","tokenizeLabelStartLink","tokenizeLineEnding","thematicBreak","tokenizeThematicBreak","sequence","tokenizeListContinuation","tokenizeListEnd","tokenizeListStart","listItemPrefixWhitespaceConstruct","tokenizeListItemPrefixWhitespace","indentConstruct","tokenizeIndent","initialSize","onBlank","endOfPrefix","otherPrefix","notBlank","notInCurrentItem","setextUnderline","resolveToSetextUnderline","tokenizeSetextUnderline","heading","paragraph","flow","initializeFlow","atBlankEnding","afterConstruct","resolver","createResolver","string","initializeFactory","field","resolveAllLineSuffixes","initializeText","notText","extraResolver","resolveAllText","chunks","bufferIndex","tabs","chunk","contentInitial","flowInitial","insideSpan","resolveText","disable","createTokenizer","parser","initialize","from","columnStart","resolveAllConstructs","constructFactory","onsuccessfulconstruct","onsuccessfulcheck","consume","defineSkip","now","sliceSerialize","sliceStream","write","main","addResult","expandTabs","serializeChunks","sliceChunks","_bufferIndex","_index","line","column","accountForPotentialSkip","chunkIndex","go","fields","construct","_","onreturn","bogusState","listOfConstructs","constructIndex","currentConstruct","handleListOfConstructs","handleMapOfConstructs","map","handleConstruct","store","startPoint","startPrevious","startCurrentConstruct","startEventsIndex","startStack","restore","startIndex","startBufferIndex","endIndex","endBufferIndex","view","atTab","parse","defaultConstructs","create","creator","postprocess","search","preprocess","atCarriageReturn","preprocessor","encoding","match","endPosition","micromark","gfmStrikethrough","single","tokenizeStrikethrough","resolveAllStrikethrough","strikethrough","extend","destination","i","source","repeat","trimLeadingNewlines","trimTrailingNewlines","indexEnd","trimNewlines","blockElements","isBlock","node","is","voidElements","isVoid","hasVoid","has","meaningfulWhenBlankElements","isMeaningfulWhenBlank","hasMeaningfulWhenBlank","tagNames","markdownEscapes","escapeMarkdown","accumulator","rules","hLevel","underline","parent","isParagraph","className","language","fenceChar","fenceSize","fenceInCodeRegex","fence","href","escapeLinkDestination","title","escapeLinkTitle","cleanAttribute","titlePart","replacement","reference","references","hasSiblings","isCodeBlock","extraSpace","delimiter","matches","alt","src","attribute","escaped","Rules","rule","filter","findRule","fn","filterValue","collapseWhitespace","isPre","prevText","keepLeadingWs","prev","nextNode","root","canParseHTMLNatively","Parser","canParse","createHTMLParser","shouldUseActiveX","doc","useActiveX","HTMLParser","RootNode","input","htmlParser","isPreOrCode","_htmlParser","Node","isBlank","flankingWhitespace","edges","edgeWhitespace","isFlankedByWhitespace","m","side","sibling","regExp","isFlanked","reduce","TurndownService","defaults","canConvert","output","process","postProcess","plugin","parentNode","replacementForNode","join","whitespace","s1","s2","nls","separator","emptyOptions","toString","includeImageAlt","includeHtml","one","values","characterEscapeOrReference","decodeString","decode","$0","$1","$2","hex","stringifyPosition","position","pos","own","fromMarkdown","compiler","config","opener","link","onenterdata","codeFlow","emphasis","hardBreak","html","image","listItem","onenterreference","strong","closer","onexitcharacterreference","onexitcodefenced","onexitcodefencedfencemeta","onexitcodeindented","onexithtmlflow","onexithtmltext","onexitimage","onexitlink","onexitresource","configure","tree","handler","defaultOnError","listSpread","firstBlankLineIndex","tailIndex","tailEvent","and","errorHandler","onExitError","ancestor","depth","siblings","referenceType","fragment","children","d","combined","gfmStrikethroughFromMarkdown","enterStrikethrough","exitStrikethrough","convert","castFactory","anyFactory","propertiesFactory","typeFactory","tests","checks","any","checkAsRecord","nodeAsRecord","testFunction","looksLikeANode","empty","CONTINUE","EXIT","SKIP","visitParents","visitor","reverse","step","factory","parents","visit","subresult","grandparents","toResult","nodeAsParent","child","testOrVisitor","visitorOrReverse","maybeReverse","overload","setCodeBlockLanguage","selectionStart","fencePattern","openingFence","fenceMatch","fenceStart","newlineIndex","fenceEnd","getFormatsFromDecorations","decorations","marks","headingLevel","rmeStyles","css","_sourceHighlightSheet","MICROMARK_OPTIONS","MDAST_OPTIONS","SAFE_RICH_ELEMENTS","isSafeLinkHref","trimmed","sanitizeRichMarkup","markup","_turndown","_content","$pre","$code","DECORATION_MAP","_RcMarkdownEditor","LitElement","_e","md","e","action","codeLanguage","nextSourceMode","sel","range","$anchor","$el","$a","$popover","v","old","$textarea","changed","nextMode","nothing","markdown","langs","$pres","lang","api","formats","to","style","dec","newTag","editor","wrap","wordInfo","pre","suf","level","stripped","nextValue","selectionEnd","lineEndIdx","lineEnd","prevNewline","prevLine","afterEnd","nextNewline","nextLine","unwrapStart","unwrapEnd","inner","selected","$existingPre","$p","unwrapRange","innerRange","$toolbar","$label","modify","rangeRect","hostRect","mode","RcMarkdownEditor","__decorateClass","property","query","icon","svg","icons","HEADING_OPTIONS","RcEditorToolbar","$btn","extra","active"],"mappings":";;;;;AAIA,MAAMA,KAAU,SAAS,cAAc,GAAG;AAMnC,SAASC,GAA8BC,GAAO;AACnD,QAAMC,IAAqB,MAAMD,IAAQ;AACzC,EAAAF,GAAQ,YAAYG;A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