} */
- let marker;
- return start;
-
- /**
- * Start of code.
- *
- * ```markdown
- * > | ~~~js
- * ^
- * | alert(1)
- * | ~~~
- * ```
- *
- * @type {State}
- */
- function start(code) {
- // To do: parse whitespace like `markdown-rs`.
- return beforeSequenceOpen(code);
- }
-
- /**
- * In opening fence, after prefix, at sequence.
- *
- * ```markdown
- * > | ~~~js
- * ^
- * | alert(1)
- * | ~~~
- * ```
- *
- * @type {State}
- */
- function beforeSequenceOpen(code) {
- const tail = self.events[self.events.length - 1];
- initialPrefix = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
- marker = code;
- effects.enter("codeFenced");
- effects.enter("codeFencedFence");
- effects.enter("codeFencedFenceSequence");
- return sequenceOpen(code);
- }
-
- /**
- * In opening fence sequence.
- *
- * ```markdown
- * > | ~~~js
- * ^
- * | alert(1)
- * | ~~~
- * ```
- *
- * @type {State}
- */
- function sequenceOpen(code) {
- if (code === marker) {
- sizeOpen++;
- effects.consume(code);
- return sequenceOpen;
- }
- if (sizeOpen < 3) {
- return nok(code);
- }
- effects.exit("codeFencedFenceSequence");
- return markdownSpace(code) ? factorySpace(effects, infoBefore, "whitespace")(code) : infoBefore(code);
- }
-
- /**
- * In opening fence, after the sequence (and optional whitespace), before info.
- *
- * ```markdown
- * > | ~~~js
- * ^
- * | alert(1)
- * | ~~~
- * ```
- *
- * @type {State}
- */
- function infoBefore(code) {
- if (code === null || markdownLineEnding(code)) {
- effects.exit("codeFencedFence");
- return self.interrupt ? ok(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
- }
- effects.enter("codeFencedFenceInfo");
- effects.enter("chunkString", {
- contentType: "string"
- });
- return info(code);
- }
-
- /**
- * In info.
- *
- * ```markdown
- * > | ~~~js
- * ^
- * | alert(1)
- * | ~~~
- * ```
- *
- * @type {State}
- */
- function info(code) {
- if (code === null || markdownLineEnding(code)) {
- effects.exit("chunkString");
- effects.exit("codeFencedFenceInfo");
- return infoBefore(code);
- }
- if (markdownSpace(code)) {
- effects.exit("chunkString");
- effects.exit("codeFencedFenceInfo");
- return factorySpace(effects, metaBefore, "whitespace")(code);
- }
- if (code === 96 && code === marker) {
- return nok(code);
- }
- effects.consume(code);
- return info;
- }
-
- /**
- * In opening fence, after info and whitespace, before meta.
- *
- * ```markdown
- * > | ~~~js eval
- * ^
- * | alert(1)
- * | ~~~
- * ```
- *
- * @type {State}
- */
- function metaBefore(code) {
- if (code === null || markdownLineEnding(code)) {
- return infoBefore(code);
- }
- effects.enter("codeFencedFenceMeta");
- effects.enter("chunkString", {
- contentType: "string"
- });
- return meta(code);
- }
-
- /**
- * In meta.
- *
- * ```markdown
- * > | ~~~js eval
- * ^
- * | alert(1)
- * | ~~~
- * ```
- *
- * @type {State}
- */
- function meta(code) {
- if (code === null || markdownLineEnding(code)) {
- effects.exit("chunkString");
- effects.exit("codeFencedFenceMeta");
- return infoBefore(code);
- }
- if (code === 96 && code === marker) {
- return nok(code);
- }
- effects.consume(code);
- return meta;
- }
-
- /**
- * At eol/eof in code, before a non-lazy closing fence or content.
- *
- * ```markdown
- * > | ~~~js
- * ^
- * > | alert(1)
- * ^
- * | ~~~
- * ```
- *
- * @type {State}
- */
- function atNonLazyBreak(code) {
- return effects.attempt(closeStart, after, contentBefore)(code);
- }
-
- /**
- * Before code content, not a closing fence, at eol.
- *
- * ```markdown
- * | ~~~js
- * > | alert(1)
- * ^
- * | ~~~
- * ```
- *
- * @type {State}
- */
- function contentBefore(code) {
- effects.enter("lineEnding");
- effects.consume(code);
- effects.exit("lineEnding");
- return contentStart;
- }
-
- /**
- * Before code content, not a closing fence.
- *
- * ```markdown
- * | ~~~js
- * > | alert(1)
- * ^
- * | ~~~
- * ```
- *
- * @type {State}
- */
- function contentStart(code) {
- return initialPrefix > 0 && markdownSpace(code) ? factorySpace(effects, beforeContentChunk, "linePrefix", initialPrefix + 1)(code) : beforeContentChunk(code);
- }
-
- /**
- * Before code content, after optional prefix.
- *
- * ```markdown
- * | ~~~js
- * > | alert(1)
- * ^
- * | ~~~
- * ```
- *
- * @type {State}
- */
- function beforeContentChunk(code) {
- if (code === null || markdownLineEnding(code)) {
- return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
- }
- effects.enter("codeFlowValue");
- return contentChunk(code);
- }
-
- /**
- * In code content.
- *
- * ```markdown
- * | ~~~js
- * > | alert(1)
- * ^^^^^^^^
- * | ~~~
- * ```
- *
- * @type {State}
- */
- function contentChunk(code) {
- if (code === null || markdownLineEnding(code)) {
- effects.exit("codeFlowValue");
- return beforeContentChunk(code);
- }
- effects.consume(code);
- return contentChunk;
- }
-
- /**
- * After code.
- *
- * ```markdown
- * | ~~~js
- * | alert(1)
- * > | ~~~
- * ^
- * ```
- *
- * @type {State}
- */
- function after(code) {
- effects.exit("codeFenced");
- return ok(code);
- }
-
- /**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
- function tokenizeCloseStart(effects, ok, nok) {
- let size = 0;
- return startBefore;
-
- /**
- *
- *
- * @type {State}
- */
- function startBefore(code) {
- effects.enter("lineEnding");
- effects.consume(code);
- effects.exit("lineEnding");
- return start;
- }
-
- /**
- * Before closing fence, at optional whitespace.
- *
- * ```markdown
- * | ~~~js
- * | alert(1)
- * > | ~~~
- * ^
- * ```
- *
- * @type {State}
- */
- function start(code) {
- // Always populated by defaults.
-
- // To do: `enter` here or in next state?
- effects.enter("codeFencedFence");
- return markdownSpace(code) ? factorySpace(effects, beforeSequenceClose, "linePrefix", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : beforeSequenceClose(code);
- }
-
- /**
- * In closing fence, after optional whitespace, at sequence.
- *
- * ```markdown
- * | ~~~js
- * | alert(1)
- * > | ~~~
- * ^
- * ```
- *
- * @type {State}
- */
- function beforeSequenceClose(code) {
- if (code === marker) {
- effects.enter("codeFencedFenceSequence");
- return sequenceClose(code);
- }
- return nok(code);
- }
-
- /**
- * In closing fence sequence.
- *
- * ```markdown
- * | ~~~js
- * | alert(1)
- * > | ~~~
- * ^
- * ```
- *
- * @type {State}
- */
- function sequenceClose(code) {
- if (code === marker) {
- size++;
- effects.consume(code);
- return sequenceClose;
- }
- if (size >= sizeOpen) {
- effects.exit("codeFencedFenceSequence");
- return markdownSpace(code) ? factorySpace(effects, sequenceCloseAfter, "whitespace")(code) : sequenceCloseAfter(code);
- }
- return nok(code);
- }
-
- /**
- * After closing fence sequence, after optional whitespace.
- *
- * ```markdown
- * | ~~~js
- * | alert(1)
- * > | ~~~
- * ^
- * ```
- *
- * @type {State}
- */
- function sequenceCloseAfter(code) {
- if (code === null || markdownLineEnding(code)) {
- effects.exit("codeFencedFence");
- return ok(code);
- }
- return nok(code);
- }
- }
-}
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeNonLazyContinuation(effects, ok, nok) {
- const self = this;
- return start;
-
- /**
- *
- *
- * @type {State}
- */
- function start(code) {
- if (code === null) {
- return nok(code);
- }
- effects.enter("lineEnding");
- effects.consume(code);
- effects.exit("lineEnding");
- return lineStart;
- }
-
- /**
- *
- *
- * @type {State}
- */
- function lineStart(code) {
- return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
- }
-}
-;// CONCATENATED MODULE: ./node_modules/_decode-named-character-reference@1.0.2@decode-named-character-reference/index.dom.js
-///
-
-/* eslint-env browser */
-
-const index_dom_element = document.createElement('i')
-
-/**
- * @param {string} value
- * @returns {string|false}
- */
-function decodeNamedCharacterReference(value) {
- const characterReference = '&' + value + ';'
- index_dom_element.innerHTML = characterReference
- const char = index_dom_element.textContent
-
- // Some named character references do not require the closing semicolon
- // (`¬`, for instance), which leads to situations where parsing the assumed
- // named reference of `¬it;` will result in the string `¬it;`.
- // When we encounter a trailing semicolon after parsing, and the character
- // reference to decode was not a semicolon (`;`), we can assume that the
- // matching was not complete.
- // @ts-expect-error: TypeScript is wrong that `textContent` on elements can
- // yield `null`.
- if (char.charCodeAt(char.length - 1) === 59 /* `;` */ && value !== 'semi') {
- return false
- }
-
- // If the decoded string is equal to the input, the character reference was
- // not valid.
- // @ts-expect-error: TypeScript is wrong that `textContent` on elements can
- // yield `null`.
- return char === characterReference ? false : char
-}
-
-;// CONCATENATED MODULE: ./node_modules/_micromark-core-commonmark@2.0.1@micromark-core-commonmark/lib/character-reference.js
-/**
- * @typedef {import('micromark-util-types').Code} Code
- * @typedef {import('micromark-util-types').Construct} Construct
- * @typedef {import('micromark-util-types').State} State
- * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
- * @typedef {import('micromark-util-types').Tokenizer} Tokenizer
- */
-
-
-
-/** @type {Construct} */
-const characterReference = {
- name: 'characterReference',
- tokenize: tokenizeCharacterReference
-};
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeCharacterReference(effects, ok, nok) {
- const self = this;
- let size = 0;
- /** @type {number} */
- let max;
- /** @type {(code: Code) => boolean} */
- let test;
- return start;
-
- /**
- * Start of character reference.
- *
- * ```markdown
- * > | a&b
- * ^
- * > | a{b
- * ^
- * > | a b
- * ^
- * ```
- *
- * @type {State}
- */
- function start(code) {
- effects.enter("characterReference");
- effects.enter("characterReferenceMarker");
- effects.consume(code);
- effects.exit("characterReferenceMarker");
- return open;
- }
-
- /**
- * After `&`, at `#` for numeric references or alphanumeric for named
- * references.
- *
- * ```markdown
- * > | a&b
- * ^
- * > | a{b
- * ^
- * > | a b
- * ^
- * ```
- *
- * @type {State}
- */
- function open(code) {
- if (code === 35) {
- effects.enter("characterReferenceMarkerNumeric");
- effects.consume(code);
- effects.exit("characterReferenceMarkerNumeric");
- return numeric;
- }
- effects.enter("characterReferenceValue");
- max = 31;
- test = asciiAlphanumeric;
- return value(code);
- }
-
- /**
- * After `#`, at `x` for hexadecimals or digit for decimals.
- *
- * ```markdown
- * > | a{b
- * ^
- * > | a b
- * ^
- * ```
- *
- * @type {State}
- */
- function numeric(code) {
- if (code === 88 || code === 120) {
- effects.enter("characterReferenceMarkerHexadecimal");
- effects.consume(code);
- effects.exit("characterReferenceMarkerHexadecimal");
- effects.enter("characterReferenceValue");
- max = 6;
- test = asciiHexDigit;
- return value;
- }
- effects.enter("characterReferenceValue");
- max = 7;
- test = asciiDigit;
- return value(code);
- }
-
- /**
- * After markers (``, ``, or `&`), in value, before `;`.
- *
- * The character reference kind defines what and how many characters are
- * allowed.
- *
- * ```markdown
- * > | a&b
- * ^^^
- * > | a{b
- * ^^^
- * > | a b
- * ^
- * ```
- *
- * @type {State}
- */
- function value(code) {
- if (code === 59 && size) {
- const token = effects.exit("characterReferenceValue");
- if (test === asciiAlphanumeric && !decodeNamedCharacterReference(self.sliceSerialize(token))) {
- return nok(code);
- }
-
- // To do: `markdown-rs` uses a different name:
- // `CharacterReferenceMarkerSemi`.
- effects.enter("characterReferenceMarker");
- effects.consume(code);
- effects.exit("characterReferenceMarker");
- effects.exit("characterReference");
- return ok;
- }
- if (test(code) && size++ < max) {
- effects.consume(code);
- return value;
- }
- return nok(code);
- }
-}
-;// CONCATENATED MODULE: ./node_modules/_micromark-core-commonmark@2.0.1@micromark-core-commonmark/lib/character-escape.js
-/**
- * @typedef {import('micromark-util-types').Construct} Construct
- * @typedef {import('micromark-util-types').State} State
- * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
- * @typedef {import('micromark-util-types').Tokenizer} Tokenizer
- */
-
-
-/** @type {Construct} */
-const characterEscape = {
- name: 'characterEscape',
- tokenize: tokenizeCharacterEscape
-};
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeCharacterEscape(effects, ok, nok) {
- return start;
-
- /**
- * Start of character escape.
- *
- * ```markdown
- * > | a\*b
- * ^
- * ```
- *
- * @type {State}
- */
- function start(code) {
- effects.enter("characterEscape");
- effects.enter("escapeMarker");
- effects.consume(code);
- effects.exit("escapeMarker");
- return inside;
- }
-
- /**
- * After `\`, at punctuation.
- *
- * ```markdown
- * > | a\*b
- * ^
- * ```
- *
- * @type {State}
- */
- function inside(code) {
- // ASCII punctuation.
- if (asciiPunctuation(code)) {
- effects.enter("characterEscapeValue");
- effects.consume(code);
- effects.exit("characterEscapeValue");
- effects.exit("characterEscape");
- return ok;
- }
- return nok(code);
- }
-}
-;// CONCATENATED MODULE: ./node_modules/_micromark-core-commonmark@2.0.1@micromark-core-commonmark/lib/line-ending.js
-/**
- * @typedef {import('micromark-util-types').Construct} Construct
- * @typedef {import('micromark-util-types').State} State
- * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
- * @typedef {import('micromark-util-types').Tokenizer} Tokenizer
- */
-
-
-
-/** @type {Construct} */
-const lineEnding = {
- name: 'lineEnding',
- tokenize: tokenizeLineEnding
-};
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeLineEnding(effects, ok) {
- return start;
-
- /** @type {State} */
- function start(code) {
- effects.enter("lineEnding");
- effects.consume(code);
- effects.exit("lineEnding");
- return factorySpace(effects, ok, "linePrefix");
- }
-}
-;// CONCATENATED MODULE: ./node_modules/_micromark-core-commonmark@2.0.1@micromark-core-commonmark/lib/label-end.js
-/**
- * @typedef {import('micromark-util-types').Construct} Construct
- * @typedef {import('micromark-util-types').Event} Event
- * @typedef {import('micromark-util-types').Resolver} Resolver
- * @typedef {import('micromark-util-types').State} State
- * @typedef {import('micromark-util-types').Token} Token
- * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
- * @typedef {import('micromark-util-types').Tokenizer} Tokenizer
- */
-
-
-
-
-
-
-
-
-
-/** @type {Construct} */
-const labelEnd = {
- name: 'labelEnd',
- tokenize: tokenizeLabelEnd,
- resolveTo: resolveToLabelEnd,
- resolveAll: resolveAllLabelEnd
-};
-
-/** @type {Construct} */
-const resourceConstruct = {
- tokenize: tokenizeResource
-};
-/** @type {Construct} */
-const referenceFullConstruct = {
- tokenize: tokenizeReferenceFull
-};
-/** @type {Construct} */
-const referenceCollapsedConstruct = {
- tokenize: tokenizeReferenceCollapsed
-};
-
-/** @type {Resolver} */
-function resolveAllLabelEnd(events) {
- let index = -1;
- while (++index < events.length) {
- const token = events[index][1];
- if (token.type === "labelImage" || token.type === "labelLink" || token.type === "labelEnd") {
- // Remove the marker.
- events.splice(index + 1, token.type === "labelImage" ? 4 : 2);
- token.type = "data";
- index++;
- }
- }
- return events;
-}
-
-/** @type {Resolver} */
-function resolveToLabelEnd(events, context) {
- let index = events.length;
- let offset = 0;
- /** @type {Token} */
- let token;
- /** @type {number | undefined} */
- let open;
- /** @type {number | undefined} */
- let close;
- /** @type {Array} */
- let media;
-
- // Find an opening.
- while (index--) {
- token = events[index][1];
- if (open) {
- // If we see another link, or inactive link label, we’ve been here before.
- if (token.type === "link" || token.type === "labelLink" && token._inactive) {
- break;
- }
-
- // Mark other link openings as inactive, as we can’t have links in
- // links.
- if (events[index][0] === 'enter' && token.type === "labelLink") {
- token._inactive = true;
- }
- } else if (close) {
- if (events[index][0] === 'enter' && (token.type === "labelImage" || token.type === "labelLink") && !token._balanced) {
- open = index;
- if (token.type !== "labelLink") {
- offset = 2;
- break;
- }
- }
- } else if (token.type === "labelEnd") {
- close = index;
- }
- }
- const group = {
- type: events[open][1].type === "labelLink" ? "link" : "image",
- start: Object.assign({}, events[open][1].start),
- end: Object.assign({}, events[events.length - 1][1].end)
- };
- const label = {
- type: "label",
- start: Object.assign({}, events[open][1].start),
- end: Object.assign({}, events[close][1].end)
- };
- const text = {
- type: "labelText",
- start: Object.assign({}, events[open + offset + 2][1].end),
- end: Object.assign({}, events[close - 2][1].start)
- };
- media = [['enter', group, context], ['enter', label, context]];
-
- // Opening marker.
- media = push(media, events.slice(open + 1, open + offset + 3));
-
- // Text open.
- media = push(media, [['enter', text, context]]);
-
- // Always populated by defaults.
-
- // Between.
- media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + offset + 4, close - 3), context));
-
- // Text close, marker close, label close.
- media = push(media, [['exit', text, context], events[close - 2], events[close - 1], ['exit', label, context]]);
-
- // Reference, resource, or so.
- media = push(media, events.slice(close + 1));
-
- // Media close.
- media = push(media, [['exit', group, context]]);
- splice(events, open, events.length, media);
- return events;
-}
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeLabelEnd(effects, ok, nok) {
- const self = this;
- let index = self.events.length;
- /** @type {Token} */
- let labelStart;
- /** @type {boolean} */
- let defined;
-
- // Find an opening.
- while (index--) {
- if ((self.events[index][1].type === "labelImage" || self.events[index][1].type === "labelLink") && !self.events[index][1]._balanced) {
- labelStart = self.events[index][1];
- break;
- }
- }
- return start;
-
- /**
- * Start of label end.
- *
- * ```markdown
- * > | [a](b) c
- * ^
- * > | [a][b] c
- * ^
- * > | [a][] b
- * ^
- * > | [a] b
- * ```
- *
- * @type {State}
- */
- function start(code) {
- // If there is not an okay opening.
- if (!labelStart) {
- return nok(code);
- }
-
- // If the corresponding label (link) start is marked as inactive,
- // it means we’d be wrapping a link, like this:
- //
- // ```markdown
- // > | a [b [c](d) e](f) g.
- // ^
- // ```
- //
- // We can’t have that, so it’s just balanced brackets.
- if (labelStart._inactive) {
- return labelEndNok(code);
- }
- defined = self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize({
- start: labelStart.end,
- end: self.now()
- })));
- effects.enter("labelEnd");
- effects.enter("labelMarker");
- effects.consume(code);
- effects.exit("labelMarker");
- effects.exit("labelEnd");
- return after;
- }
-
- /**
- * After `]`.
- *
- * ```markdown
- * > | [a](b) c
- * ^
- * > | [a][b] c
- * ^
- * > | [a][] b
- * ^
- * > | [a] b
- * ^
- * ```
- *
- * @type {State}
- */
- function after(code) {
- // Note: `markdown-rs` also parses GFM footnotes here, which for us is in
- // an extension.
-
- // Resource (`[asd](fgh)`)?
- if (code === 40) {
- return effects.attempt(resourceConstruct, labelEndOk, defined ? labelEndOk : labelEndNok)(code);
- }
-
- // Full (`[asd][fgh]`) or collapsed (`[asd][]`) reference?
- if (code === 91) {
- return effects.attempt(referenceFullConstruct, labelEndOk, defined ? referenceNotFull : labelEndNok)(code);
- }
-
- // Shortcut (`[asd]`) reference?
- return defined ? labelEndOk(code) : labelEndNok(code);
- }
-
- /**
- * After `]`, at `[`, but not at a full reference.
- *
- * > 👉 **Note**: we only get here if the label is defined.
- *
- * ```markdown
- * > | [a][] b
- * ^
- * > | [a] b
- * ^
- * ```
- *
- * @type {State}
- */
- function referenceNotFull(code) {
- return effects.attempt(referenceCollapsedConstruct, labelEndOk, labelEndNok)(code);
- }
-
- /**
- * Done, we found something.
- *
- * ```markdown
- * > | [a](b) c
- * ^
- * > | [a][b] c
- * ^
- * > | [a][] b
- * ^
- * > | [a] b
- * ^
- * ```
- *
- * @type {State}
- */
- function labelEndOk(code) {
- // Note: `markdown-rs` does a bunch of stuff here.
- return ok(code);
- }
-
- /**
- * Done, it’s nothing.
- *
- * There was an okay opening, but we didn’t match anything.
- *
- * ```markdown
- * > | [a](b c
- * ^
- * > | [a][b c
- * ^
- * > | [a] b
- * ^
- * ```
- *
- * @type {State}
- */
- function labelEndNok(code) {
- labelStart._balanced = true;
- return nok(code);
- }
-}
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeResource(effects, ok, nok) {
- return resourceStart;
-
- /**
- * At a resource.
- *
- * ```markdown
- * > | [a](b) c
- * ^
- * ```
- *
- * @type {State}
- */
- function resourceStart(code) {
- effects.enter("resource");
- effects.enter("resourceMarker");
- effects.consume(code);
- effects.exit("resourceMarker");
- return resourceBefore;
- }
-
- /**
- * In resource, after `(`, at optional whitespace.
- *
- * ```markdown
- * > | [a](b) c
- * ^
- * ```
- *
- * @type {State}
- */
- function resourceBefore(code) {
- return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceOpen)(code) : resourceOpen(code);
- }
-
- /**
- * In resource, after optional whitespace, at `)` or a destination.
- *
- * ```markdown
- * > | [a](b) c
- * ^
- * ```
- *
- * @type {State}
- */
- function resourceOpen(code) {
- if (code === 41) {
- return resourceEnd(code);
- }
- return factoryDestination(effects, resourceDestinationAfter, resourceDestinationMissing, "resourceDestination", "resourceDestinationLiteral", "resourceDestinationLiteralMarker", "resourceDestinationRaw", "resourceDestinationString", 32)(code);
- }
-
- /**
- * In resource, after destination, at optional whitespace.
- *
- * ```markdown
- * > | [a](b) c
- * ^
- * ```
- *
- * @type {State}
- */
- function resourceDestinationAfter(code) {
- return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceBetween)(code) : resourceEnd(code);
- }
-
- /**
- * At invalid destination.
- *
- * ```markdown
- * > | [a](<<) b
- * ^
- * ```
- *
- * @type {State}
- */
- function resourceDestinationMissing(code) {
- return nok(code);
- }
-
- /**
- * In resource, after destination and whitespace, at `(` or title.
- *
- * ```markdown
- * > | [a](b ) c
- * ^
- * ```
- *
- * @type {State}
- */
- function resourceBetween(code) {
- if (code === 34 || code === 39 || code === 40) {
- return factoryTitle(effects, resourceTitleAfter, nok, "resourceTitle", "resourceTitleMarker", "resourceTitleString")(code);
- }
- return resourceEnd(code);
- }
-
- /**
- * In resource, after title, at optional whitespace.
- *
- * ```markdown
- * > | [a](b "c") d
- * ^
- * ```
- *
- * @type {State}
- */
- function resourceTitleAfter(code) {
- return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceEnd)(code) : resourceEnd(code);
- }
-
- /**
- * In resource, at `)`.
- *
- * ```markdown
- * > | [a](b) d
- * ^
- * ```
- *
- * @type {State}
- */
- function resourceEnd(code) {
- if (code === 41) {
- effects.enter("resourceMarker");
- effects.consume(code);
- effects.exit("resourceMarker");
- effects.exit("resource");
- return ok;
- }
- return nok(code);
- }
-}
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeReferenceFull(effects, ok, nok) {
- const self = this;
- return referenceFull;
-
- /**
- * In a reference (full), at the `[`.
- *
- * ```markdown
- * > | [a][b] d
- * ^
- * ```
- *
- * @type {State}
- */
- function referenceFull(code) {
- return factoryLabel.call(self, effects, referenceFullAfter, referenceFullMissing, "reference", "referenceMarker", "referenceString")(code);
- }
-
- /**
- * In a reference (full), after `]`.
- *
- * ```markdown
- * > | [a][b] d
- * ^
- * ```
- *
- * @type {State}
- */
- function referenceFullAfter(code) {
- return self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1))) ? ok(code) : nok(code);
- }
-
- /**
- * In reference (full) that was missing.
- *
- * ```markdown
- * > | [a][b d
- * ^
- * ```
- *
- * @type {State}
- */
- function referenceFullMissing(code) {
- return nok(code);
- }
-}
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeReferenceCollapsed(effects, ok, nok) {
- return referenceCollapsedStart;
-
- /**
- * In reference (collapsed), at `[`.
- *
- * > 👉 **Note**: we only get here if the label is defined.
- *
- * ```markdown
- * > | [a][] d
- * ^
- * ```
- *
- * @type {State}
- */
- function referenceCollapsedStart(code) {
- // We only attempt a collapsed label if there’s a `[`.
-
- effects.enter("reference");
- effects.enter("referenceMarker");
- effects.consume(code);
- effects.exit("referenceMarker");
- return referenceCollapsedOpen;
- }
-
- /**
- * In reference (collapsed), at `]`.
- *
- * > 👉 **Note**: we only get here if the label is defined.
- *
- * ```markdown
- * > | [a][] d
- * ^
- * ```
- *
- * @type {State}
- */
- function referenceCollapsedOpen(code) {
- if (code === 93) {
- effects.enter("referenceMarker");
- effects.consume(code);
- effects.exit("referenceMarker");
- effects.exit("reference");
- return ok;
- }
- return nok(code);
- }
-}
-;// CONCATENATED MODULE: ./node_modules/_micromark-core-commonmark@2.0.1@micromark-core-commonmark/lib/label-start-image.js
-/**
- * @typedef {import('micromark-util-types').Construct} Construct
- * @typedef {import('micromark-util-types').State} State
- * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
- * @typedef {import('micromark-util-types').Tokenizer} Tokenizer
- */
-
-
-
-/** @type {Construct} */
-const labelStartImage = {
- name: 'labelStartImage',
- tokenize: tokenizeLabelStartImage,
- resolveAll: labelEnd.resolveAll
-};
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeLabelStartImage(effects, ok, nok) {
- const self = this;
- return start;
-
- /**
- * Start of label (image) start.
- *
- * ```markdown
- * > | a ![b] c
- * ^
- * ```
- *
- * @type {State}
- */
- function start(code) {
- effects.enter("labelImage");
- effects.enter("labelImageMarker");
- effects.consume(code);
- effects.exit("labelImageMarker");
- return open;
- }
-
- /**
- * After `!`, at `[`.
- *
- * ```markdown
- * > | a ![b] c
- * ^
- * ```
- *
- * @type {State}
- */
- function open(code) {
- if (code === 91) {
- effects.enter("labelMarker");
- effects.consume(code);
- effects.exit("labelMarker");
- effects.exit("labelImage");
- return after;
- }
- return nok(code);
- }
-
- /**
- * After `![`.
- *
- * ```markdown
- * > | a ![b] c
- * ^
- * ```
- *
- * This is needed in because, when GFM footnotes are enabled, images never
- * form when started with a `^`.
- * Instead, links form:
- *
- * ```markdown
- * 
- *
- * ![^a][b]
- *
- * [b]: c
- * ```
- *
- * ```html
- * !^a
- * !^a
- * ```
- *
- * @type {State}
- */
- function after(code) {
- // To do: use a new field to do this, this is still needed for
- // `micromark-extension-gfm-footnote`, but the `label-start-link`
- // behavior isn’t.
- // Hidden footnotes hook.
- /* c8 ignore next 3 */
- return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs ? nok(code) : ok(code);
- }
-}
-;// CONCATENATED MODULE: ./node_modules/_micromark-util-classify-character@2.0.0@micromark-util-classify-character/index.js
-/**
- * @typedef {import('micromark-util-types').Code} Code
- */
-
-
-/**
- * Classify whether a code represents whitespace, punctuation, or something
- * else.
- *
- * Used for attention (emphasis, strong), whose sequences can open or close
- * based on the class of surrounding characters.
- *
- * > 👉 **Note**: eof (`null`) is seen as whitespace.
- *
- * @param {Code} code
- * Code.
- * @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined}
- * Group.
- */
-function classifyCharacter(code) {
- if (
- code === null ||
- markdownLineEndingOrSpace(code) ||
- unicodeWhitespace(code)
- ) {
- return 1
- }
- if (unicodePunctuation(code)) {
- return 2
- }
-}
-
-;// CONCATENATED MODULE: ./node_modules/_micromark-core-commonmark@2.0.1@micromark-core-commonmark/lib/attention.js
-/**
- * @typedef {import('micromark-util-types').Code} Code
- * @typedef {import('micromark-util-types').Construct} Construct
- * @typedef {import('micromark-util-types').Event} Event
- * @typedef {import('micromark-util-types').Point} Point
- * @typedef {import('micromark-util-types').Resolver} Resolver
- * @typedef {import('micromark-util-types').State} State
- * @typedef {import('micromark-util-types').Token} Token
- * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
- * @typedef {import('micromark-util-types').Tokenizer} Tokenizer
- */
-
-
-
-
-/** @type {Construct} */
-const attention = {
- name: 'attention',
- tokenize: tokenizeAttention,
- resolveAll: resolveAllAttention
-};
-
-/**
- * Take all events and resolve attention to emphasis or strong.
- *
- * @type {Resolver}
- */
-// eslint-disable-next-line complexity
-function resolveAllAttention(events, context) {
- let index = -1;
- /** @type {number} */
- let open;
- /** @type {Token} */
- let group;
- /** @type {Token} */
- let text;
- /** @type {Token} */
- let openingSequence;
- /** @type {Token} */
- let closingSequence;
- /** @type {number} */
- let use;
- /** @type {Array} */
- let nextEvents;
- /** @type {number} */
- let offset;
-
- // Walk through all events.
- //
- // Note: performance of this is fine on an mb of normal markdown, but it’s
- // a bottleneck for malicious stuff.
- while (++index < events.length) {
- // Find a token that can close.
- if (events[index][0] === 'enter' && events[index][1].type === 'attentionSequence' && events[index][1]._close) {
- open = index;
-
- // Now walk back to find an opener.
- while (open--) {
- // Find a token that can open the closer.
- if (events[open][0] === 'exit' && events[open][1].type === 'attentionSequence' && events[open][1]._open &&
- // If the markers are the same:
- context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index][1]).charCodeAt(0)) {
- // If the opening can close or the closing can open,
- // and the close size *is not* a multiple of three,
- // but the sum of the opening and closing size *is* multiple of three,
- // then don’t match.
- 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)) {
- continue;
- }
-
- // Number of markers to use from the sequence.
- 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;
- const start = Object.assign({}, events[open][1].end);
- const end = Object.assign({}, events[index][1].start);
- movePoint(start, -use);
- movePoint(end, use);
- openingSequence = {
- type: use > 1 ? "strongSequence" : "emphasisSequence",
- start,
- end: Object.assign({}, events[open][1].end)
- };
- closingSequence = {
- type: use > 1 ? "strongSequence" : "emphasisSequence",
- start: Object.assign({}, events[index][1].start),
- end
- };
- text = {
- type: use > 1 ? "strongText" : "emphasisText",
- start: Object.assign({}, events[open][1].end),
- end: Object.assign({}, events[index][1].start)
- };
- group = {
- type: use > 1 ? "strong" : "emphasis",
- start: Object.assign({}, openingSequence.start),
- end: Object.assign({}, closingSequence.end)
- };
- events[open][1].end = Object.assign({}, openingSequence.start);
- events[index][1].start = Object.assign({}, closingSequence.end);
- nextEvents = [];
-
- // If there are more markers in the opening, add them before.
- if (events[open][1].end.offset - events[open][1].start.offset) {
- nextEvents = push(nextEvents, [['enter', events[open][1], context], ['exit', events[open][1], context]]);
- }
-
- // Opening.
- nextEvents = push(nextEvents, [['enter', group, context], ['enter', openingSequence, context], ['exit', openingSequence, context], ['enter', text, context]]);
-
- // Always populated by defaults.
-
- // Between.
- nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index), context));
-
- // Closing.
- nextEvents = push(nextEvents, [['exit', text, context], ['enter', closingSequence, context], ['exit', closingSequence, context], ['exit', group, context]]);
-
- // If there are more markers in the closing, add them after.
- if (events[index][1].end.offset - events[index][1].start.offset) {
- offset = 2;
- nextEvents = push(nextEvents, [['enter', events[index][1], context], ['exit', events[index][1], context]]);
- } else {
- offset = 0;
- }
- splice(events, open - 1, index - open + 3, nextEvents);
- index = open + nextEvents.length - offset - 2;
- break;
- }
- }
- }
- }
-
- // Remove remaining sequences.
- index = -1;
- while (++index < events.length) {
- if (events[index][1].type === 'attentionSequence') {
- events[index][1].type = 'data';
- }
- }
- return events;
-}
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeAttention(effects, ok) {
- const attentionMarkers = this.parser.constructs.attentionMarkers.null;
- const previous = this.previous;
- const before = classifyCharacter(previous);
-
- /** @type {NonNullable} */
- let marker;
- return start;
-
- /**
- * Before a sequence.
- *
- * ```markdown
- * > | **
- * ^
- * ```
- *
- * @type {State}
- */
- function start(code) {
- marker = code;
- effects.enter('attentionSequence');
- return inside(code);
- }
-
- /**
- * In a sequence.
- *
- * ```markdown
- * > | **
- * ^^
- * ```
- *
- * @type {State}
- */
- function inside(code) {
- if (code === marker) {
- effects.consume(code);
- return inside;
- }
- const token = effects.exit('attentionSequence');
-
- // To do: next major: move this to resolver, just like `markdown-rs`.
- const after = classifyCharacter(code);
-
- // Always populated by defaults.
-
- const open = !after || after === 2 && before || attentionMarkers.includes(code);
- const close = !before || before === 2 && after || attentionMarkers.includes(previous);
- token._open = Boolean(marker === 42 ? open : open && (before || !close));
- token._close = Boolean(marker === 42 ? close : close && (after || !open));
- return ok(code);
- }
-}
-
-/**
- * Move a point a bit.
- *
- * Note: `move` only works inside lines! It’s not possible to move past other
- * chunks (replacement characters, tabs, or line endings).
- *
- * @param {Point} point
- * @param {number} offset
- * @returns {undefined}
- */
-function movePoint(point, offset) {
- point.column += offset;
- point.offset += offset;
- point._bufferIndex += offset;
-}
-;// CONCATENATED MODULE: ./node_modules/_micromark-core-commonmark@2.0.1@micromark-core-commonmark/lib/autolink.js
-/**
- * @typedef {import('micromark-util-types').Construct} Construct
- * @typedef {import('micromark-util-types').State} State
- * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
- * @typedef {import('micromark-util-types').Tokenizer} Tokenizer
- */
-
-
-/** @type {Construct} */
-const autolink = {
- name: 'autolink',
- tokenize: tokenizeAutolink
-};
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeAutolink(effects, ok, nok) {
- let size = 0;
- return start;
-
- /**
- * Start of an autolink.
- *
- * ```markdown
- * > | ab
- * ^
- * > | ab
- * ^
- * ```
- *
- * @type {State}
- */
- function start(code) {
- effects.enter("autolink");
- effects.enter("autolinkMarker");
- effects.consume(code);
- effects.exit("autolinkMarker");
- effects.enter("autolinkProtocol");
- return open;
- }
-
- /**
- * After `<`, at protocol or atext.
- *
- * ```markdown
- * > | ab
- * ^
- * > | ab
- * ^
- * ```
- *
- * @type {State}
- */
- function open(code) {
- if (asciiAlpha(code)) {
- effects.consume(code);
- return schemeOrEmailAtext;
- }
- if (code === 64) {
- return nok(code);
- }
- return emailAtext(code);
- }
-
- /**
- * At second byte of protocol or atext.
- *
- * ```markdown
- * > | ab
- * ^
- * > | ab
- * ^
- * ```
- *
- * @type {State}
- */
- function schemeOrEmailAtext(code) {
- // ASCII alphanumeric and `+`, `-`, and `.`.
- if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) {
- // Count the previous alphabetical from `open` too.
- size = 1;
- return schemeInsideOrEmailAtext(code);
- }
- return emailAtext(code);
- }
-
- /**
- * In ambiguous protocol or atext.
- *
- * ```markdown
- * > | ab
- * ^
- * > | ab
- * ^
- * ```
- *
- * @type {State}
- */
- function schemeInsideOrEmailAtext(code) {
- if (code === 58) {
- effects.consume(code);
- size = 0;
- return urlInside;
- }
-
- // ASCII alphanumeric and `+`, `-`, and `.`.
- if ((code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && size++ < 32) {
- effects.consume(code);
- return schemeInsideOrEmailAtext;
- }
- size = 0;
- return emailAtext(code);
- }
-
- /**
- * After protocol, in URL.
- *
- * ```markdown
- * > | ab
- * ^
- * ```
- *
- * @type {State}
- */
- function urlInside(code) {
- if (code === 62) {
- effects.exit("autolinkProtocol");
- effects.enter("autolinkMarker");
- effects.consume(code);
- effects.exit("autolinkMarker");
- effects.exit("autolink");
- return ok;
- }
-
- // ASCII control, space, or `<`.
- if (code === null || code === 32 || code === 60 || asciiControl(code)) {
- return nok(code);
- }
- effects.consume(code);
- return urlInside;
- }
-
- /**
- * In email atext.
- *
- * ```markdown
- * > | ab
- * ^
- * ```
- *
- * @type {State}
- */
- function emailAtext(code) {
- if (code === 64) {
- effects.consume(code);
- return emailAtSignOrDot;
- }
- if (asciiAtext(code)) {
- effects.consume(code);
- return emailAtext;
- }
- return nok(code);
- }
-
- /**
- * In label, after at-sign or dot.
- *
- * ```markdown
- * > | ab
- * ^ ^
- * ```
- *
- * @type {State}
- */
- function emailAtSignOrDot(code) {
- return asciiAlphanumeric(code) ? emailLabel(code) : nok(code);
- }
-
- /**
- * In label, where `.` and `>` are allowed.
- *
- * ```markdown
- * > | ab
- * ^
- * ```
- *
- * @type {State}
- */
- function emailLabel(code) {
- if (code === 46) {
- effects.consume(code);
- size = 0;
- return emailAtSignOrDot;
- }
- if (code === 62) {
- // Exit, then change the token type.
- effects.exit("autolinkProtocol").type = "autolinkEmail";
- effects.enter("autolinkMarker");
- effects.consume(code);
- effects.exit("autolinkMarker");
- effects.exit("autolink");
- return ok;
- }
- return emailValue(code);
- }
-
- /**
- * In label, where `.` and `>` are *not* allowed.
- *
- * Though, this is also used in `emailLabel` to parse other values.
- *
- * ```markdown
- * > | ab
- * ^
- * ```
- *
- * @type {State}
- */
- function emailValue(code) {
- // ASCII alphanumeric or `-`.
- if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) {
- const next = code === 45 ? emailValue : emailLabel;
- effects.consume(code);
- return next;
- }
- return nok(code);
- }
-}
-;// CONCATENATED MODULE: ./node_modules/_micromark-core-commonmark@2.0.1@micromark-core-commonmark/lib/html-text.js
-/**
- * @typedef {import('micromark-util-types').Code} Code
- * @typedef {import('micromark-util-types').Construct} Construct
- * @typedef {import('micromark-util-types').State} State
- * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
- * @typedef {import('micromark-util-types').Tokenizer} Tokenizer
- */
-
-
-
-/** @type {Construct} */
-const htmlText = {
- name: 'htmlText',
- tokenize: tokenizeHtmlText
-};
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeHtmlText(effects, ok, nok) {
- const self = this;
- /** @type {NonNullable | undefined} */
- let marker;
- /** @type {number} */
- let index;
- /** @type {State} */
- let returnState;
- return start;
-
- /**
- * Start of HTML (text).
- *
- * ```markdown
- * > | a c
- * ^
- * ```
- *
- * @type {State}
- */
- function start(code) {
- effects.enter("htmlText");
- effects.enter("htmlTextData");
- effects.consume(code);
- return open;
- }
-
- /**
- * After `<`, at tag name or other stuff.
- *
- * ```markdown
- * > | a c
- * ^
- * > | a c
- * ^
- * > | a c
- * ^
- * ```
- *
- * @type {State}
- */
- function open(code) {
- if (code === 33) {
- effects.consume(code);
- return declarationOpen;
- }
- if (code === 47) {
- effects.consume(code);
- return tagCloseStart;
- }
- if (code === 63) {
- effects.consume(code);
- return instruction;
- }
-
- // ASCII alphabetical.
- if (asciiAlpha(code)) {
- effects.consume(code);
- return tagOpen;
- }
- return nok(code);
- }
-
- /**
- * After ` | a c
- * ^
- * > | a c
- * ^
- * > | a &<]]> c
- * ^
- * ```
- *
- * @type {State}
- */
- function declarationOpen(code) {
- if (code === 45) {
- effects.consume(code);
- return commentOpenInside;
- }
- if (code === 91) {
- effects.consume(code);
- index = 0;
- return cdataOpenInside;
- }
- if (asciiAlpha(code)) {
- effects.consume(code);
- return declaration;
- }
- return nok(code);
- }
-
- /**
- * In a comment, after ` | a c
- * ^
- * ```
- *
- * @type {State}
- */
- function commentOpenInside(code) {
- if (code === 45) {
- effects.consume(code);
- return commentEnd;
- }
- return nok(code);
- }
-
- /**
- * In comment.
- *
- * ```markdown
- * > | a c
- * ^
- * ```
- *
- * @type {State}
- */
- function comment(code) {
- if (code === null) {
- return nok(code);
- }
- if (code === 45) {
- effects.consume(code);
- return commentClose;
- }
- if (markdownLineEnding(code)) {
- returnState = comment;
- return lineEndingBefore(code);
- }
- effects.consume(code);
- return comment;
- }
-
- /**
- * In comment, after `-`.
- *
- * ```markdown
- * > | a c
- * ^
- * ```
- *
- * @type {State}
- */
- function commentClose(code) {
- if (code === 45) {
- effects.consume(code);
- return commentEnd;
- }
- return comment(code);
- }
-
- /**
- * In comment, after `--`.
- *
- * ```markdown
- * > | a c
- * ^
- * ```
- *
- * @type {State}
- */
- function commentEnd(code) {
- return code === 62 ? end(code) : code === 45 ? commentClose(code) : comment(code);
- }
-
- /**
- * After ` | a &<]]> b
- * ^^^^^^
- * ```
- *
- * @type {State}
- */
- function cdataOpenInside(code) {
- const value = "CDATA[";
- if (code === value.charCodeAt(index++)) {
- effects.consume(code);
- return index === value.length ? cdata : cdataOpenInside;
- }
- return nok(code);
- }
-
- /**
- * In CDATA.
- *
- * ```markdown
- * > | a &<]]> b
- * ^^^
- * ```
- *
- * @type {State}
- */
- function cdata(code) {
- if (code === null) {
- return nok(code);
- }
- if (code === 93) {
- effects.consume(code);
- return cdataClose;
- }
- if (markdownLineEnding(code)) {
- returnState = cdata;
- return lineEndingBefore(code);
- }
- effects.consume(code);
- return cdata;
- }
-
- /**
- * In CDATA, after `]`, at another `]`.
- *
- * ```markdown
- * > | a &<]]> b
- * ^
- * ```
- *
- * @type {State}
- */
- function cdataClose(code) {
- if (code === 93) {
- effects.consume(code);
- return cdataEnd;
- }
- return cdata(code);
- }
-
- /**
- * In CDATA, after `]]`, at `>`.
- *
- * ```markdown
- * > | a &<]]> b
- * ^
- * ```
- *
- * @type {State}
- */
- function cdataEnd(code) {
- if (code === 62) {
- return end(code);
- }
- if (code === 93) {
- effects.consume(code);
- return cdataEnd;
- }
- return cdata(code);
- }
-
- /**
- * In declaration.
- *
- * ```markdown
- * > | a c
- * ^
- * ```
- *
- * @type {State}
- */
- function declaration(code) {
- if (code === null || code === 62) {
- return end(code);
- }
- if (markdownLineEnding(code)) {
- returnState = declaration;
- return lineEndingBefore(code);
- }
- effects.consume(code);
- return declaration;
- }
-
- /**
- * In instruction.
- *
- * ```markdown
- * > | a c
- * ^
- * ```
- *
- * @type {State}
- */
- function instruction(code) {
- if (code === null) {
- return nok(code);
- }
- if (code === 63) {
- effects.consume(code);
- return instructionClose;
- }
- if (markdownLineEnding(code)) {
- returnState = instruction;
- return lineEndingBefore(code);
- }
- effects.consume(code);
- return instruction;
- }
-
- /**
- * In instruction, after `?`, at `>`.
- *
- * ```markdown
- * > | a c
- * ^
- * ```
- *
- * @type {State}
- */
- function instructionClose(code) {
- return code === 62 ? end(code) : instruction(code);
- }
-
- /**
- * After ``, in closing tag, at tag name.
- *
- * ```markdown
- * > | a c
- * ^
- * ```
- *
- * @type {State}
- */
- function tagCloseStart(code) {
- // ASCII alphabetical.
- if (asciiAlpha(code)) {
- effects.consume(code);
- return tagClose;
- }
- return nok(code);
- }
-
- /**
- * After ` | a c
- * ^
- * ```
- *
- * @type {State}
- */
- function tagClose(code) {
- // ASCII alphanumerical and `-`.
- if (code === 45 || asciiAlphanumeric(code)) {
- effects.consume(code);
- return tagClose;
- }
- return tagCloseBetween(code);
- }
-
- /**
- * In closing tag, after tag name.
- *
- * ```markdown
- * > | a c
- * ^
- * ```
- *
- * @type {State}
- */
- function tagCloseBetween(code) {
- if (markdownLineEnding(code)) {
- returnState = tagCloseBetween;
- return lineEndingBefore(code);
- }
- if (markdownSpace(code)) {
- effects.consume(code);
- return tagCloseBetween;
- }
- return end(code);
- }
-
- /**
- * After ` | a c
- * ^
- * ```
- *
- * @type {State}
- */
- function tagOpen(code) {
- // ASCII alphanumerical and `-`.
- if (code === 45 || asciiAlphanumeric(code)) {
- effects.consume(code);
- return tagOpen;
- }
- if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
- return tagOpenBetween(code);
- }
- return nok(code);
- }
-
- /**
- * In opening tag, after tag name.
- *
- * ```markdown
- * > | a c
- * ^
- * ```
- *
- * @type {State}
- */
- function tagOpenBetween(code) {
- if (code === 47) {
- effects.consume(code);
- return end;
- }
-
- // ASCII alphabetical and `:` and `_`.
- if (code === 58 || code === 95 || asciiAlpha(code)) {
- effects.consume(code);
- return tagOpenAttributeName;
- }
- if (markdownLineEnding(code)) {
- returnState = tagOpenBetween;
- return lineEndingBefore(code);
- }
- if (markdownSpace(code)) {
- effects.consume(code);
- return tagOpenBetween;
- }
- return end(code);
- }
-
- /**
- * In attribute name.
- *
- * ```markdown
- * > | a d
- * ^
- * ```
- *
- * @type {State}
- */
- function tagOpenAttributeName(code) {
- // ASCII alphabetical and `-`, `.`, `:`, and `_`.
- if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {
- effects.consume(code);
- return tagOpenAttributeName;
- }
- return tagOpenAttributeNameAfter(code);
- }
-
- /**
- * After attribute name, before initializer, the end of the tag, or
- * whitespace.
- *
- * ```markdown
- * > | a d
- * ^
- * ```
- *
- * @type {State}
- */
- function tagOpenAttributeNameAfter(code) {
- if (code === 61) {
- effects.consume(code);
- return tagOpenAttributeValueBefore;
- }
- if (markdownLineEnding(code)) {
- returnState = tagOpenAttributeNameAfter;
- return lineEndingBefore(code);
- }
- if (markdownSpace(code)) {
- effects.consume(code);
- return tagOpenAttributeNameAfter;
- }
- return tagOpenBetween(code);
- }
-
- /**
- * Before unquoted, double quoted, or single quoted attribute value, allowing
- * whitespace.
- *
- * ```markdown
- * > | a e
- * ^
- * ```
- *
- * @type {State}
- */
- function tagOpenAttributeValueBefore(code) {
- if (code === null || code === 60 || code === 61 || code === 62 || code === 96) {
- return nok(code);
- }
- if (code === 34 || code === 39) {
- effects.consume(code);
- marker = code;
- return tagOpenAttributeValueQuoted;
- }
- if (markdownLineEnding(code)) {
- returnState = tagOpenAttributeValueBefore;
- return lineEndingBefore(code);
- }
- if (markdownSpace(code)) {
- effects.consume(code);
- return tagOpenAttributeValueBefore;
- }
- effects.consume(code);
- return tagOpenAttributeValueUnquoted;
- }
-
- /**
- * In double or single quoted attribute value.
- *
- * ```markdown
- * > | a e
- * ^
- * ```
- *
- * @type {State}
- */
- function tagOpenAttributeValueQuoted(code) {
- if (code === marker) {
- effects.consume(code);
- marker = undefined;
- return tagOpenAttributeValueQuotedAfter;
- }
- if (code === null) {
- return nok(code);
- }
- if (markdownLineEnding(code)) {
- returnState = tagOpenAttributeValueQuoted;
- return lineEndingBefore(code);
- }
- effects.consume(code);
- return tagOpenAttributeValueQuoted;
- }
-
- /**
- * In unquoted attribute value.
- *
- * ```markdown
- * > | a e
- * ^
- * ```
- *
- * @type {State}
- */
- function tagOpenAttributeValueUnquoted(code) {
- if (code === null || code === 34 || code === 39 || code === 60 || code === 61 || code === 96) {
- return nok(code);
- }
- if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
- return tagOpenBetween(code);
- }
- effects.consume(code);
- return tagOpenAttributeValueUnquoted;
- }
-
- /**
- * After double or single quoted attribute value, before whitespace or the end
- * of the tag.
- *
- * ```markdown
- * > | a e
- * ^
- * ```
- *
- * @type {State}
- */
- function tagOpenAttributeValueQuotedAfter(code) {
- if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
- return tagOpenBetween(code);
- }
- return nok(code);
- }
-
- /**
- * In certain circumstances of a tag where only an `>` is allowed.
- *
- * ```markdown
- * > | a e
- * ^
- * ```
- *
- * @type {State}
- */
- function end(code) {
- if (code === 62) {
- effects.consume(code);
- effects.exit("htmlTextData");
- effects.exit("htmlText");
- return ok;
- }
- return nok(code);
- }
-
- /**
- * At eol.
- *
- * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
- * > empty tokens.
- *
- * ```markdown
- * > | a
- * ```
- *
- * @type {State}
- */
- function lineEndingBefore(code) {
- effects.exit("htmlTextData");
- effects.enter("lineEnding");
- effects.consume(code);
- effects.exit("lineEnding");
- return lineEndingAfter;
- }
-
- /**
- * After eol, at optional whitespace.
- *
- * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
- * > empty tokens.
- *
- * ```markdown
- * | a
- * ^
- * ```
- *
- * @type {State}
- */
- function lineEndingAfter(code) {
- // Always populated by defaults.
-
- return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, "linePrefix", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : lineEndingAfterPrefix(code);
- }
-
- /**
- * After eol, after optional whitespace.
- *
- * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
- * > empty tokens.
- *
- * ```markdown
- * | a
- * ^
- * ```
- *
- * @type {State}
- */
- function lineEndingAfterPrefix(code) {
- effects.enter("htmlTextData");
- return returnState(code);
- }
-}
-;// CONCATENATED MODULE: ./node_modules/_micromark-core-commonmark@2.0.1@micromark-core-commonmark/lib/label-start-link.js
-/**
- * @typedef {import('micromark-util-types').Construct} Construct
- * @typedef {import('micromark-util-types').State} State
- * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
- * @typedef {import('micromark-util-types').Tokenizer} Tokenizer
- */
-
-
-
-/** @type {Construct} */
-const labelStartLink = {
- name: 'labelStartLink',
- tokenize: tokenizeLabelStartLink,
- resolveAll: labelEnd.resolveAll
-};
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeLabelStartLink(effects, ok, nok) {
- const self = this;
- return start;
-
- /**
- * Start of label (link) start.
- *
- * ```markdown
- * > | a [b] c
- * ^
- * ```
- *
- * @type {State}
- */
- function start(code) {
- effects.enter("labelLink");
- effects.enter("labelMarker");
- effects.consume(code);
- effects.exit("labelMarker");
- effects.exit("labelLink");
- return after;
- }
-
- /** @type {State} */
- function after(code) {
- // To do: this isn’t needed in `micromark-extension-gfm-footnote`,
- // remove.
- // Hidden footnotes hook.
- /* c8 ignore next 3 */
- return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs ? nok(code) : ok(code);
- }
-}
-;// CONCATENATED MODULE: ./node_modules/_micromark-core-commonmark@2.0.1@micromark-core-commonmark/lib/hard-break-escape.js
-/**
- * @typedef {import('micromark-util-types').Construct} Construct
- * @typedef {import('micromark-util-types').State} State
- * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
- * @typedef {import('micromark-util-types').Tokenizer} Tokenizer
- */
-
-
-/** @type {Construct} */
-const hardBreakEscape = {
- name: 'hardBreakEscape',
- tokenize: tokenizeHardBreakEscape
-};
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeHardBreakEscape(effects, ok, nok) {
- return start;
-
- /**
- * Start of a hard break (escape).
- *
- * ```markdown
- * > | a\
- * ^
- * | b
- * ```
- *
- * @type {State}
- */
- function start(code) {
- effects.enter("hardBreakEscape");
- effects.consume(code);
- return after;
- }
-
- /**
- * After `\`, at eol.
- *
- * ```markdown
- * > | a\
- * ^
- * | b
- * ```
- *
- * @type {State}
- */
- function after(code) {
- if (markdownLineEnding(code)) {
- effects.exit("hardBreakEscape");
- return ok(code);
- }
- return nok(code);
- }
-}
-;// CONCATENATED MODULE: ./node_modules/_micromark-core-commonmark@2.0.1@micromark-core-commonmark/lib/code-text.js
-/**
- * @typedef {import('micromark-util-types').Construct} Construct
- * @typedef {import('micromark-util-types').Previous} Previous
- * @typedef {import('micromark-util-types').Resolver} Resolver
- * @typedef {import('micromark-util-types').State} State
- * @typedef {import('micromark-util-types').Token} Token
- * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
- * @typedef {import('micromark-util-types').Tokenizer} Tokenizer
- */
-
-
-/** @type {Construct} */
-const codeText = {
- name: 'codeText',
- tokenize: tokenizeCodeText,
- resolve: resolveCodeText,
- previous
-};
-
-// To do: next major: don’t resolve, like `markdown-rs`.
-/** @type {Resolver} */
-function resolveCodeText(events) {
- let tailExitIndex = events.length - 4;
- let headEnterIndex = 3;
- /** @type {number} */
- let index;
- /** @type {number | undefined} */
- let enter;
-
- // If we start and end with an EOL or a space.
- if ((events[headEnterIndex][1].type === "lineEnding" || events[headEnterIndex][1].type === 'space') && (events[tailExitIndex][1].type === "lineEnding" || events[tailExitIndex][1].type === 'space')) {
- index = headEnterIndex;
-
- // And we have data.
- while (++index < tailExitIndex) {
- if (events[index][1].type === "codeTextData") {
- // Then we have padding.
- events[headEnterIndex][1].type = "codeTextPadding";
- events[tailExitIndex][1].type = "codeTextPadding";
- headEnterIndex += 2;
- tailExitIndex -= 2;
- break;
- }
- }
- }
-
- // Merge adjacent spaces and data.
- index = headEnterIndex - 1;
- tailExitIndex++;
- while (++index <= tailExitIndex) {
- if (enter === undefined) {
- if (index !== tailExitIndex && events[index][1].type !== "lineEnding") {
- enter = index;
- }
- } else if (index === tailExitIndex || events[index][1].type === "lineEnding") {
- events[enter][1].type = "codeTextData";
- if (index !== enter + 2) {
- events[enter][1].end = events[index - 1][1].end;
- events.splice(enter + 2, index - enter - 2);
- tailExitIndex -= index - enter - 2;
- index = enter + 2;
- }
- enter = undefined;
- }
- }
- return events;
-}
-
-/**
- * @this {TokenizeContext}
- * @type {Previous}
- */
-function previous(code) {
- // If there is a previous code, there will always be a tail.
- return code !== 96 || this.events[this.events.length - 1][1].type === "characterEscape";
-}
-
-/**
- * @this {TokenizeContext}
- * @type {Tokenizer}
- */
-function tokenizeCodeText(effects, ok, nok) {
- const self = this;
- let sizeOpen = 0;
- /** @type {number} */
- let size;
- /** @type {Token} */
- let token;
- return start;
-
- /**
- * Start of code (text).
- *
- * ```markdown
- * > | `a`
- * ^
- * > | \`a`
- * ^
- * ```
- *
- * @type {State}
- */
- function start(code) {
- effects.enter("codeText");
- effects.enter("codeTextSequence");
- return sequenceOpen(code);
- }
-
- /**
- * In opening sequence.
- *
- * ```markdown
- * > | `a`
- * ^
- * ```
- *
- * @type {State}
- */
- function sequenceOpen(code) {
- if (code === 96) {
- effects.consume(code);
- sizeOpen++;
- return sequenceOpen;
- }
- effects.exit("codeTextSequence");
- return between(code);
- }
-
- /**
- * Between something and something else.
- *
- * ```markdown
- * > | `a`
- * ^^
- * ```
- *
- * @type {State}
- */
- function between(code) {
- // EOF.
- if (code === null) {
- return nok(code);
- }
-
- // To do: next major: don’t do spaces in resolve, but when compiling,
- // like `markdown-rs`.
- // Tabs don’t work, and virtual spaces don’t make sense.
- if (code === 32) {
- effects.enter('space');
- effects.consume(code);
- effects.exit('space');
- return between;
- }
-
- // Closing fence? Could also be data.
- if (code === 96) {
- token = effects.enter("codeTextSequence");
- size = 0;
- return sequenceClose(code);
- }
- if (markdownLineEnding(code)) {
- effects.enter("lineEnding");
- effects.consume(code);
- effects.exit("lineEnding");
- return between;
- }
-
- // Data.
- effects.enter("codeTextData");
- return data(code);
- }
-
- /**
- * In data.
- *
- * ```markdown
- * > | `a`
- * ^
- * ```
- *
- * @type {State}
- */
- function data(code) {
- if (code === null || code === 32 || code === 96 || markdownLineEnding(code)) {
- effects.exit("codeTextData");
- return between(code);
- }
- effects.consume(code);
- return data;
- }
-
- /**
- * In closing sequence.
- *
- * ```markdown
- * > | `a`
- * ^
- * ```
- *
- * @type {State}
- */
- function sequenceClose(code) {
- // More.
- if (code === 96) {
- effects.consume(code);
- size++;
- return sequenceClose;
- }
-
- // Done!
- if (size === sizeOpen) {
- effects.exit("codeTextSequence");
- effects.exit("codeText");
- return ok(code);
- }
-
- // More or less accents: mark as data.
- token.type = "codeTextData";
- return data(code);
- }
-}
-;// CONCATENATED MODULE: ./node_modules/_micromark@4.0.0@micromark/lib/constructs.js
-/**
- * @typedef {import('micromark-util-types').Extension} Extension
- */
-
-
-
-
-/** @satisfies {Extension['document']} */
-const constructs_document = {
- [42]: list,
- [43]: list,
- [45]: list,
- [48]: list,
- [49]: list,
- [50]: list,
- [51]: list,
- [52]: list,
- [53]: list,
- [54]: list,
- [55]: list,
- [56]: list,
- [57]: list,
- [62]: blockQuote
-}
-
-/** @satisfies {Extension['contentInitial']} */
-const contentInitial = {
- [91]: definition
-}
-
-/** @satisfies {Extension['flowInitial']} */
-const flowInitial = {
- [-2]: codeIndented,
- [-1]: codeIndented,
- [32]: codeIndented
-}
-
-/** @satisfies {Extension['flow']} */
-const constructs_flow = {
- [35]: headingAtx,
- [42]: thematicBreak,
- [45]: [setextUnderline, thematicBreak],
- [60]: htmlFlow,
- [61]: setextUnderline,
- [95]: thematicBreak,
- [96]: codeFenced,
- [126]: codeFenced
-}
-
-/** @satisfies {Extension['string']} */
-const constructs_string = {
- [38]: characterReference,
- [92]: characterEscape
-}
-
-/** @satisfies {Extension['text']} */
-const constructs_text = {
- [-5]: lineEnding,
- [-4]: lineEnding,
- [-3]: lineEnding,
- [33]: labelStartImage,
- [38]: characterReference,
- [42]: attention,
- [60]: [autolink, htmlText],
- [91]: labelStartLink,
- [92]: [hardBreakEscape, characterEscape],
- [93]: labelEnd,
- [95]: attention,
- [96]: codeText
-}
-
-/** @satisfies {Extension['insideSpan']} */
-const insideSpan = {
- null: [attention, resolver]
-}
-
-/** @satisfies {Extension['attentionMarkers']} */
-const attentionMarkers = {
- null: [42, 95]
-}
-
-/** @satisfies {Extension['disable']} */
-const disable = {
- null: []
-}
-
-;// CONCATENATED MODULE: ./node_modules/_micromark@4.0.0@micromark/lib/parse.js
-/**
- * @typedef {import('micromark-util-types').Create} Create
- * @typedef {import('micromark-util-types').FullNormalizedExtension} FullNormalizedExtension
- * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct
- * @typedef {import('micromark-util-types').ParseContext} ParseContext
- * @typedef {import('micromark-util-types').ParseOptions} ParseOptions
- */
-
-
-
-
-
-
-
-
-
-/**
- * @param {ParseOptions | null | undefined} [options]
- * @returns {ParseContext}
- */
-function parse_parse(options) {
- const settings = options || {}
- const constructs =
- /** @type {FullNormalizedExtension} */
- combineExtensions([constructs_namespaceObject, ...(settings.extensions || [])])
-
- /** @type {ParseContext} */
- const parser = {
- defined: [],
- lazy: {},
- constructs,
- content: create(content),
- document: create(document_document),
- flow: create(flow),
- string: create(string),
- text: create(text_text)
- }
- return parser
-
- /**
- * @param {InitialConstruct} initial
- */
- function create(initial) {
- return creator
- /** @type {Create} */
- function creator(from) {
- return createTokenizer(parser, initial, from)
- }
- }
-}
-
-;// CONCATENATED MODULE: ./node_modules/_micromark@4.0.0@micromark/lib/preprocess.js
-/**
- * @typedef {import('micromark-util-types').Chunk} Chunk
- * @typedef {import('micromark-util-types').Code} Code
- * @typedef {import('micromark-util-types').Encoding} Encoding
- * @typedef {import('micromark-util-types').Value} Value
- */
-
-/**
- * @callback Preprocessor
- * @param {Value} value
- * @param {Encoding | null | undefined} [encoding]
- * @param {boolean | null | undefined} [end=false]
- * @returns {Array}
- */
-
-const search = /[\0\t\n\r]/g
-
-/**
- * @returns {Preprocessor}
- */
-function preprocess() {
- let column = 1
- let buffer = ''
- /** @type {boolean | undefined} */
- let start = true
- /** @type {boolean | undefined} */
- let atCarriageReturn
- return preprocessor
-
- /** @type {Preprocessor} */
- // eslint-disable-next-line complexity
- function preprocessor(value, encoding, end) {
- /** @type {Array} */
- const chunks = []
- /** @type {RegExpMatchArray | null} */
- let match
- /** @type {number} */
- let next
- /** @type {number} */
- let startPosition
- /** @type {number} */
- let endPosition
- /** @type {Code} */
- let code
- value =
- buffer +
- (typeof value === 'string'
- ? value.toString()
- : new TextDecoder(encoding || undefined).decode(value))
- startPosition = 0
- buffer = ''
- if (start) {
- // To do: `markdown-rs` actually parses BOMs (byte order mark).
- if (value.charCodeAt(0) === 65279) {
- startPosition++
- }
- start = undefined
- }
- while (startPosition < value.length) {
- search.lastIndex = startPosition
- match = search.exec(value)
- endPosition =
- match && match.index !== undefined ? match.index : value.length
- code = value.charCodeAt(endPosition)
- if (!match) {
- buffer = value.slice(startPosition)
- break
- }
- if (code === 10 && startPosition === endPosition && atCarriageReturn) {
- chunks.push(-3)
- atCarriageReturn = undefined
- } else {
- if (atCarriageReturn) {
- chunks.push(-5)
- atCarriageReturn = undefined
- }
- if (startPosition < endPosition) {
- chunks.push(value.slice(startPosition, endPosition))
- column += endPosition - startPosition
- }
- switch (code) {
- case 0: {
- chunks.push(65533)
- column++
- break
- }
- case 9: {
- next = Math.ceil(column / 4) * 4
- chunks.push(-2)
- while (column++ < next) chunks.push(-1)
- break
- }
- case 10: {
- chunks.push(-4)
- column = 1
- break
- }
- default: {
- atCarriageReturn = true
- column = 1
- }
- }
- }
- startPosition = endPosition + 1
- }
- if (end) {
- if (atCarriageReturn) chunks.push(-5)
- if (buffer) chunks.push(buffer)
- chunks.push(null)
- }
- return chunks
- }
-}
-
-;// CONCATENATED MODULE: ./node_modules/_micromark-util-decode-numeric-character-reference@2.0.1@micromark-util-decode-numeric-character-reference/index.js
-/**
- * Turn the number (in string form as either hexa- or plain decimal) coming from
- * a numeric character reference into a character.
- *
- * Sort of like `String.fromCodePoint(Number.parseInt(value, base))`, but makes
- * non-characters and control characters safe.
- *
- * @param {string} value
- * Value to decode.
- * @param {number} base
- * Numeric base.
- * @returns {string}
- * Character.
- */
-function decodeNumericCharacterReference(value, base) {
- const code = Number.parseInt(value, base);
- if (
- // C0 except for HT, LF, FF, CR, space.
- code < 9 || code === 11 || code > 13 && code < 32 ||
- // Control character (DEL) of C0, and C1 controls.
- code > 126 && code < 160 ||
- // Lone high surrogates and low surrogates.
- code > 55_295 && code < 57_344 ||
- // Noncharacters.
- code > 64_975 && code < 65_008 || /* eslint-disable no-bitwise */
- (code & 65_535) === 65_535 || (code & 65_535) === 65_534 || /* eslint-enable no-bitwise */
- // Out of range
- code > 1_114_111) {
- return "\uFFFD";
- }
- return String.fromCodePoint(code);
-}
-;// CONCATENATED MODULE: ./node_modules/_micromark-util-decode-string@2.0.0@micromark-util-decode-string/index.js
-
-
-const characterEscapeOrReference =
- /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi
-
-/**
- * Decode markdown strings (which occur in places such as fenced code info
- * strings, destinations, labels, and titles).
- *
- * The “string” content type allows character escapes and -references.
- * This decodes those.
- *
- * @param {string} value
- * Value to decode.
- * @returns {string}
- * Decoded value.
- */
-function decodeString(value) {
- return value.replace(characterEscapeOrReference, decode)
-}
-
-/**
- * @param {string} $0
- * @param {string} $1
- * @param {string} $2
- * @returns {string}
- */
-function decode($0, $1, $2) {
- if ($1) {
- // Escape.
- return $1
- }
-
- // Reference.
- const head = $2.charCodeAt(0)
- if (head === 35) {
- const head = $2.charCodeAt(1)
- const hex = head === 120 || head === 88
- return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10)
- }
- return decodeNamedCharacterReference($2) || $0
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-from-markdown@2.0.1@mdast-util-from-markdown/lib/index.js
-/**
- * @typedef {import('mdast').Break} Break
- * @typedef {import('mdast').Blockquote} Blockquote
- * @typedef {import('mdast').Code} Code
- * @typedef {import('mdast').Definition} Definition
- * @typedef {import('mdast').Emphasis} Emphasis
- * @typedef {import('mdast').Heading} Heading
- * @typedef {import('mdast').Html} Html
- * @typedef {import('mdast').Image} Image
- * @typedef {import('mdast').InlineCode} InlineCode
- * @typedef {import('mdast').Link} Link
- * @typedef {import('mdast').List} List
- * @typedef {import('mdast').ListItem} ListItem
- * @typedef {import('mdast').Nodes} Nodes
- * @typedef {import('mdast').Paragraph} Paragraph
- * @typedef {import('mdast').Parent} Parent
- * @typedef {import('mdast').PhrasingContent} PhrasingContent
- * @typedef {import('mdast').ReferenceType} ReferenceType
- * @typedef {import('mdast').Root} Root
- * @typedef {import('mdast').Strong} Strong
- * @typedef {import('mdast').Text} Text
- * @typedef {import('mdast').ThematicBreak} ThematicBreak
- *
- * @typedef {import('micromark-util-types').Encoding} Encoding
- * @typedef {import('micromark-util-types').Event} Event
- * @typedef {import('micromark-util-types').ParseOptions} ParseOptions
- * @typedef {import('micromark-util-types').Token} Token
- * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
- * @typedef {import('micromark-util-types').Value} Value
- *
- * @typedef {import('unist').Point} Point
- *
- * @typedef {import('../index.js').CompileData} CompileData
- */
-
-/**
- * @typedef {Omit & {type: 'fragment', children: Array}} Fragment
- */
-
-/**
- * @callback Transform
- * Extra transform, to change the AST afterwards.
- * @param {Root} tree
- * Tree to transform.
- * @returns {Root | null | undefined | void}
- * New tree or nothing (in which case the current tree is used).
- *
- * @callback Handle
- * Handle a token.
- * @param {CompileContext} this
- * Context.
- * @param {Token} token
- * Current token.
- * @returns {undefined | void}
- * Nothing.
- *
- * @typedef {Record} Handles
- * Token types mapping to handles
- *
- * @callback OnEnterError
- * Handle the case where the `right` token is open, but it is closed (by the
- * `left` token) or because we reached the end of the document.
- * @param {Omit} this
- * Context.
- * @param {Token | undefined} left
- * Left token.
- * @param {Token} right
- * Right token.
- * @returns {undefined}
- * Nothing.
- *
- * @callback OnExitError
- * Handle the case where the `right` token is open but it is closed by
- * exiting the `left` token.
- * @param {Omit} this
- * Context.
- * @param {Token} left
- * Left token.
- * @param {Token} right
- * Right token.
- * @returns {undefined}
- * Nothing.
- *
- * @typedef {[Token, OnEnterError | undefined]} TokenTuple
- * Open token on the stack, with an optional error handler for when
- * that token isn’t closed properly.
- */
-
-/**
- * @typedef Config
- * Configuration.
- *
- * We have our defaults, but extensions will add more.
- * @property {Array} canContainEols
- * Token types where line endings are used.
- * @property {Handles} enter
- * Opening handles.
- * @property {Handles} exit
- * Closing handles.
- * @property {Array} transforms
- * Tree transforms.
- *
- * @typedef {Partial} Extension
- * Change how markdown tokens from micromark are turned into mdast.
- *
- * @typedef CompileContext
- * mdast compiler context.
- * @property {Array} stack
- * Stack of nodes.
- * @property {Array} tokenStack
- * Stack of tokens.
- * @property {(this: CompileContext) => undefined} buffer
- * Capture some of the output data.
- * @property {(this: CompileContext) => string} resume
- * Stop capturing and access the output data.
- * @property {(this: CompileContext, node: Nodes, token: Token, onError?: OnEnterError) => undefined} enter
- * Enter a node.
- * @property {(this: CompileContext, token: Token, onError?: OnExitError) => undefined} exit
- * Exit a node.
- * @property {TokenizeContext['sliceSerialize']} sliceSerialize
- * Get the string value of a token.
- * @property {Config} config
- * Configuration.
- * @property {CompileData} data
- * Info passed around; key/value store.
- *
- * @typedef FromMarkdownOptions
- * Configuration for how to build mdast.
- * @property {Array> | null | undefined} [mdastExtensions]
- * Extensions for this utility to change how tokens are turned into a tree.
- *
- * @typedef {ParseOptions & FromMarkdownOptions} Options
- * Configuration.
- */
-
-
-
-
-
-
-
-
-const _mdast_util_from_markdown_2_0_1_mdast_util_from_markdown_lib_own = {}.hasOwnProperty;
-
-/**
- * Turn markdown into a syntax tree.
- *
- * @overload
- * @param {Value} value
- * @param {Encoding | null | undefined} [encoding]
- * @param {Options | null | undefined} [options]
- * @returns {Root}
- *
- * @overload
- * @param {Value} value
- * @param {Options | null | undefined} [options]
- * @returns {Root}
- *
- * @param {Value} value
- * Markdown to parse.
- * @param {Encoding | Options | null | undefined} [encoding]
- * Character encoding for when `value` is `Buffer`.
- * @param {Options | null | undefined} [options]
- * Configuration.
- * @returns {Root}
- * mdast tree.
- */
-function fromMarkdown(value, encoding, options) {
- if (typeof encoding !== 'string') {
- options = encoding;
- encoding = undefined;
- }
- return compiler(options)(postprocess(parse_parse(options).document().write(preprocess()(value, encoding, true))));
-}
-
-/**
- * Note this compiler only understand complete buffering, not streaming.
- *
- * @param {Options | null | undefined} [options]
- */
-function compiler(options) {
- /** @type {Config} */
- const config = {
- transforms: [],
- canContainEols: ['emphasis', 'fragment', 'heading', 'paragraph', 'strong'],
- enter: {
- autolink: opener(link),
- autolinkProtocol: onenterdata,
- autolinkEmail: onenterdata,
- atxHeading: opener(heading),
- blockQuote: opener(blockQuote),
- characterEscape: onenterdata,
- characterReference: onenterdata,
- codeFenced: opener(codeFlow),
- codeFencedFenceInfo: buffer,
- codeFencedFenceMeta: buffer,
- codeIndented: opener(codeFlow, buffer),
- codeText: opener(codeText, buffer),
- codeTextData: onenterdata,
- data: onenterdata,
- codeFlowValue: onenterdata,
- definition: opener(definition),
- definitionDestinationString: buffer,
- definitionLabelString: buffer,
- definitionTitleString: buffer,
- emphasis: opener(emphasis),
- hardBreakEscape: opener(hardBreak),
- hardBreakTrailing: opener(hardBreak),
- htmlFlow: opener(html, buffer),
- htmlFlowData: onenterdata,
- htmlText: opener(html, buffer),
- htmlTextData: onenterdata,
- image: opener(image),
- label: buffer,
- link: opener(link),
- listItem: opener(listItem),
- listItemValue: onenterlistitemvalue,
- listOrdered: opener(list, onenterlistordered),
- listUnordered: opener(list),
- paragraph: opener(paragraph),
- reference: onenterreference,
- referenceString: buffer,
- resourceDestinationString: buffer,
- resourceTitleString: buffer,
- setextHeading: opener(heading),
- strong: opener(strong),
- thematicBreak: opener(thematicBreak)
- },
- exit: {
- atxHeading: closer(),
- atxHeadingSequence: onexitatxheadingsequence,
- autolink: closer(),
- autolinkEmail: onexitautolinkemail,
- autolinkProtocol: onexitautolinkprotocol,
- blockQuote: closer(),
- characterEscapeValue: onexitdata,
- characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker,
- characterReferenceMarkerNumeric: onexitcharacterreferencemarker,
- characterReferenceValue: onexitcharacterreferencevalue,
- characterReference: onexitcharacterreference,
- codeFenced: closer(onexitcodefenced),
- codeFencedFence: onexitcodefencedfence,
- codeFencedFenceInfo: onexitcodefencedfenceinfo,
- codeFencedFenceMeta: onexitcodefencedfencemeta,
- codeFlowValue: onexitdata,
- codeIndented: closer(onexitcodeindented),
- codeText: closer(onexitcodetext),
- codeTextData: onexitdata,
- data: onexitdata,
- definition: closer(),
- definitionDestinationString: onexitdefinitiondestinationstring,
- definitionLabelString: onexitdefinitionlabelstring,
- definitionTitleString: onexitdefinitiontitlestring,
- emphasis: closer(),
- hardBreakEscape: closer(onexithardbreak),
- hardBreakTrailing: closer(onexithardbreak),
- htmlFlow: closer(onexithtmlflow),
- htmlFlowData: onexitdata,
- htmlText: closer(onexithtmltext),
- htmlTextData: onexitdata,
- image: closer(onexitimage),
- label: onexitlabel,
- labelText: onexitlabeltext,
- lineEnding: onexitlineending,
- link: closer(onexitlink),
- listItem: closer(),
- listOrdered: closer(),
- listUnordered: closer(),
- paragraph: closer(),
- referenceString: onexitreferencestring,
- resourceDestinationString: onexitresourcedestinationstring,
- resourceTitleString: onexitresourcetitlestring,
- resource: onexitresource,
- setextHeading: closer(onexitsetextheading),
- setextHeadingLineSequence: onexitsetextheadinglinesequence,
- setextHeadingText: onexitsetextheadingtext,
- strong: closer(),
- thematicBreak: closer()
- }
- };
- configure(config, (options || {}).mdastExtensions || []);
-
- /** @type {CompileData} */
- const data = {};
- return compile;
-
- /**
- * Turn micromark events into an mdast tree.
- *
- * @param {Array} events
- * Events.
- * @returns {Root}
- * mdast tree.
- */
- function compile(events) {
- /** @type {Root} */
- let tree = {
- type: 'root',
- children: []
- };
- /** @type {Omit} */
- const context = {
- stack: [tree],
- tokenStack: [],
- config,
- enter,
- exit,
- buffer,
- resume,
- data
- };
- /** @type {Array} */
- const listStack = [];
- let index = -1;
- while (++index < events.length) {
- // We preprocess lists to add `listItem` tokens, and to infer whether
- // items the list itself are spread out.
- if (events[index][1].type === "listOrdered" || events[index][1].type === "listUnordered") {
- if (events[index][0] === 'enter') {
- listStack.push(index);
- } else {
- const tail = listStack.pop();
- index = prepareList(events, tail, index);
- }
- }
- }
- index = -1;
- while (++index < events.length) {
- const handler = config[events[index][0]];
- if (_mdast_util_from_markdown_2_0_1_mdast_util_from_markdown_lib_own.call(handler, events[index][1].type)) {
- handler[events[index][1].type].call(Object.assign({
- sliceSerialize: events[index][2].sliceSerialize
- }, context), events[index][1]);
- }
- }
-
- // Handle tokens still being open.
- if (context.tokenStack.length > 0) {
- const tail = context.tokenStack[context.tokenStack.length - 1];
- const handler = tail[1] || defaultOnError;
- handler.call(context, undefined, tail[0]);
- }
-
- // Figure out `root` position.
- tree.position = {
- start: _mdast_util_from_markdown_2_0_1_mdast_util_from_markdown_lib_point(events.length > 0 ? events[0][1].start : {
- line: 1,
- column: 1,
- offset: 0
- }),
- end: _mdast_util_from_markdown_2_0_1_mdast_util_from_markdown_lib_point(events.length > 0 ? events[events.length - 2][1].end : {
- line: 1,
- column: 1,
- offset: 0
- })
- };
-
- // Call transforms.
- index = -1;
- while (++index < config.transforms.length) {
- tree = config.transforms[index](tree) || tree;
- }
- return tree;
- }
-
- /**
- * @param {Array} events
- * @param {number} start
- * @param {number} length
- * @returns {number}
- */
- function prepareList(events, start, length) {
- let index = start - 1;
- let containerBalance = -1;
- let listSpread = false;
- /** @type {Token | undefined} */
- let listItem;
- /** @type {number | undefined} */
- let lineIndex;
- /** @type {number | undefined} */
- let firstBlankLineIndex;
- /** @type {boolean | undefined} */
- let atMarker;
- while (++index <= length) {
- const event = events[index];
- switch (event[1].type) {
- case "listUnordered":
- case "listOrdered":
- case "blockQuote":
- {
- if (event[0] === 'enter') {
- containerBalance++;
- } else {
- containerBalance--;
- }
- atMarker = undefined;
- break;
- }
- case "lineEndingBlank":
- {
- if (event[0] === 'enter') {
- if (listItem && !atMarker && !containerBalance && !firstBlankLineIndex) {
- firstBlankLineIndex = index;
- }
- atMarker = undefined;
- }
- break;
- }
- case "linePrefix":
- case "listItemValue":
- case "listItemMarker":
- case "listItemPrefix":
- case "listItemPrefixWhitespace":
- {
- // Empty.
-
- break;
- }
- default:
- {
- atMarker = undefined;
- }
- }
- if (!containerBalance && event[0] === 'enter' && event[1].type === "listItemPrefix" || containerBalance === -1 && event[0] === 'exit' && (event[1].type === "listUnordered" || event[1].type === "listOrdered")) {
- if (listItem) {
- let tailIndex = index;
- lineIndex = undefined;
- while (tailIndex--) {
- const tailEvent = events[tailIndex];
- if (tailEvent[1].type === "lineEnding" || tailEvent[1].type === "lineEndingBlank") {
- if (tailEvent[0] === 'exit') continue;
- if (lineIndex) {
- events[lineIndex][1].type = "lineEndingBlank";
- listSpread = true;
- }
- tailEvent[1].type = "lineEnding";
- lineIndex = tailIndex;
- } else if (tailEvent[1].type === "linePrefix" || tailEvent[1].type === "blockQuotePrefix" || tailEvent[1].type === "blockQuotePrefixWhitespace" || tailEvent[1].type === "blockQuoteMarker" || tailEvent[1].type === "listItemIndent") {
- // Empty
- } else {
- break;
- }
- }
- if (firstBlankLineIndex && (!lineIndex || firstBlankLineIndex < lineIndex)) {
- listItem._spread = true;
- }
-
- // Fix position.
- listItem.end = Object.assign({}, lineIndex ? events[lineIndex][1].start : event[1].end);
- events.splice(lineIndex || index, 0, ['exit', listItem, event[2]]);
- index++;
- length++;
- }
-
- // Create a new list item.
- if (event[1].type === "listItemPrefix") {
- /** @type {Token} */
- const item = {
- type: 'listItem',
- _spread: false,
- start: Object.assign({}, event[1].start),
- // @ts-expect-error: we’ll add `end` in a second.
- end: undefined
- };
- listItem = item;
- events.splice(index, 0, ['enter', item, event[2]]);
- index++;
- length++;
- firstBlankLineIndex = undefined;
- atMarker = true;
- }
- }
- }
- events[start][1]._spread = listSpread;
- return length;
- }
-
- /**
- * Create an opener handle.
- *
- * @param {(token: Token) => Nodes} create
- * Create a node.
- * @param {Handle | undefined} [and]
- * Optional function to also run.
- * @returns {Handle}
- * Handle.
- */
- function opener(create, and) {
- return open;
-
- /**
- * @this {CompileContext}
- * @param {Token} token
- * @returns {undefined}
- */
- function open(token) {
- enter.call(this, create(token), token);
- if (and) and.call(this, token);
- }
- }
-
- /**
- * @this {CompileContext}
- * @returns {undefined}
- */
- function buffer() {
- this.stack.push({
- type: 'fragment',
- children: []
- });
- }
-
- /**
- * @this {CompileContext}
- * Context.
- * @param {Nodes} node
- * Node to enter.
- * @param {Token} token
- * Corresponding token.
- * @param {OnEnterError | undefined} [errorHandler]
- * Handle the case where this token is open, but it is closed by something else.
- * @returns {undefined}
- * Nothing.
- */
- function enter(node, token, errorHandler) {
- const parent = this.stack[this.stack.length - 1];
- /** @type {Array} */
- const siblings = parent.children;
- siblings.push(node);
- this.stack.push(node);
- this.tokenStack.push([token, errorHandler]);
- node.position = {
- start: _mdast_util_from_markdown_2_0_1_mdast_util_from_markdown_lib_point(token.start),
- // @ts-expect-error: `end` will be patched later.
- end: undefined
- };
- }
-
- /**
- * Create a closer handle.
- *
- * @param {Handle | undefined} [and]
- * Optional function to also run.
- * @returns {Handle}
- * Handle.
- */
- function closer(and) {
- return close;
-
- /**
- * @this {CompileContext}
- * @param {Token} token
- * @returns {undefined}
- */
- function close(token) {
- if (and) and.call(this, token);
- exit.call(this, token);
- }
- }
-
- /**
- * @this {CompileContext}
- * Context.
- * @param {Token} token
- * Corresponding token.
- * @param {OnExitError | undefined} [onExitError]
- * Handle the case where another token is open.
- * @returns {undefined}
- * Nothing.
- */
- function exit(token, onExitError) {
- const node = this.stack.pop();
- const open = this.tokenStack.pop();
- if (!open) {
- throw new Error('Cannot close `' + token.type + '` (' + stringifyPosition({
- start: token.start,
- end: token.end
- }) + '): it’s not open');
- } else if (open[0].type !== token.type) {
- if (onExitError) {
- onExitError.call(this, token, open[0]);
- } else {
- const handler = open[1] || defaultOnError;
- handler.call(this, token, open[0]);
- }
- }
- node.position.end = _mdast_util_from_markdown_2_0_1_mdast_util_from_markdown_lib_point(token.end);
- }
-
- /**
- * @this {CompileContext}
- * @returns {string}
- */
- function resume() {
- return lib_toString(this.stack.pop());
- }
-
- //
- // Handlers.
- //
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onenterlistordered() {
- this.data.expectingFirstListItemValue = true;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onenterlistitemvalue(token) {
- if (this.data.expectingFirstListItemValue) {
- const ancestor = this.stack[this.stack.length - 2];
- ancestor.start = Number.parseInt(this.sliceSerialize(token), 10);
- this.data.expectingFirstListItemValue = undefined;
- }
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitcodefencedfenceinfo() {
- const data = this.resume();
- const node = this.stack[this.stack.length - 1];
- node.lang = data;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitcodefencedfencemeta() {
- const data = this.resume();
- const node = this.stack[this.stack.length - 1];
- node.meta = data;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitcodefencedfence() {
- // Exit if this is the closing fence.
- if (this.data.flowCodeInside) return;
- this.buffer();
- this.data.flowCodeInside = true;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitcodefenced() {
- const data = this.resume();
- const node = this.stack[this.stack.length - 1];
- node.value = data.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, '');
- this.data.flowCodeInside = undefined;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitcodeindented() {
- const data = this.resume();
- const node = this.stack[this.stack.length - 1];
- node.value = data.replace(/(\r?\n|\r)$/g, '');
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitdefinitionlabelstring(token) {
- const label = this.resume();
- const node = this.stack[this.stack.length - 1];
- node.label = label;
- node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitdefinitiontitlestring() {
- const data = this.resume();
- const node = this.stack[this.stack.length - 1];
- node.title = data;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitdefinitiondestinationstring() {
- const data = this.resume();
- const node = this.stack[this.stack.length - 1];
- node.url = data;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitatxheadingsequence(token) {
- const node = this.stack[this.stack.length - 1];
- if (!node.depth) {
- const depth = this.sliceSerialize(token).length;
- node.depth = depth;
- }
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitsetextheadingtext() {
- this.data.setextHeadingSlurpLineEnding = true;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitsetextheadinglinesequence(token) {
- const node = this.stack[this.stack.length - 1];
- node.depth = this.sliceSerialize(token).codePointAt(0) === 61 ? 1 : 2;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitsetextheading() {
- this.data.setextHeadingSlurpLineEnding = undefined;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onenterdata(token) {
- const node = this.stack[this.stack.length - 1];
- /** @type {Array} */
- const siblings = node.children;
- let tail = siblings[siblings.length - 1];
- if (!tail || tail.type !== 'text') {
- // Add a new text node.
- tail = text();
- tail.position = {
- start: _mdast_util_from_markdown_2_0_1_mdast_util_from_markdown_lib_point(token.start),
- // @ts-expect-error: we’ll add `end` later.
- end: undefined
- };
- siblings.push(tail);
- }
- this.stack.push(tail);
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexitdata(token) {
- const tail = this.stack.pop();
- tail.value += this.sliceSerialize(token);
- tail.position.end = _mdast_util_from_markdown_2_0_1_mdast_util_from_markdown_lib_point(token.end);
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexitlineending(token) {
- const context = this.stack[this.stack.length - 1];
- // If we’re at a hard break, include the line ending in there.
- if (this.data.atHardBreak) {
- const tail = context.children[context.children.length - 1];
- tail.position.end = _mdast_util_from_markdown_2_0_1_mdast_util_from_markdown_lib_point(token.end);
- this.data.atHardBreak = undefined;
- return;
- }
- if (!this.data.setextHeadingSlurpLineEnding && config.canContainEols.includes(context.type)) {
- onenterdata.call(this, token);
- onexitdata.call(this, token);
- }
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexithardbreak() {
- this.data.atHardBreak = true;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexithtmlflow() {
- const data = this.resume();
- const node = this.stack[this.stack.length - 1];
- node.value = data;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexithtmltext() {
- const data = this.resume();
- const node = this.stack[this.stack.length - 1];
- node.value = data;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexitcodetext() {
- const data = this.resume();
- const node = this.stack[this.stack.length - 1];
- node.value = data;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexitlink() {
- const node = this.stack[this.stack.length - 1];
- // Note: there are also `identifier` and `label` fields on this link node!
- // These are used / cleaned here.
-
- // To do: clean.
- if (this.data.inReference) {
- /** @type {ReferenceType} */
- const referenceType = this.data.referenceType || 'shortcut';
- node.type += 'Reference';
- // @ts-expect-error: mutate.
- node.referenceType = referenceType;
- // @ts-expect-error: mutate.
- delete node.url;
- delete node.title;
- } else {
- // @ts-expect-error: mutate.
- delete node.identifier;
- // @ts-expect-error: mutate.
- delete node.label;
- }
- this.data.referenceType = undefined;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexitimage() {
- const node = this.stack[this.stack.length - 1];
- // Note: there are also `identifier` and `label` fields on this link node!
- // These are used / cleaned here.
-
- // To do: clean.
- if (this.data.inReference) {
- /** @type {ReferenceType} */
- const referenceType = this.data.referenceType || 'shortcut';
- node.type += 'Reference';
- // @ts-expect-error: mutate.
- node.referenceType = referenceType;
- // @ts-expect-error: mutate.
- delete node.url;
- delete node.title;
- } else {
- // @ts-expect-error: mutate.
- delete node.identifier;
- // @ts-expect-error: mutate.
- delete node.label;
- }
- this.data.referenceType = undefined;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexitlabeltext(token) {
- const string = this.sliceSerialize(token);
- const ancestor = this.stack[this.stack.length - 2];
- // @ts-expect-error: stash this on the node, as it might become a reference
- // later.
- ancestor.label = decodeString(string);
- // @ts-expect-error: same as above.
- ancestor.identifier = normalizeIdentifier(string).toLowerCase();
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexitlabel() {
- const fragment = this.stack[this.stack.length - 1];
- const value = this.resume();
- const node = this.stack[this.stack.length - 1];
- // Assume a reference.
- this.data.inReference = true;
- if (node.type === 'link') {
- /** @type {Array} */
- const children = fragment.children;
- node.children = children;
- } else {
- node.alt = value;
- }
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexitresourcedestinationstring() {
- const data = this.resume();
- const node = this.stack[this.stack.length - 1];
- node.url = data;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexitresourcetitlestring() {
- const data = this.resume();
- const node = this.stack[this.stack.length - 1];
- node.title = data;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexitresource() {
- this.data.inReference = undefined;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onenterreference() {
- this.data.referenceType = 'collapsed';
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexitreferencestring(token) {
- const label = this.resume();
- const node = this.stack[this.stack.length - 1];
- // @ts-expect-error: stash this on the node, as it might become a reference
- // later.
- node.label = label;
- // @ts-expect-error: same as above.
- node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
- this.data.referenceType = 'full';
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
-
- function onexitcharacterreferencemarker(token) {
- this.data.characterReferenceType = token.type;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitcharacterreferencevalue(token) {
- const data = this.sliceSerialize(token);
- const type = this.data.characterReferenceType;
- /** @type {string} */
- let value;
- if (type) {
- value = decodeNumericCharacterReference(data, type === "characterReferenceMarkerNumeric" ? 10 : 16);
- this.data.characterReferenceType = undefined;
- } else {
- const result = decodeNamedCharacterReference(data);
- value = result;
- }
- const tail = this.stack[this.stack.length - 1];
- tail.value += value;
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitcharacterreference(token) {
- const tail = this.stack.pop();
- tail.position.end = _mdast_util_from_markdown_2_0_1_mdast_util_from_markdown_lib_point(token.end);
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitautolinkprotocol(token) {
- onexitdata.call(this, token);
- const node = this.stack[this.stack.length - 1];
- node.url = this.sliceSerialize(token);
- }
-
- /**
- * @this {CompileContext}
- * @type {Handle}
- */
- function onexitautolinkemail(token) {
- onexitdata.call(this, token);
- const node = this.stack[this.stack.length - 1];
- node.url = 'mailto:' + this.sliceSerialize(token);
- }
-
- //
- // Creaters.
- //
-
- /** @returns {Blockquote} */
- function blockQuote() {
- return {
- type: 'blockquote',
- children: []
- };
- }
-
- /** @returns {Code} */
- function codeFlow() {
- return {
- type: 'code',
- lang: null,
- meta: null,
- value: ''
- };
- }
-
- /** @returns {InlineCode} */
- function codeText() {
- return {
- type: 'inlineCode',
- value: ''
- };
- }
-
- /** @returns {Definition} */
- function definition() {
- return {
- type: 'definition',
- identifier: '',
- label: null,
- title: null,
- url: ''
- };
- }
-
- /** @returns {Emphasis} */
- function emphasis() {
- return {
- type: 'emphasis',
- children: []
- };
- }
-
- /** @returns {Heading} */
- function heading() {
- return {
- type: 'heading',
- // @ts-expect-error `depth` will be set later.
- depth: 0,
- children: []
- };
- }
-
- /** @returns {Break} */
- function hardBreak() {
- return {
- type: 'break'
- };
- }
-
- /** @returns {Html} */
- function html() {
- return {
- type: 'html',
- value: ''
- };
- }
-
- /** @returns {Image} */
- function image() {
- return {
- type: 'image',
- title: null,
- url: '',
- alt: null
- };
- }
-
- /** @returns {Link} */
- function link() {
- return {
- type: 'link',
- title: null,
- url: '',
- children: []
- };
- }
-
- /**
- * @param {Token} token
- * @returns {List}
- */
- function list(token) {
- return {
- type: 'list',
- ordered: token.type === 'listOrdered',
- start: null,
- spread: token._spread,
- children: []
- };
- }
-
- /**
- * @param {Token} token
- * @returns {ListItem}
- */
- function listItem(token) {
- return {
- type: 'listItem',
- spread: token._spread,
- checked: null,
- children: []
- };
- }
-
- /** @returns {Paragraph} */
- function paragraph() {
- return {
- type: 'paragraph',
- children: []
- };
- }
-
- /** @returns {Strong} */
- function strong() {
- return {
- type: 'strong',
- children: []
- };
- }
-
- /** @returns {Text} */
- function text() {
- return {
- type: 'text',
- value: ''
- };
- }
-
- /** @returns {ThematicBreak} */
- function thematicBreak() {
- return {
- type: 'thematicBreak'
- };
- }
-}
-
-/**
- * Copy a point-like value.
- *
- * @param {Point} d
- * Point-like value.
- * @returns {Point}
- * unist point.
- */
-function _mdast_util_from_markdown_2_0_1_mdast_util_from_markdown_lib_point(d) {
- return {
- line: d.line,
- column: d.column,
- offset: d.offset
- };
-}
-
-/**
- * @param {Config} combined
- * @param {Array | Extension>} extensions
- * @returns {undefined}
- */
-function configure(combined, extensions) {
- let index = -1;
- while (++index < extensions.length) {
- const value = extensions[index];
- if (Array.isArray(value)) {
- configure(combined, value);
- } else {
- extension(combined, value);
- }
- }
-}
-
-/**
- * @param {Config} combined
- * @param {Extension} extension
- * @returns {undefined}
- */
-function extension(combined, extension) {
- /** @type {keyof Extension} */
- let key;
- for (key in extension) {
- if (_mdast_util_from_markdown_2_0_1_mdast_util_from_markdown_lib_own.call(extension, key)) {
- switch (key) {
- case 'canContainEols':
- {
- const right = extension[key];
- if (right) {
- combined[key].push(...right);
- }
- break;
- }
- case 'transforms':
- {
- const right = extension[key];
- if (right) {
- combined[key].push(...right);
- }
- break;
- }
- case 'enter':
- case 'exit':
- {
- const right = extension[key];
- if (right) {
- Object.assign(combined[key], right);
- }
- break;
- }
- // No default
- }
- }
- }
-}
-
-/** @type {OnEnterError} */
-function defaultOnError(left, right) {
- if (left) {
- throw new Error('Cannot close `' + left.type + '` (' + stringifyPosition({
- start: left.start,
- end: left.end
- }) + '): a different token (`' + right.type + '`, ' + stringifyPosition({
- start: right.start,
- end: right.end
- }) + ') is open');
- } else {
- throw new Error('Cannot close document, a token (`' + right.type + '`, ' + stringifyPosition({
- start: right.start,
- end: right.end
- }) + ') is still open');
- }
-}
-;// CONCATENATED MODULE: ./node_modules/_remark-parse@11.0.0@remark-parse/lib/index.js
-/**
- * @typedef {import('mdast').Root} Root
- * @typedef {import('mdast-util-from-markdown').Options} FromMarkdownOptions
- * @typedef {import('unified').Parser} Parser
- * @typedef {import('unified').Processor} Processor
- */
-
-/**
- * @typedef {Omit} Options
- */
-
-
-
-/**
- * Aadd support for parsing from markdown.
- *
- * @param {Readonly | null | undefined} [options]
- * Configuration (optional).
- * @returns {undefined}
- * Nothing.
- */
-function remarkParse(options) {
- /** @type {Processor} */
- // @ts-expect-error: TS in JSDoc generates wrong types if `this` is typed regularly.
- const self = this
-
- self.parser = parser
-
- /**
- * @type {Parser}
- */
- function parser(doc) {
- return fromMarkdown(doc, {
- ...self.data('settings'),
- ...options,
- // Note: these options are not in the readme.
- // The goal is for them to be set by plugins on `data` instead of being
- // passed by users.
- extensions: self.data('micromarkExtensions') || [],
- mdastExtensions: self.data('fromMarkdownExtensions') || []
- })
- }
-}
-
-;// CONCATENATED MODULE: ./node_modules/_@ungap_structured-clone@1.2.0@@ungap/structured-clone/esm/types.js
-const VOID = -1;
-const PRIMITIVE = 0;
-const ARRAY = 1;
-const OBJECT = 2;
-const DATE = 3;
-const REGEXP = 4;
-const MAP = 5;
-const SET = 6;
-const ERROR = 7;
-const BIGINT = 8;
-// export const SYMBOL = 9;
-
-;// CONCATENATED MODULE: ./node_modules/_@ungap_structured-clone@1.2.0@@ungap/structured-clone/esm/deserialize.js
-
-
-const env = typeof self === 'object' ? self : globalThis;
-
-const deserializer = ($, _) => {
- const as = (out, index) => {
- $.set(index, out);
- return out;
- };
-
- const unpair = index => {
- if ($.has(index))
- return $.get(index);
-
- const [type, value] = _[index];
- switch (type) {
- case PRIMITIVE:
- case VOID:
- return as(value, index);
- case ARRAY: {
- const arr = as([], index);
- for (const index of value)
- arr.push(unpair(index));
- return arr;
- }
- case OBJECT: {
- const object = as({}, index);
- for (const [key, index] of value)
- object[unpair(key)] = unpair(index);
- return object;
- }
- case DATE:
- return as(new Date(value), index);
- case REGEXP: {
- const {source, flags} = value;
- return as(new RegExp(source, flags), index);
- }
- case MAP: {
- const map = as(new Map, index);
- for (const [key, index] of value)
- map.set(unpair(key), unpair(index));
- return map;
- }
- case SET: {
- const set = as(new Set, index);
- for (const index of value)
- set.add(unpair(index));
- return set;
- }
- case ERROR: {
- const {name, message} = value;
- return as(new env[name](message), index);
- }
- case BIGINT:
- return as(BigInt(value), index);
- case 'BigInt':
- return as(Object(BigInt(value)), index);
- }
- return as(new env[type](value), index);
- };
-
- return unpair;
-};
-
-/**
- * @typedef {Array} Record a type representation
- */
-
-/**
- * Returns a deserialized value from a serialized array of Records.
- * @param {Record[]} serialized a previously serialized value.
- * @returns {any}
- */
-const deserialize = serialized => deserializer(new Map, serialized)(0);
-
-;// CONCATENATED MODULE: ./node_modules/_@ungap_structured-clone@1.2.0@@ungap/structured-clone/esm/serialize.js
-
-
-const EMPTY = '';
-
-const {toString: serialize_toString} = {};
-const {keys} = Object;
-
-const typeOf = value => {
- const type = typeof value;
- if (type !== 'object' || !value)
- return [PRIMITIVE, type];
-
- const asString = serialize_toString.call(value).slice(8, -1);
- switch (asString) {
- case 'Array':
- return [ARRAY, EMPTY];
- case 'Object':
- return [OBJECT, EMPTY];
- case 'Date':
- return [DATE, EMPTY];
- case 'RegExp':
- return [REGEXP, EMPTY];
- case 'Map':
- return [MAP, EMPTY];
- case 'Set':
- return [SET, EMPTY];
- }
-
- if (asString.includes('Array'))
- return [ARRAY, asString];
-
- if (asString.includes('Error'))
- return [ERROR, asString];
-
- return [OBJECT, asString];
-};
-
-const shouldSkip = ([TYPE, type]) => (
- TYPE === PRIMITIVE &&
- (type === 'function' || type === 'symbol')
-);
-
-const serializer = (strict, json, $, _) => {
-
- const as = (out, value) => {
- const index = _.push(out) - 1;
- $.set(value, index);
- return index;
- };
-
- const pair = value => {
- if ($.has(value))
- return $.get(value);
-
- let [TYPE, type] = typeOf(value);
- switch (TYPE) {
- case PRIMITIVE: {
- let entry = value;
- switch (type) {
- case 'bigint':
- TYPE = BIGINT;
- entry = value.toString();
- break;
- case 'function':
- case 'symbol':
- if (strict)
- throw new TypeError('unable to serialize ' + type);
- entry = null;
- break;
- case 'undefined':
- return as([VOID], value);
- }
- return as([TYPE, entry], value);
- }
- case ARRAY: {
- if (type)
- return as([type, [...value]], value);
-
- const arr = [];
- const index = as([TYPE, arr], value);
- for (const entry of value)
- arr.push(pair(entry));
- return index;
- }
- case OBJECT: {
- if (type) {
- switch (type) {
- case 'BigInt':
- return as([type, value.toString()], value);
- case 'Boolean':
- case 'Number':
- case 'String':
- return as([type, value.valueOf()], value);
- }
- }
-
- if (json && ('toJSON' in value))
- return pair(value.toJSON());
-
- const entries = [];
- const index = as([TYPE, entries], value);
- for (const key of keys(value)) {
- if (strict || !shouldSkip(typeOf(value[key])))
- entries.push([pair(key), pair(value[key])]);
- }
- return index;
- }
- case DATE:
- return as([TYPE, value.toISOString()], value);
- case REGEXP: {
- const {source, flags} = value;
- return as([TYPE, {source, flags}], value);
- }
- case MAP: {
- const entries = [];
- const index = as([TYPE, entries], value);
- for (const [key, entry] of value) {
- if (strict || !(shouldSkip(typeOf(key)) || shouldSkip(typeOf(entry))))
- entries.push([pair(key), pair(entry)]);
- }
- return index;
- }
- case SET: {
- const entries = [];
- const index = as([TYPE, entries], value);
- for (const entry of value) {
- if (strict || !shouldSkip(typeOf(entry)))
- entries.push(pair(entry));
- }
- return index;
- }
- }
-
- const {message} = value;
- return as([TYPE, {name: type, message}], value);
- };
-
- return pair;
-};
-
-/**
- * @typedef {Array} Record a type representation
- */
-
-/**
- * Returns an array of serialized Records.
- * @param {any} value a serializable value.
- * @param {{json?: boolean, lossy?: boolean}?} options an object with a `lossy` or `json` property that,
- * if `true`, will not throw errors on incompatible types, and behave more
- * like JSON stringify would behave. Symbol and Function will be discarded.
- * @returns {Record[]}
- */
- const serialize = (value, {json, lossy} = {}) => {
- const _ = [];
- return serializer(!(json || lossy), !!json, new Map, _)(value), _;
-};
-
-;// CONCATENATED MODULE: ./node_modules/_@ungap_structured-clone@1.2.0@@ungap/structured-clone/esm/index.js
-
-
-
-/**
- * @typedef {Array} Record a type representation
- */
-
-/**
- * Returns an array of serialized Records.
- * @param {any} any a serializable value.
- * @param {{transfer?: any[], json?: boolean, lossy?: boolean}?} options an object with
- * a transfer option (ignored when polyfilled) and/or non standard fields that
- * fallback to the polyfill if present.
- * @returns {Record[]}
- */
-/* harmony default export */ var structured_clone_esm = (typeof structuredClone === "function" ?
- /* c8 ignore start */
- (any, options) => (
- options && ('json' in options || 'lossy' in options) ?
- deserialize(serialize(any, options)) : structuredClone(any)
- ) :
- (any, options) => deserialize(serialize(any, options)));
- /* c8 ignore stop */
-
-
-
-;// CONCATENATED MODULE: ./node_modules/_micromark-util-sanitize-uri@2.0.0@micromark-util-sanitize-uri/index.js
-
-
-/**
- * Make a value safe for injection as a URL.
- *
- * This encodes unsafe characters with percent-encoding and skips already
- * encoded sequences (see `normalizeUri`).
- * Further unsafe characters are encoded as character references (see
- * `micromark-util-encode`).
- *
- * A regex of allowed protocols can be given, in which case the URL is
- * sanitized.
- * For example, `/^(https?|ircs?|mailto|xmpp)$/i` can be used for `a[href]`, or
- * `/^https?$/i` for `img[src]` (this is what `github.com` allows).
- * If the URL includes an unknown protocol (one not matched by `protocol`, such
- * as a dangerous example, `javascript:`), the value is ignored.
- *
- * @param {string | null | undefined} url
- * URI to sanitize.
- * @param {RegExp | null | undefined} [protocol]
- * Allowed protocols.
- * @returns {string}
- * Sanitized URI.
- */
-function sanitizeUri(url, protocol) {
- const value = encode(normalizeUri(url || ''))
- if (!protocol) {
- return value
- }
- const colon = value.indexOf(':')
- const questionMark = value.indexOf('?')
- const numberSign = value.indexOf('#')
- const slash = value.indexOf('/')
- if (
- // If there is no protocol, it’s relative.
- colon < 0 ||
- // If the first colon is after a `?`, `#`, or `/`, it’s not a protocol.
- (slash > -1 && colon > slash) ||
- (questionMark > -1 && colon > questionMark) ||
- (numberSign > -1 && colon > numberSign) ||
- // It is a protocol, it should be allowed.
- protocol.test(value.slice(0, colon))
- ) {
- return value
- }
- return ''
-}
-
-/**
- * Normalize a URL.
- *
- * Encode unsafe characters with percent-encoding, skipping already encoded
- * sequences.
- *
- * @param {string} value
- * URI to normalize.
- * @returns {string}
- * Normalized URI.
- */
-function normalizeUri(value) {
- /** @type {Array} */
- const result = []
- let index = -1
- let start = 0
- let skip = 0
- while (++index < value.length) {
- const code = value.charCodeAt(index)
- /** @type {string} */
- let replace = ''
-
- // A correct percent encoded value.
- if (
- code === 37 &&
- asciiAlphanumeric(value.charCodeAt(index + 1)) &&
- asciiAlphanumeric(value.charCodeAt(index + 2))
- ) {
- skip = 2
- }
- // ASCII.
- else if (code < 128) {
- if (!/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code))) {
- replace = String.fromCharCode(code)
- }
- }
- // Astral.
- else if (code > 55_295 && code < 57_344) {
- const next = value.charCodeAt(index + 1)
-
- // A correct surrogate pair.
- if (code < 56_320 && next > 56_319 && next < 57_344) {
- replace = String.fromCharCode(code, next)
- skip = 1
- }
- // Lone surrogate.
- else {
- replace = '\uFFFD'
- }
- }
- // Unicode.
- else {
- replace = String.fromCharCode(code)
- }
- if (replace) {
- result.push(value.slice(start, index), encodeURIComponent(replace))
- start = index + skip + 1
- replace = ''
- }
- if (skip) {
- index += skip
- skip = 0
- }
- }
- return result.join('') + value.slice(start)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/footer.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('hast').ElementContent} ElementContent
- *
- * @typedef {import('./state.js').State} State
- */
-
-/**
- * @callback FootnoteBackContentTemplate
- * Generate content for the backreference dynamically.
- *
- * For the following markdown:
- *
- * ```markdown
- * Alpha[^micromark], bravo[^micromark], and charlie[^remark].
- *
- * [^remark]: things about remark
- * [^micromark]: things about micromark
- * ```
- *
- * This function will be called with:
- *
- * * `0` and `0` for the backreference from `things about micromark` to
- * `alpha`, as it is the first used definition, and the first call to it
- * * `0` and `1` for the backreference from `things about micromark` to
- * `bravo`, as it is the first used definition, and the second call to it
- * * `1` and `0` for the backreference from `things about remark` to
- * `charlie`, as it is the second used definition
- * @param {number} referenceIndex
- * Index of the definition in the order that they are first referenced,
- * 0-indexed.
- * @param {number} rereferenceIndex
- * Index of calls to the same definition, 0-indexed.
- * @returns {Array | ElementContent | string}
- * Content for the backreference when linking back from definitions to their
- * reference.
- *
- * @callback FootnoteBackLabelTemplate
- * Generate a back label dynamically.
- *
- * For the following markdown:
- *
- * ```markdown
- * Alpha[^micromark], bravo[^micromark], and charlie[^remark].
- *
- * [^remark]: things about remark
- * [^micromark]: things about micromark
- * ```
- *
- * This function will be called with:
- *
- * * `0` and `0` for the backreference from `things about micromark` to
- * `alpha`, as it is the first used definition, and the first call to it
- * * `0` and `1` for the backreference from `things about micromark` to
- * `bravo`, as it is the first used definition, and the second call to it
- * * `1` and `0` for the backreference from `things about remark` to
- * `charlie`, as it is the second used definition
- * @param {number} referenceIndex
- * Index of the definition in the order that they are first referenced,
- * 0-indexed.
- * @param {number} rereferenceIndex
- * Index of calls to the same definition, 0-indexed.
- * @returns {string}
- * Back label to use when linking back from definitions to their reference.
- */
-
-
-
-
-/**
- * Generate the default content that GitHub uses on backreferences.
- *
- * @param {number} _
- * Index of the definition in the order that they are first referenced,
- * 0-indexed.
- * @param {number} rereferenceIndex
- * Index of calls to the same definition, 0-indexed.
- * @returns {Array}
- * Content.
- */
-function defaultFootnoteBackContent(_, rereferenceIndex) {
- /** @type {Array} */
- const result = [{type: 'text', value: '↩'}]
-
- if (rereferenceIndex > 1) {
- result.push({
- type: 'element',
- tagName: 'sup',
- properties: {},
- children: [{type: 'text', value: String(rereferenceIndex)}]
- })
- }
-
- return result
-}
-
-/**
- * Generate the default label that GitHub uses on backreferences.
- *
- * @param {number} referenceIndex
- * Index of the definition in the order that they are first referenced,
- * 0-indexed.
- * @param {number} rereferenceIndex
- * Index of calls to the same definition, 0-indexed.
- * @returns {string}
- * Label.
- */
-function defaultFootnoteBackLabel(referenceIndex, rereferenceIndex) {
- return (
- 'Back to reference ' +
- (referenceIndex + 1) +
- (rereferenceIndex > 1 ? '-' + rereferenceIndex : '')
- )
-}
-
-/**
- * Generate a hast footer for called footnote definitions.
- *
- * @param {State} state
- * Info passed around.
- * @returns {Element | undefined}
- * `section` element or `undefined`.
- */
-// eslint-disable-next-line complexity
-function footer(state) {
- const clobberPrefix =
- typeof state.options.clobberPrefix === 'string'
- ? state.options.clobberPrefix
- : 'user-content-'
- const footnoteBackContent =
- state.options.footnoteBackContent || defaultFootnoteBackContent
- const footnoteBackLabel =
- state.options.footnoteBackLabel || defaultFootnoteBackLabel
- const footnoteLabel = state.options.footnoteLabel || 'Footnotes'
- const footnoteLabelTagName = state.options.footnoteLabelTagName || 'h2'
- const footnoteLabelProperties = state.options.footnoteLabelProperties || {
- className: ['sr-only']
- }
- /** @type {Array} */
- const listItems = []
- let referenceIndex = -1
-
- while (++referenceIndex < state.footnoteOrder.length) {
- const definition = state.footnoteById.get(
- state.footnoteOrder[referenceIndex]
- )
-
- if (!definition) {
- continue
- }
-
- const content = state.all(definition)
- const id = String(definition.identifier).toUpperCase()
- const safeId = normalizeUri(id.toLowerCase())
- let rereferenceIndex = 0
- /** @type {Array} */
- const backReferences = []
- const counts = state.footnoteCounts.get(id)
-
- // eslint-disable-next-line no-unmodified-loop-condition
- while (counts !== undefined && ++rereferenceIndex <= counts) {
- if (backReferences.length > 0) {
- backReferences.push({type: 'text', value: ' '})
- }
-
- let children =
- typeof footnoteBackContent === 'string'
- ? footnoteBackContent
- : footnoteBackContent(referenceIndex, rereferenceIndex)
-
- if (typeof children === 'string') {
- children = {type: 'text', value: children}
- }
-
- backReferences.push({
- type: 'element',
- tagName: 'a',
- properties: {
- href:
- '#' +
- clobberPrefix +
- 'fnref-' +
- safeId +
- (rereferenceIndex > 1 ? '-' + rereferenceIndex : ''),
- dataFootnoteBackref: '',
- ariaLabel:
- typeof footnoteBackLabel === 'string'
- ? footnoteBackLabel
- : footnoteBackLabel(referenceIndex, rereferenceIndex),
- className: ['data-footnote-backref']
- },
- children: Array.isArray(children) ? children : [children]
- })
- }
-
- const tail = content[content.length - 1]
-
- if (tail && tail.type === 'element' && tail.tagName === 'p') {
- const tailTail = tail.children[tail.children.length - 1]
- if (tailTail && tailTail.type === 'text') {
- tailTail.value += ' '
- } else {
- tail.children.push({type: 'text', value: ' '})
- }
-
- tail.children.push(...backReferences)
- } else {
- content.push(...backReferences)
- }
-
- /** @type {Element} */
- const listItem = {
- type: 'element',
- tagName: 'li',
- properties: {id: clobberPrefix + 'fn-' + safeId},
- children: state.wrap(content, true)
- }
-
- state.patch(definition, listItem)
-
- listItems.push(listItem)
- }
-
- if (listItems.length === 0) {
- return
- }
-
- return {
- type: 'element',
- tagName: 'section',
- properties: {dataFootnotes: true, className: ['footnotes']},
- children: [
- {
- type: 'element',
- tagName: footnoteLabelTagName,
- properties: {
- ...structured_clone_esm(footnoteLabelProperties),
- id: 'footnote-label'
- },
- children: [{type: 'text', value: footnoteLabel}]
- },
- {type: 'text', value: '\n'},
- {
- type: 'element',
- tagName: 'ol',
- properties: {},
- children: state.wrap(listItems, true)
- },
- {type: 'text', value: '\n'}
- ]
- }
-}
-
-;// CONCATENATED MODULE: ./node_modules/_unist-util-is@6.0.0@unist-util-is/lib/index.js
-/**
- * @typedef {import('unist').Node} Node
- * @typedef {import('unist').Parent} Parent
- */
-
-/**
- * @template Fn
- * @template Fallback
- * @typedef {Fn extends (value: any) => value is infer Thing ? Thing : Fallback} Predicate
- */
-
-/**
- * @callback Check
- * Check that an arbitrary value is a node.
- * @param {unknown} this
- * The given context.
- * @param {unknown} [node]
- * Anything (typically a node).
- * @param {number | null | undefined} [index]
- * The node’s position in its parent.
- * @param {Parent | null | undefined} [parent]
- * The node’s parent.
- * @returns {boolean}
- * Whether this is a node and passes a test.
- *
- * @typedef {Record | Node} Props
- * Object to check for equivalence.
- *
- * Note: `Node` is included as it is common but is not indexable.
- *
- * @typedef {Array | Props | TestFunction | string | null | undefined} Test
- * Check for an arbitrary node.
- *
- * @callback TestFunction
- * Check if a node passes a test.
- * @param {unknown} this
- * The given context.
- * @param {Node} node
- * A node.
- * @param {number | undefined} [index]
- * The node’s position in its parent.
- * @param {Parent | undefined} [parent]
- * The node’s parent.
- * @returns {boolean | undefined | void}
- * Whether this node passes the test.
- *
- * Note: `void` is included until TS sees no return as `undefined`.
- */
-
-/**
- * Check if `node` is a `Node` and whether it passes the given test.
- *
- * @param {unknown} node
- * Thing to check, typically `Node`.
- * @param {Test} test
- * A check for a specific node.
- * @param {number | null | undefined} index
- * The node’s position in its parent.
- * @param {Parent | null | undefined} parent
- * The node’s parent.
- * @param {unknown} context
- * Context object (`this`) to pass to `test` functions.
- * @returns {boolean}
- * Whether `node` is a node and passes a test.
- */
-const is =
- // Note: overloads in JSDoc can’t yet use different `@template`s.
- /**
- * @type {(
- * ((node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &
- * ((node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &
- * ((node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate) &
- * ((node?: null | undefined) => false) &
- * ((node: unknown, test?: null | undefined, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
- * ((node: unknown, test?: Test, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => boolean)
- * )}
- */
- (
- /**
- * @param {unknown} [node]
- * @param {Test} [test]
- * @param {number | null | undefined} [index]
- * @param {Parent | null | undefined} [parent]
- * @param {unknown} [context]
- * @returns {boolean}
- */
- // eslint-disable-next-line max-params
- function (node, test, index, parent, context) {
- const check = convert(test)
-
- if (
- index !== undefined &&
- index !== null &&
- (typeof index !== 'number' ||
- index < 0 ||
- index === Number.POSITIVE_INFINITY)
- ) {
- throw new Error('Expected positive finite index')
- }
-
- if (
- parent !== undefined &&
- parent !== null &&
- (!is(parent) || !parent.children)
- ) {
- throw new Error('Expected parent node')
- }
-
- if (
- (parent === undefined || parent === null) !==
- (index === undefined || index === null)
- ) {
- throw new Error('Expected both parent and index')
- }
-
- return looksLikeANode(node)
- ? check.call(context, node, index, parent)
- : false
- }
- )
-
-/**
- * Generate an assertion from a test.
- *
- * Useful if you’re going to test many nodes, for example when creating a
- * utility where something else passes a compatible test.
- *
- * The created function is a bit faster because it expects valid input only:
- * a `node`, `index`, and `parent`.
- *
- * @param {Test} test
- * * when nullish, checks if `node` is a `Node`.
- * * when `string`, works like passing `(node) => node.type === test`.
- * * when `function` checks if function passed the node is true.
- * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
- * * when `array`, checks if any one of the subtests pass.
- * @returns {Check}
- * An assertion.
- */
-const convert =
- // Note: overloads in JSDoc can’t yet use different `@template`s.
- /**
- * @type {(
- * ((test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &
- * ((test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &
- * ((test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate) &
- * ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
- * ((test?: Test) => Check)
- * )}
- */
- (
- /**
- * @param {Test} [test]
- * @returns {Check}
- */
- function (test) {
- if (test === null || test === undefined) {
- return lib_ok
- }
-
- if (typeof test === 'function') {
- return castFactory(test)
- }
-
- if (typeof test === 'object') {
- return Array.isArray(test) ? anyFactory(test) : propsFactory(test)
- }
-
- if (typeof test === 'string') {
- return typeFactory(test)
- }
-
- throw new Error('Expected function, string, or object as test')
- }
- )
-
-/**
- * @param {Array} tests
- * @returns {Check}
- */
-function anyFactory(tests) {
- /** @type {Array} */
- const checks = []
- let index = -1
-
- while (++index < tests.length) {
- checks[index] = convert(tests[index])
- }
-
- return castFactory(any)
-
- /**
- * @this {unknown}
- * @type {TestFunction}
- */
- function any(...parameters) {
- let index = -1
-
- while (++index < checks.length) {
- if (checks[index].apply(this, parameters)) return true
- }
-
- return false
- }
-}
-
-/**
- * Turn an object into a test for a node with a certain fields.
- *
- * @param {Props} check
- * @returns {Check}
- */
-function propsFactory(check) {
- const checkAsRecord = /** @type {Record} */ (check)
-
- return castFactory(all)
-
- /**
- * @param {Node} node
- * @returns {boolean}
- */
- function all(node) {
- const nodeAsRecord = /** @type {Record} */ (
- /** @type {unknown} */ (node)
- )
-
- /** @type {string} */
- let key
-
- for (key in check) {
- if (nodeAsRecord[key] !== checkAsRecord[key]) return false
- }
-
- return true
- }
-}
-
-/**
- * Turn a string into a test for a node with a certain type.
- *
- * @param {string} check
- * @returns {Check}
- */
-function typeFactory(check) {
- return castFactory(type)
-
- /**
- * @param {Node} node
- */
- function type(node) {
- return node && node.type === check
- }
-}
-
-/**
- * Turn a custom test into a test for a node that passes that test.
- *
- * @param {TestFunction} testFunction
- * @returns {Check}
- */
-function castFactory(testFunction) {
- return check
-
- /**
- * @this {unknown}
- * @type {Check}
- */
- function check(value, index, parent) {
- return Boolean(
- looksLikeANode(value) &&
- testFunction.call(
- this,
- value,
- typeof index === 'number' ? index : undefined,
- parent || undefined
- )
- )
- }
-}
-
-function lib_ok() {
- return true
-}
-
-/**
- * @param {unknown} value
- * @returns {value is Node}
- */
-function looksLikeANode(value) {
- return value !== null && typeof value === 'object' && 'type' in value
-}
-
-;// CONCATENATED MODULE: ./node_modules/_unist-util-visit-parents@6.0.1@unist-util-visit-parents/lib/color.js
-/**
- * @param {string} d
- * @returns {string}
- */
-function color(d) {
- return d
-}
-
-;// CONCATENATED MODULE: ./node_modules/_unist-util-visit-parents@6.0.1@unist-util-visit-parents/lib/index.js
-/**
- * @typedef {import('unist').Node} UnistNode
- * @typedef {import('unist').Parent} UnistParent
- */
-
-/**
- * @typedef {Exclude | undefined} Test
- * Test from `unist-util-is`.
- *
- * Note: we have remove and add `undefined`, because otherwise when generating
- * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,
- * which doesn’t work when publishing on npm.
- */
-
-/**
- * @typedef {(
- * Fn extends (value: any) => value is infer Thing
- * ? Thing
- * : Fallback
- * )} Predicate
- * Get the value of a type guard `Fn`.
- * @template Fn
- * Value; typically function that is a type guard (such as `(x): x is Y`).
- * @template Fallback
- * Value to yield if `Fn` is not a type guard.
- */
-
-/**
- * @typedef {(
- * Check extends null | undefined // No test.
- * ? Value
- * : Value extends {type: Check} // String (type) test.
- * ? Value
- * : Value extends Check // Partial test.
- * ? Value
- * : Check extends Function // Function test.
- * ? Predicate extends Value
- * ? Predicate
- * : never
- * : never // Some other test?
- * )} MatchesOne
- * Check whether a node matches a primitive check in the type system.
- * @template Value
- * Value; typically unist `Node`.
- * @template Check
- * Value; typically `unist-util-is`-compatible test, but not arrays.
- */
-
-/**
- * @typedef {(
- * Check extends Array
- * ? MatchesOne
- * : MatchesOne
- * )} Matches
- * Check whether a node matches a check in the type system.
- * @template Value
- * Value; typically unist `Node`.
- * @template Check
- * Value; typically `unist-util-is`-compatible test.
- */
-
-/**
- * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint
- * Number; capped reasonably.
- */
-
-/**
- * @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
- * Increment a number in the type system.
- * @template {Uint} [I=0]
- * Index.
- */
-
-/**
- * @typedef {(
- * Node extends UnistParent
- * ? Node extends {children: Array}
- * ? Child extends Children ? Node : never
- * : never
- * : never
- * )} InternalParent
- * Collect nodes that can be parents of `Child`.
- * @template {UnistNode} Node
- * All node types in a tree.
- * @template {UnistNode} Child
- * Node to search for.
- */
-
-/**
- * @typedef {InternalParent, Child>} Parent
- * Collect nodes in `Tree` that can be parents of `Child`.
- * @template {UnistNode} Tree
- * All node types in a tree.
- * @template {UnistNode} Child
- * Node to search for.
- */
-
-/**
- * @typedef {(
- * Depth extends Max
- * ? never
- * :
- * | InternalParent
- * | InternalAncestor, Max, Increment>
- * )} InternalAncestor
- * Collect nodes in `Tree` that can be ancestors of `Child`.
- * @template {UnistNode} Node
- * All node types in a tree.
- * @template {UnistNode} Child
- * Node to search for.
- * @template {Uint} [Max=10]
- * Max; searches up to this depth.
- * @template {Uint} [Depth=0]
- * Current depth.
- */
-
-/**
- * @typedef {InternalAncestor, Child>} Ancestor
- * Collect nodes in `Tree` that can be ancestors of `Child`.
- * @template {UnistNode} Tree
- * All node types in a tree.
- * @template {UnistNode} Child
- * Node to search for.
- */
-
-/**
- * @typedef {(
- * Tree extends UnistParent
- * ? Depth extends Max
- * ? Tree
- * : Tree | InclusiveDescendant>
- * : Tree
- * )} InclusiveDescendant
- * Collect all (inclusive) descendants of `Tree`.
- *
- * > 👉 **Note**: for performance reasons, this seems to be the fastest way to
- * > recurse without actually running into an infinite loop, which the
- * > previous version did.
- * >
- * > Practically, a max of `2` is typically enough assuming a `Root` is
- * > passed, but it doesn’t improve performance.
- * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.
- * > Using up to `10` doesn’t hurt or help either.
- * @template {UnistNode} Tree
- * Tree type.
- * @template {Uint} [Max=10]
- * Max; searches up to this depth.
- * @template {Uint} [Depth=0]
- * Current depth.
- */
-
-/**
- * @typedef {'skip' | boolean} Action
- * Union of the action types.
- *
- * @typedef {number} Index
- * Move to the sibling at `index` next (after node itself is completely
- * traversed).
- *
- * Useful if mutating the tree, such as removing the node the visitor is
- * currently on, or any of its previous siblings.
- * Results less than 0 or greater than or equal to `children.length` stop
- * traversing the parent.
- *
- * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple
- * List with one or two values, the first an action, the second an index.
- *
- * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult
- * Any value that can be returned from a visitor.
- */
-
-/**
- * @callback Visitor
- * Handle a node (matching `test`, if given).
- *
- * Visitors are free to transform `node`.
- * They can also transform the parent of node (the last of `ancestors`).
- *
- * Replacing `node` itself, if `SKIP` is not returned, still causes its
- * descendants to be walked (which is a bug).
- *
- * When adding or removing previous siblings of `node` (or next siblings, in
- * case of reverse), the `Visitor` should return a new `Index` to specify the
- * sibling to traverse after `node` is traversed.
- * Adding or removing next siblings of `node` (or previous siblings, in case
- * of reverse) is handled as expected without needing to return a new `Index`.
- *
- * Removing the children property of an ancestor still results in them being
- * traversed.
- * @param {Visited} node
- * Found node.
- * @param {Array} ancestors
- * Ancestors of `node`.
- * @returns {VisitorResult}
- * What to do next.
- *
- * An `Index` is treated as a tuple of `[CONTINUE, Index]`.
- * An `Action` is treated as a tuple of `[Action]`.
- *
- * Passing a tuple back only makes sense if the `Action` is `SKIP`.
- * When the `Action` is `EXIT`, that action can be returned.
- * When the `Action` is `CONTINUE`, `Index` can be returned.
- * @template {UnistNode} [Visited=UnistNode]
- * Visited node type.
- * @template {UnistParent} [VisitedParents=UnistParent]
- * Ancestor type.
- */
-
-/**
- * @typedef {Visitor, Check>, Ancestor, Check>>>} BuildVisitor
- * Build a typed `Visitor` function from a tree and a test.
- *
- * It will infer which values are passed as `node` and which as `parents`.
- * @template {UnistNode} [Tree=UnistNode]
- * Tree type.
- * @template {Test} [Check=Test]
- * Test type.
- */
-
-
-
-
-/** @type {Readonly} */
-const lib_empty = []
-
-/**
- * Continue traversing as normal.
- */
-const CONTINUE = true
-
-/**
- * Stop traversing immediately.
- */
-const EXIT = false
-
-/**
- * Do not traverse this node’s children.
- */
-const SKIP = 'skip'
-
-/**
- * Visit nodes, with ancestral information.
- *
- * This algorithm performs *depth-first* *tree traversal* in *preorder*
- * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
- *
- * You can choose for which nodes `visitor` is called by passing a `test`.
- * For complex tests, you should test yourself in `visitor`, as it will be
- * faster and will have improved type information.
- *
- * Walking the tree is an intensive task.
- * Make use of the return values of the visitor when possible.
- * Instead of walking a tree multiple times, walk it once, use `unist-util-is`
- * to check if a node matches, and then perform different operations.
- *
- * You can change the tree.
- * See `Visitor` for more info.
- *
- * @overload
- * @param {Tree} tree
- * @param {Check} check
- * @param {BuildVisitor} visitor
- * @param {boolean | null | undefined} [reverse]
- * @returns {undefined}
- *
- * @overload
- * @param {Tree} tree
- * @param {BuildVisitor} visitor
- * @param {boolean | null | undefined} [reverse]
- * @returns {undefined}
- *
- * @param {UnistNode} tree
- * Tree to traverse.
- * @param {Visitor | Test} test
- * `unist-util-is`-compatible test
- * @param {Visitor | boolean | null | undefined} [visitor]
- * Handle each node.
- * @param {boolean | null | undefined} [reverse]
- * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
- * @returns {undefined}
- * Nothing.
- *
- * @template {UnistNode} Tree
- * Node type.
- * @template {Test} Check
- * `unist-util-is`-compatible test.
- */
-function visitParents(tree, test, visitor, reverse) {
- /** @type {Test} */
- let check
-
- if (typeof test === 'function' && typeof visitor !== 'function') {
- reverse = visitor
- // @ts-expect-error no visitor given, so `visitor` is test.
- visitor = test
- } else {
- // @ts-expect-error visitor given, so `test` isn’t a visitor.
- check = test
- }
-
- const is = convert(check)
- const step = reverse ? -1 : 1
-
- factory(tree, undefined, [])()
-
- /**
- * @param {UnistNode} node
- * @param {number | undefined} index
- * @param {Array} parents
- */
- function factory(node, index, parents) {
- const value = /** @type {Record} */ (
- node && typeof node === 'object' ? node : {}
- )
-
- if (typeof value.type === 'string') {
- const name =
- // `hast`
- typeof value.tagName === 'string'
- ? value.tagName
- : // `xast`
- typeof value.name === 'string'
- ? value.name
- : undefined
-
- Object.defineProperty(visit, 'name', {
- value:
- 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'
- })
- }
-
- return visit
-
- function visit() {
- /** @type {Readonly} */
- let result = lib_empty
- /** @type {Readonly} */
- let subresult
- /** @type {number} */
- let offset
- /** @type {Array} */
- let grandparents
-
- if (!test || is(node, index, parents[parents.length - 1] || undefined)) {
- // @ts-expect-error: `visitor` is now a visitor.
- result = toResult(visitor(node, parents))
-
- if (result[0] === EXIT) {
- return result
- }
- }
-
- if ('children' in node && node.children) {
- const nodeAsParent = /** @type {UnistParent} */ (node)
-
- if (nodeAsParent.children && result[0] !== SKIP) {
- offset = (reverse ? nodeAsParent.children.length : -1) + step
- grandparents = parents.concat(nodeAsParent)
-
- while (offset > -1 && offset < nodeAsParent.children.length) {
- const child = nodeAsParent.children[offset]
-
- subresult = factory(child, offset, grandparents)()
-
- if (subresult[0] === EXIT) {
- return subresult
- }
-
- offset =
- typeof subresult[1] === 'number' ? subresult[1] : offset + step
- }
- }
- }
-
- return result
- }
- }
-}
-
-/**
- * Turn a return value into a clean result.
- *
- * @param {VisitorResult} value
- * Valid return values from visitors.
- * @returns {Readonly}
- * Clean result.
- */
-function toResult(value) {
- if (Array.isArray(value)) {
- return value
- }
-
- if (typeof value === 'number') {
- return [CONTINUE, value]
- }
-
- return value === null || value === undefined ? lib_empty : [value]
-}
-
-;// CONCATENATED MODULE: ./node_modules/_unist-util-visit@5.0.0@unist-util-visit/lib/index.js
-/**
- * @typedef {import('unist').Node} UnistNode
- * @typedef {import('unist').Parent} UnistParent
- * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult
- */
-
-/**
- * @typedef {Exclude | undefined} Test
- * Test from `unist-util-is`.
- *
- * Note: we have remove and add `undefined`, because otherwise when generating
- * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,
- * which doesn’t work when publishing on npm.
- */
-
-// To do: use types from `unist-util-visit-parents` when it’s released.
-
-/**
- * @typedef {(
- * Fn extends (value: any) => value is infer Thing
- * ? Thing
- * : Fallback
- * )} Predicate
- * Get the value of a type guard `Fn`.
- * @template Fn
- * Value; typically function that is a type guard (such as `(x): x is Y`).
- * @template Fallback
- * Value to yield if `Fn` is not a type guard.
- */
-
-/**
- * @typedef {(
- * Check extends null | undefined // No test.
- * ? Value
- * : Value extends {type: Check} // String (type) test.
- * ? Value
- * : Value extends Check // Partial test.
- * ? Value
- * : Check extends Function // Function test.
- * ? Predicate extends Value
- * ? Predicate
- * : never
- * : never // Some other test?
- * )} MatchesOne
- * Check whether a node matches a primitive check in the type system.
- * @template Value
- * Value; typically unist `Node`.
- * @template Check
- * Value; typically `unist-util-is`-compatible test, but not arrays.
- */
-
-/**
- * @typedef {(
- * Check extends Array
- * ? MatchesOne
- * : MatchesOne
- * )} Matches
- * Check whether a node matches a check in the type system.
- * @template Value
- * Value; typically unist `Node`.
- * @template Check
- * Value; typically `unist-util-is`-compatible test.
- */
-
-/**
- * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint
- * Number; capped reasonably.
- */
-
-/**
- * @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
- * Increment a number in the type system.
- * @template {Uint} [I=0]
- * Index.
- */
-
-/**
- * @typedef {(
- * Node extends UnistParent
- * ? Node extends {children: Array}
- * ? Child extends Children ? Node : never
- * : never
- * : never
- * )} InternalParent
- * Collect nodes that can be parents of `Child`.
- * @template {UnistNode} Node
- * All node types in a tree.
- * @template {UnistNode} Child
- * Node to search for.
- */
-
-/**
- * @typedef {InternalParent, Child>} Parent
- * Collect nodes in `Tree` that can be parents of `Child`.
- * @template {UnistNode} Tree
- * All node types in a tree.
- * @template {UnistNode} Child
- * Node to search for.
- */
-
-/**
- * @typedef {(
- * Depth extends Max
- * ? never
- * :
- * | InternalParent
- * | InternalAncestor, Max, Increment>
- * )} InternalAncestor
- * Collect nodes in `Tree` that can be ancestors of `Child`.
- * @template {UnistNode} Node
- * All node types in a tree.
- * @template {UnistNode} Child
- * Node to search for.
- * @template {Uint} [Max=10]
- * Max; searches up to this depth.
- * @template {Uint} [Depth=0]
- * Current depth.
- */
-
-/**
- * @typedef {(
- * Tree extends UnistParent
- * ? Depth extends Max
- * ? Tree
- * : Tree | InclusiveDescendant>
- * : Tree
- * )} InclusiveDescendant
- * Collect all (inclusive) descendants of `Tree`.
- *
- * > 👉 **Note**: for performance reasons, this seems to be the fastest way to
- * > recurse without actually running into an infinite loop, which the
- * > previous version did.
- * >
- * > Practically, a max of `2` is typically enough assuming a `Root` is
- * > passed, but it doesn’t improve performance.
- * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.
- * > Using up to `10` doesn’t hurt or help either.
- * @template {UnistNode} Tree
- * Tree type.
- * @template {Uint} [Max=10]
- * Max; searches up to this depth.
- * @template {Uint} [Depth=0]
- * Current depth.
- */
-
-/**
- * @callback Visitor
- * Handle a node (matching `test`, if given).
- *
- * Visitors are free to transform `node`.
- * They can also transform `parent`.
- *
- * Replacing `node` itself, if `SKIP` is not returned, still causes its
- * descendants to be walked (which is a bug).
- *
- * When adding or removing previous siblings of `node` (or next siblings, in
- * case of reverse), the `Visitor` should return a new `Index` to specify the
- * sibling to traverse after `node` is traversed.
- * Adding or removing next siblings of `node` (or previous siblings, in case
- * of reverse) is handled as expected without needing to return a new `Index`.
- *
- * Removing the children property of `parent` still results in them being
- * traversed.
- * @param {Visited} node
- * Found node.
- * @param {Visited extends UnistNode ? number | undefined : never} index
- * Index of `node` in `parent`.
- * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
- * Parent of `node`.
- * @returns {VisitorResult}
- * What to do next.
- *
- * An `Index` is treated as a tuple of `[CONTINUE, Index]`.
- * An `Action` is treated as a tuple of `[Action]`.
- *
- * Passing a tuple back only makes sense if the `Action` is `SKIP`.
- * When the `Action` is `EXIT`, that action can be returned.
- * When the `Action` is `CONTINUE`, `Index` can be returned.
- * @template {UnistNode} [Visited=UnistNode]
- * Visited node type.
- * @template {UnistParent} [Ancestor=UnistParent]
- * Ancestor type.
- */
-
-/**
- * @typedef {Visitor>} BuildVisitorFromMatch
- * Build a typed `Visitor` function from a node and all possible parents.
- *
- * It will infer which values are passed as `node` and which as `parent`.
- * @template {UnistNode} Visited
- * Node type.
- * @template {UnistParent} Ancestor
- * Parent type.
- */
-
-/**
- * @typedef {(
- * BuildVisitorFromMatch<
- * Matches,
- * Extract
- * >
- * )} BuildVisitorFromDescendants
- * Build a typed `Visitor` function from a list of descendants and a test.
- *
- * It will infer which values are passed as `node` and which as `parent`.
- * @template {UnistNode} Descendant
- * Node type.
- * @template {Test} Check
- * Test type.
- */
-
-/**
- * @typedef {(
- * BuildVisitorFromDescendants<
- * InclusiveDescendant,
- * Check
- * >
- * )} BuildVisitor
- * Build a typed `Visitor` function from a tree and a test.
- *
- * It will infer which values are passed as `node` and which as `parent`.
- * @template {UnistNode} [Tree=UnistNode]
- * Node type.
- * @template {Test} [Check=Test]
- * Test type.
- */
-
-
-
-
-
-/**
- * Visit nodes.
- *
- * This algorithm performs *depth-first* *tree traversal* in *preorder*
- * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
- *
- * You can choose for which nodes `visitor` is called by passing a `test`.
- * For complex tests, you should test yourself in `visitor`, as it will be
- * faster and will have improved type information.
- *
- * Walking the tree is an intensive task.
- * Make use of the return values of the visitor when possible.
- * Instead of walking a tree multiple times, walk it once, use `unist-util-is`
- * to check if a node matches, and then perform different operations.
- *
- * You can change the tree.
- * See `Visitor` for more info.
- *
- * @overload
- * @param {Tree} tree
- * @param {Check} check
- * @param {BuildVisitor} visitor
- * @param {boolean | null | undefined} [reverse]
- * @returns {undefined}
- *
- * @overload
- * @param {Tree} tree
- * @param {BuildVisitor} visitor
- * @param {boolean | null | undefined} [reverse]
- * @returns {undefined}
- *
- * @param {UnistNode} tree
- * Tree to traverse.
- * @param {Visitor | Test} testOrVisitor
- * `unist-util-is`-compatible test (optional, omit to pass a visitor).
- * @param {Visitor | boolean | null | undefined} [visitorOrReverse]
- * Handle each node (when test is omitted, pass `reverse`).
- * @param {boolean | null | undefined} [maybeReverse=false]
- * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
- * @returns {undefined}
- * Nothing.
- *
- * @template {UnistNode} Tree
- * Node type.
- * @template {Test} Check
- * `unist-util-is`-compatible test.
- */
-function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
- /** @type {boolean | null | undefined} */
- let reverse
- /** @type {Test} */
- let test
- /** @type {Visitor} */
- let visitor
-
- if (
- typeof testOrVisitor === 'function' &&
- typeof visitorOrReverse !== 'function'
- ) {
- test = undefined
- visitor = testOrVisitor
- reverse = visitorOrReverse
- } else {
- // @ts-expect-error: assume the overload with test was given.
- test = testOrVisitor
- // @ts-expect-error: assume the overload with test was given.
- visitor = visitorOrReverse
- reverse = maybeReverse
- }
-
- visitParents(tree, test, overload, reverse)
-
- /**
- * @param {UnistNode} node
- * @param {Array} parents
- */
- function overload(node, parents) {
- const parent = parents[parents.length - 1]
- const index = parent ? parent.children.indexOf(node) : undefined
- return visitor(node, index, parent)
- }
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/blockquote.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('mdast').Blockquote} Blockquote
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `blockquote` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {Blockquote} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function blockquote(state, node) {
- /** @type {Element} */
- const result = {
- type: 'element',
- tagName: 'blockquote',
- properties: {},
- children: state.wrap(state.all(node), true)
- }
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/break.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('hast').Text} Text
- * @typedef {import('mdast').Break} Break
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `break` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {Break} node
- * mdast node.
- * @returns {Array}
- * hast element content.
- */
-function hardBreak(state, node) {
- /** @type {Element} */
- const result = {type: 'element', tagName: 'br', properties: {}, children: []}
- state.patch(node, result)
- return [state.applyData(node, result), {type: 'text', value: '\n'}]
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/code.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('hast').Properties} Properties
- * @typedef {import('mdast').Code} Code
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `code` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {Code} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function code(state, node) {
- const value = node.value ? node.value + '\n' : ''
- /** @type {Properties} */
- const properties = {}
-
- if (node.lang) {
- properties.className = ['language-' + node.lang]
- }
-
- // Create ``.
- /** @type {Element} */
- let result = {
- type: 'element',
- tagName: 'code',
- properties,
- children: [{type: 'text', value}]
- }
-
- if (node.meta) {
- result.data = {meta: node.meta}
- }
-
- state.patch(node, result)
- result = state.applyData(node, result)
-
- // Create ``.
- result = {type: 'element', tagName: 'pre', properties: {}, children: [result]}
- state.patch(node, result)
- return result
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/delete.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('mdast').Delete} Delete
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `delete` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {Delete} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function strikethrough(state, node) {
- /** @type {Element} */
- const result = {
- type: 'element',
- tagName: 'del',
- properties: {},
- children: state.all(node)
- }
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/emphasis.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('mdast').Emphasis} Emphasis
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `emphasis` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {Emphasis} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function emphasis(state, node) {
- /** @type {Element} */
- const result = {
- type: 'element',
- tagName: 'em',
- properties: {},
- children: state.all(node)
- }
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/footnote-reference.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('mdast').FootnoteReference} FootnoteReference
- * @typedef {import('../state.js').State} State
- */
-
-
-
-/**
- * Turn an mdast `footnoteReference` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {FootnoteReference} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function footnoteReference(state, node) {
- const clobberPrefix =
- typeof state.options.clobberPrefix === 'string'
- ? state.options.clobberPrefix
- : 'user-content-'
- const id = String(node.identifier).toUpperCase()
- const safeId = normalizeUri(id.toLowerCase())
- const index = state.footnoteOrder.indexOf(id)
- /** @type {number} */
- let counter
-
- let reuseCounter = state.footnoteCounts.get(id)
-
- if (reuseCounter === undefined) {
- reuseCounter = 0
- state.footnoteOrder.push(id)
- counter = state.footnoteOrder.length
- } else {
- counter = index + 1
- }
-
- reuseCounter += 1
- state.footnoteCounts.set(id, reuseCounter)
-
- /** @type {Element} */
- const link = {
- type: 'element',
- tagName: 'a',
- properties: {
- href: '#' + clobberPrefix + 'fn-' + safeId,
- id:
- clobberPrefix +
- 'fnref-' +
- safeId +
- (reuseCounter > 1 ? '-' + reuseCounter : ''),
- dataFootnoteRef: true,
- ariaDescribedBy: ['footnote-label']
- },
- children: [{type: 'text', value: String(counter)}]
- }
- state.patch(node, link)
-
- /** @type {Element} */
- const sup = {
- type: 'element',
- tagName: 'sup',
- properties: {},
- children: [link]
- }
- state.patch(node, sup)
- return state.applyData(node, sup)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/heading.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('mdast').Heading} Heading
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `heading` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {Heading} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function heading(state, node) {
- /** @type {Element} */
- const result = {
- type: 'element',
- tagName: 'h' + node.depth,
- properties: {},
- children: state.all(node)
- }
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/html.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('mdast').Html} Html
- * @typedef {import('../state.js').State} State
- * @typedef {import('../../index.js').Raw} Raw
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `html` node into hast (`raw` node in dangerous mode, otherwise
- * nothing).
- *
- * @param {State} state
- * Info passed around.
- * @param {Html} node
- * mdast node.
- * @returns {Element | Raw | undefined}
- * hast node.
- */
-function html_html(state, node) {
- if (state.options.allowDangerousHtml) {
- /** @type {Raw} */
- const result = {type: 'raw', value: node.value}
- state.patch(node, result)
- return state.applyData(node, result)
- }
-
- return undefined
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/revert.js
-/**
- * @typedef {import('hast').ElementContent} ElementContent
- *
- * @typedef {import('mdast').Nodes} Nodes
- * @typedef {import('mdast').Reference} Reference
- *
- * @typedef {import('./state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Return the content of a reference without definition as plain text.
- *
- * @param {State} state
- * Info passed around.
- * @param {Extract} node
- * Reference node (image, link).
- * @returns {Array}
- * hast content.
- */
-function revert(state, node) {
- const subtype = node.referenceType
- let suffix = ']'
-
- if (subtype === 'collapsed') {
- suffix += '[]'
- } else if (subtype === 'full') {
- suffix += '[' + (node.label || node.identifier) + ']'
- }
-
- if (node.type === 'imageReference') {
- return [{type: 'text', value: '![' + node.alt + suffix}]
- }
-
- const contents = state.all(node)
- const head = contents[0]
-
- if (head && head.type === 'text') {
- head.value = '[' + head.value
- } else {
- contents.unshift({type: 'text', value: '['})
- }
-
- const tail = contents[contents.length - 1]
-
- if (tail && tail.type === 'text') {
- tail.value += suffix
- } else {
- contents.push({type: 'text', value: suffix})
- }
-
- return contents
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/image-reference.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('hast').ElementContent} ElementContent
- * @typedef {import('hast').Properties} Properties
- * @typedef {import('mdast').ImageReference} ImageReference
- * @typedef {import('../state.js').State} State
- */
-
-
-
-
-/**
- * Turn an mdast `imageReference` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {ImageReference} node
- * mdast node.
- * @returns {Array | ElementContent}
- * hast node.
- */
-function imageReference(state, node) {
- const id = String(node.identifier).toUpperCase()
- const definition = state.definitionById.get(id)
-
- if (!definition) {
- return revert(state, node)
- }
-
- /** @type {Properties} */
- const properties = {src: normalizeUri(definition.url || ''), alt: node.alt}
-
- if (definition.title !== null && definition.title !== undefined) {
- properties.title = definition.title
- }
-
- /** @type {Element} */
- const result = {type: 'element', tagName: 'img', properties, children: []}
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/image.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('hast').Properties} Properties
- * @typedef {import('mdast').Image} Image
- * @typedef {import('../state.js').State} State
- */
-
-
-
-/**
- * Turn an mdast `image` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {Image} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function image_image(state, node) {
- /** @type {Properties} */
- const properties = {src: normalizeUri(node.url)}
-
- if (node.alt !== null && node.alt !== undefined) {
- properties.alt = node.alt
- }
-
- if (node.title !== null && node.title !== undefined) {
- properties.title = node.title
- }
-
- /** @type {Element} */
- const result = {type: 'element', tagName: 'img', properties, children: []}
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/inline-code.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('hast').Text} Text
- * @typedef {import('mdast').InlineCode} InlineCode
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `inlineCode` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {InlineCode} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function inlineCode(state, node) {
- /** @type {Text} */
- const text = {type: 'text', value: node.value.replace(/\r?\n|\r/g, ' ')}
- state.patch(node, text)
-
- /** @type {Element} */
- const result = {
- type: 'element',
- tagName: 'code',
- properties: {},
- children: [text]
- }
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/link-reference.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('hast').ElementContent} ElementContent
- * @typedef {import('hast').Properties} Properties
- * @typedef {import('mdast').LinkReference} LinkReference
- * @typedef {import('../state.js').State} State
- */
-
-
-
-
-/**
- * Turn an mdast `linkReference` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {LinkReference} node
- * mdast node.
- * @returns {Array | ElementContent}
- * hast node.
- */
-function linkReference(state, node) {
- const id = String(node.identifier).toUpperCase()
- const definition = state.definitionById.get(id)
-
- if (!definition) {
- return revert(state, node)
- }
-
- /** @type {Properties} */
- const properties = {href: normalizeUri(definition.url || '')}
-
- if (definition.title !== null && definition.title !== undefined) {
- properties.title = definition.title
- }
-
- /** @type {Element} */
- const result = {
- type: 'element',
- tagName: 'a',
- properties,
- children: state.all(node)
- }
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/link.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('hast').Properties} Properties
- * @typedef {import('mdast').Link} Link
- * @typedef {import('../state.js').State} State
- */
-
-
-
-/**
- * Turn an mdast `link` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {Link} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function link_link(state, node) {
- /** @type {Properties} */
- const properties = {href: normalizeUri(node.url)}
-
- if (node.title !== null && node.title !== undefined) {
- properties.title = node.title
- }
-
- /** @type {Element} */
- const result = {
- type: 'element',
- tagName: 'a',
- properties,
- children: state.all(node)
- }
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/list-item.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('hast').ElementContent} ElementContent
- * @typedef {import('hast').Properties} Properties
- * @typedef {import('mdast').ListItem} ListItem
- * @typedef {import('mdast').Parents} Parents
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `listItem` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {ListItem} node
- * mdast node.
- * @param {Parents | undefined} parent
- * Parent of `node`.
- * @returns {Element}
- * hast node.
- */
-function listItem(state, node, parent) {
- const results = state.all(node)
- const loose = parent ? listLoose(parent) : listItemLoose(node)
- /** @type {Properties} */
- const properties = {}
- /** @type {Array} */
- const children = []
-
- if (typeof node.checked === 'boolean') {
- const head = results[0]
- /** @type {Element} */
- let paragraph
-
- if (head && head.type === 'element' && head.tagName === 'p') {
- paragraph = head
- } else {
- paragraph = {type: 'element', tagName: 'p', properties: {}, children: []}
- results.unshift(paragraph)
- }
-
- if (paragraph.children.length > 0) {
- paragraph.children.unshift({type: 'text', value: ' '})
- }
-
- paragraph.children.unshift({
- type: 'element',
- tagName: 'input',
- properties: {type: 'checkbox', checked: node.checked, disabled: true},
- children: []
- })
-
- // According to github-markdown-css, this class hides bullet.
- // See: .
- properties.className = ['task-list-item']
- }
-
- let index = -1
-
- while (++index < results.length) {
- const child = results[index]
-
- // Add eols before nodes, except if this is a loose, first paragraph.
- if (
- loose ||
- index !== 0 ||
- child.type !== 'element' ||
- child.tagName !== 'p'
- ) {
- children.push({type: 'text', value: '\n'})
- }
-
- if (child.type === 'element' && child.tagName === 'p' && !loose) {
- children.push(...child.children)
- } else {
- children.push(child)
- }
- }
-
- const tail = results[results.length - 1]
-
- // Add a final eol.
- if (tail && (loose || tail.type !== 'element' || tail.tagName !== 'p')) {
- children.push({type: 'text', value: '\n'})
- }
-
- /** @type {Element} */
- const result = {type: 'element', tagName: 'li', properties, children}
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-/**
- * @param {Parents} node
- * @return {Boolean}
- */
-function listLoose(node) {
- let loose = false
- if (node.type === 'list') {
- loose = node.spread || false
- const children = node.children
- let index = -1
-
- while (!loose && ++index < children.length) {
- loose = listItemLoose(children[index])
- }
- }
-
- return loose
-}
-
-/**
- * @param {ListItem} node
- * @return {Boolean}
- */
-function listItemLoose(node) {
- const spread = node.spread
-
- return spread === null || spread === undefined
- ? node.children.length > 1
- : spread
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/list.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('hast').Properties} Properties
- * @typedef {import('mdast').List} List
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `list` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {List} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function list_list(state, node) {
- /** @type {Properties} */
- const properties = {}
- const results = state.all(node)
- let index = -1
-
- if (typeof node.start === 'number' && node.start !== 1) {
- properties.start = node.start
- }
-
- // Like GitHub, add a class for custom styling.
- while (++index < results.length) {
- const child = results[index]
-
- if (
- child.type === 'element' &&
- child.tagName === 'li' &&
- child.properties &&
- Array.isArray(child.properties.className) &&
- child.properties.className.includes('task-list-item')
- ) {
- properties.className = ['contains-task-list']
- break
- }
- }
-
- /** @type {Element} */
- const result = {
- type: 'element',
- tagName: node.ordered ? 'ol' : 'ul',
- properties,
- children: state.wrap(results, true)
- }
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/paragraph.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('mdast').Paragraph} Paragraph
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `paragraph` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {Paragraph} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function paragraph(state, node) {
- /** @type {Element} */
- const result = {
- type: 'element',
- tagName: 'p',
- properties: {},
- children: state.all(node)
- }
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/root.js
-/**
- * @typedef {import('hast').Parents} HastParents
- * @typedef {import('hast').Root} HastRoot
- * @typedef {import('mdast').Root} MdastRoot
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `root` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {MdastRoot} node
- * mdast node.
- * @returns {HastParents}
- * hast node.
- */
-function root_root(state, node) {
- /** @type {HastRoot} */
- const result = {type: 'root', children: state.wrap(state.all(node))}
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/strong.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('mdast').Strong} Strong
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `strong` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {Strong} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function strong(state, node) {
- /** @type {Element} */
- const result = {
- type: 'element',
- tagName: 'strong',
- properties: {},
- children: state.all(node)
- }
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/table.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('mdast').Table} Table
- * @typedef {import('../state.js').State} State
- */
-
-
-
-/**
- * Turn an mdast `table` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {Table} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function table(state, node) {
- const rows = state.all(node)
- const firstRow = rows.shift()
- /** @type {Array} */
- const tableContent = []
-
- if (firstRow) {
- /** @type {Element} */
- const head = {
- type: 'element',
- tagName: 'thead',
- properties: {},
- children: state.wrap([firstRow], true)
- }
- state.patch(node.children[0], head)
- tableContent.push(head)
- }
-
- if (rows.length > 0) {
- /** @type {Element} */
- const body = {
- type: 'element',
- tagName: 'tbody',
- properties: {},
- children: state.wrap(rows, true)
- }
-
- const start = pointStart(node.children[1])
- const end = pointEnd(node.children[node.children.length - 1])
- if (start && end) body.position = {start, end}
- tableContent.push(body)
- }
-
- /** @type {Element} */
- const result = {
- type: 'element',
- tagName: 'table',
- properties: {},
- children: state.wrap(tableContent, true)
- }
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/table-row.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('hast').ElementContent} ElementContent
- * @typedef {import('hast').Properties} Properties
- * @typedef {import('mdast').Parents} Parents
- * @typedef {import('mdast').TableRow} TableRow
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `tableRow` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {TableRow} node
- * mdast node.
- * @param {Parents | undefined} parent
- * Parent of `node`.
- * @returns {Element}
- * hast node.
- */
-function tableRow(state, node, parent) {
- const siblings = parent ? parent.children : undefined
- // Generate a body row when without parent.
- const rowIndex = siblings ? siblings.indexOf(node) : 1
- const tagName = rowIndex === 0 ? 'th' : 'td'
- // To do: option to use `style`?
- const align = parent && parent.type === 'table' ? parent.align : undefined
- const length = align ? align.length : node.children.length
- let cellIndex = -1
- /** @type {Array} */
- const cells = []
-
- while (++cellIndex < length) {
- // Note: can also be undefined.
- const cell = node.children[cellIndex]
- /** @type {Properties} */
- const properties = {}
- const alignValue = align ? align[cellIndex] : undefined
-
- if (alignValue) {
- properties.align = alignValue
- }
-
- /** @type {Element} */
- let result = {type: 'element', tagName, properties, children: []}
-
- if (cell) {
- result.children = state.all(cell)
- state.patch(cell, result)
- result = state.applyData(cell, result)
- }
-
- cells.push(result)
- }
-
- /** @type {Element} */
- const result = {
- type: 'element',
- tagName: 'tr',
- properties: {},
- children: state.wrap(cells, true)
- }
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/table-cell.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('mdast').TableCell} TableCell
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `tableCell` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {TableCell} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function tableCell(state, node) {
- // Note: this function is normally not called: see `table-row` for how rows
- // and their cells are compiled.
- /** @type {Element} */
- const result = {
- type: 'element',
- tagName: 'td', // Assume body cell.
- properties: {},
- children: state.all(node)
- }
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_trim-lines@3.0.1@trim-lines/index.js
-const tab = 9 /* `\t` */
-const space = 32 /* ` ` */
-
-/**
- * Remove initial and final spaces and tabs at the line breaks in `value`.
- * Does not trim initial and final spaces and tabs of the value itself.
- *
- * @param {string} value
- * Value to trim.
- * @returns {string}
- * Trimmed value.
- */
-function trimLines(value) {
- const source = String(value)
- const search = /\r?\n|\r/g
- let match = search.exec(source)
- let last = 0
- /** @type {Array} */
- const lines = []
-
- while (match) {
- lines.push(
- trimLine(source.slice(last, match.index), last > 0, true),
- match[0]
- )
-
- last = match.index + match[0].length
- match = search.exec(source)
- }
-
- lines.push(trimLine(source.slice(last), last > 0, false))
-
- return lines.join('')
-}
-
-/**
- * @param {string} value
- * Line to trim.
- * @param {boolean} start
- * Whether to trim the start of the line.
- * @param {boolean} end
- * Whether to trim the end of the line.
- * @returns {string}
- * Trimmed line.
- */
-function trimLine(value, start, end) {
- let startIndex = 0
- let endIndex = value.length
-
- if (start) {
- let code = value.codePointAt(startIndex)
-
- while (code === tab || code === space) {
- startIndex++
- code = value.codePointAt(startIndex)
- }
- }
-
- if (end) {
- let code = value.codePointAt(endIndex - 1)
-
- while (code === tab || code === space) {
- endIndex--
- code = value.codePointAt(endIndex - 1)
- }
- }
-
- return endIndex > startIndex ? value.slice(startIndex, endIndex) : ''
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/text.js
-/**
- * @typedef {import('hast').Element} HastElement
- * @typedef {import('hast').Text} HastText
- * @typedef {import('mdast').Text} MdastText
- * @typedef {import('../state.js').State} State
- */
-
-
-
-/**
- * Turn an mdast `text` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {MdastText} node
- * mdast node.
- * @returns {HastElement | HastText}
- * hast node.
- */
-function handlers_text_text(state, node) {
- /** @type {HastText} */
- const result = {type: 'text', value: trimLines(String(node.value))}
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/thematic-break.js
-/**
- * @typedef {import('hast').Element} Element
- * @typedef {import('mdast').ThematicBreak} ThematicBreak
- * @typedef {import('../state.js').State} State
- */
-
-// Make VS Code show references to the above types.
-''
-
-/**
- * Turn an mdast `thematicBreak` node into hast.
- *
- * @param {State} state
- * Info passed around.
- * @param {ThematicBreak} node
- * mdast node.
- * @returns {Element}
- * hast node.
- */
-function thematic_break_thematicBreak(state, node) {
- /** @type {Element} */
- const result = {
- type: 'element',
- tagName: 'hr',
- properties: {},
- children: []
- }
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/handlers/index.js
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/**
- * Default handlers for nodes.
- *
- * @satisfies {import('../state.js').Handlers}
- */
-const handlers_handlers = {
- blockquote: blockquote,
- break: hardBreak,
- code: code,
- delete: strikethrough,
- emphasis: emphasis,
- footnoteReference: footnoteReference,
- heading: heading,
- html: html_html,
- imageReference: imageReference,
- image: image_image,
- inlineCode: inlineCode,
- linkReference: linkReference,
- link: link_link,
- listItem: listItem,
- list: list_list,
- paragraph: paragraph,
- // @ts-expect-error: root is different, but hard to type.
- root: root_root,
- strong: strong,
- table: table,
- tableCell: tableCell,
- tableRow: tableRow,
- text: handlers_text_text,
- thematicBreak: thematic_break_thematicBreak,
- toml: ignore,
- yaml: ignore,
- definition: ignore,
- footnoteDefinition: ignore
-}
-
-// Return nothing for nodes that are ignored.
-function ignore() {
- return undefined
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/state.js
-/**
- * @typedef {import('hast').Element} HastElement
- * @typedef {import('hast').ElementContent} HastElementContent
- * @typedef {import('hast').Nodes} HastNodes
- * @typedef {import('hast').Properties} HastProperties
- * @typedef {import('hast').RootContent} HastRootContent
- * @typedef {import('hast').Text} HastText
- *
- * @typedef {import('mdast').Definition} MdastDefinition
- * @typedef {import('mdast').FootnoteDefinition} MdastFootnoteDefinition
- * @typedef {import('mdast').Nodes} MdastNodes
- * @typedef {import('mdast').Parents} MdastParents
- *
- * @typedef {import('vfile').VFile} VFile
- *
- * @typedef {import('./footer.js').FootnoteBackContentTemplate} FootnoteBackContentTemplate
- * @typedef {import('./footer.js').FootnoteBackLabelTemplate} FootnoteBackLabelTemplate
- */
-
-/**
- * @callback Handler
- * Handle a node.
- * @param {State} state
- * Info passed around.
- * @param {any} node
- * mdast node to handle.
- * @param {MdastParents | undefined} parent
- * Parent of `node`.
- * @returns {Array | HastElementContent | undefined}
- * hast node.
- *
- * @typedef {Partial>} Handlers
- * Handle nodes.
- *
- * @typedef Options
- * Configuration (optional).
- * @property {boolean | null | undefined} [allowDangerousHtml=false]
- * Whether to persist raw HTML in markdown in the hast tree (default:
- * `false`).
- * @property {string | null | undefined} [clobberPrefix='user-content-']
- * Prefix to use before the `id` property on footnotes to prevent them from
- * *clobbering* (default: `'user-content-'`).
- *
- * Pass `''` for trusted markdown and when you are careful with
- * polyfilling.
- * You could pass a different prefix.
- *
- * DOM clobbering is this:
- *
- * ```html
- *
- *
- * ```
- *
- * The above example shows that elements are made available by browsers, by
- * their ID, on the `window` object.
- * This is a security risk because you might be expecting some other variable
- * at that place.
- * It can also break polyfills.
- * Using a prefix solves these problems.
- * @property {VFile | null | undefined} [file]
- * Corresponding virtual file representing the input document (optional).
- * @property {FootnoteBackContentTemplate | string | null | undefined} [footnoteBackContent]
- * Content of the backreference back to references (default: `defaultFootnoteBackContent`).
- *
- * The default value is:
- *
- * ```js
- * function defaultFootnoteBackContent(_, rereferenceIndex) {
- * const result = [{type: 'text', value: '↩'}]
- *
- * if (rereferenceIndex > 1) {
- * result.push({
- * type: 'element',
- * tagName: 'sup',
- * properties: {},
- * children: [{type: 'text', value: String(rereferenceIndex)}]
- * })
- * }
- *
- * return result
- * }
- * ```
- *
- * This content is used in the `a` element of each backreference (the `↩`
- * links).
- * @property {FootnoteBackLabelTemplate | string | null | undefined} [footnoteBackLabel]
- * Label to describe the backreference back to references (default:
- * `defaultFootnoteBackLabel`).
- *
- * The default value is:
- *
- * ```js
- * function defaultFootnoteBackLabel(referenceIndex, rereferenceIndex) {
- * return (
- * 'Back to reference ' +
- * (referenceIndex + 1) +
- * (rereferenceIndex > 1 ? '-' + rereferenceIndex : '')
- * )
- * }
- * ```
- *
- * Change it when the markdown is not in English.
- *
- * This label is used in the `ariaLabel` property on each backreference
- * (the `↩` links).
- * It affects users of assistive technology.
- * @property {string | null | undefined} [footnoteLabel='Footnotes']
- * Textual label to use for the footnotes section (default: `'Footnotes'`).
- *
- * Change it when the markdown is not in English.
- *
- * This label is typically hidden visually (assuming a `sr-only` CSS class
- * is defined that does that) and so affects screen readers only.
- * If you do have such a class, but want to show this section to everyone,
- * pass different properties with the `footnoteLabelProperties` option.
- * @property {HastProperties | null | undefined} [footnoteLabelProperties={className: ['sr-only']}]
- * Properties to use on the footnote label (default: `{className:
- * ['sr-only']}`).
- *
- * Change it to show the label and add other properties.
- *
- * This label is typically hidden visually (assuming an `sr-only` CSS class
- * is defined that does that) and so affects screen readers only.
- * If you do have such a class, but want to show this section to everyone,
- * pass an empty string.
- * You can also add different properties.
- *
- * > **Note**: `id: 'footnote-label'` is always added, because footnote
- * > calls use it with `aria-describedby` to provide an accessible label.
- * @property {string | null | undefined} [footnoteLabelTagName='h2']
- * HTML tag name to use for the footnote label element (default: `'h2'`).
- *
- * Change it to match your document structure.
- *
- * This label is typically hidden visually (assuming a `sr-only` CSS class
- * is defined that does that) and so affects screen readers only.
- * If you do have such a class, but want to show this section to everyone,
- * pass different properties with the `footnoteLabelProperties` option.
- * @property {Handlers | null | undefined} [handlers]
- * Extra handlers for nodes (optional).
- * @property {Array | null | undefined} [passThrough]
- * List of custom mdast node types to pass through (keep) in hast (note that
- * the node itself is passed, but eventual children are transformed)
- * (optional).
- * @property {Handler | null | undefined} [unknownHandler]
- * Handler for all unknown nodes (optional).
- *
- * @typedef State
- * Info passed around.
- * @property {(node: MdastNodes) => Array} all
- * Transform the children of an mdast parent to hast.
- * @property {(from: MdastNodes, to: Type) => HastElement | Type} applyData
- * Honor the `data` of `from`, and generate an element instead of `node`.
- * @property {Map} definitionById
- * Definitions by their identifier.
- * @property {Map} footnoteById
- * Footnote definitions by their identifier.
- * @property {Map} footnoteCounts
- * Counts for how often the same footnote was called.
- * @property {Array} footnoteOrder
- * Identifiers of order when footnote calls first appear in tree order.
- * @property {Handlers} handlers
- * Applied handlers.
- * @property {(node: MdastNodes, parent: MdastParents | undefined) => Array | HastElementContent | undefined} one
- * Transform an mdast node to hast.
- * @property {Options} options
- * Configuration.
- * @property {(from: MdastNodes, node: HastNodes) => undefined} patch
- * Copy a node’s positional info.
- * @property {(nodes: Array, loose?: boolean | undefined) => Array} wrap
- * Wrap `nodes` with line endings between each node, adds initial/final line endings when `loose`.
- */
-
-
-
-
-
-
-const state_own = {}.hasOwnProperty
-
-/** @type {Options} */
-const state_emptyOptions = {}
-
-/**
- * Create `state` from an mdast tree.
- *
- * @param {MdastNodes} tree
- * mdast node to transform.
- * @param {Options | null | undefined} [options]
- * Configuration (optional).
- * @returns {State}
- * `state` function.
- */
-function createState(tree, options) {
- const settings = options || state_emptyOptions
- /** @type {Map} */
- const definitionById = new Map()
- /** @type {Map} */
- const footnoteById = new Map()
- /** @type {Map} */
- const footnoteCounts = new Map()
- /** @type {Handlers} */
- // @ts-expect-error: the root handler returns a root.
- // Hard to type.
- const handlers = {...handlers_handlers, ...settings.handlers}
-
- /** @type {State} */
- const state = {
- all,
- applyData,
- definitionById,
- footnoteById,
- footnoteCounts,
- footnoteOrder: [],
- handlers,
- one,
- options: settings,
- patch,
- wrap
- }
-
- visit(tree, function (node) {
- if (node.type === 'definition' || node.type === 'footnoteDefinition') {
- const map = node.type === 'definition' ? definitionById : footnoteById
- const id = String(node.identifier).toUpperCase()
-
- // Mimick CM behavior of link definitions.
- // See: .
- if (!map.has(id)) {
- // @ts-expect-error: node type matches map.
- map.set(id, node)
- }
- }
- })
-
- return state
-
- /**
- * Transform an mdast node into a hast node.
- *
- * @param {MdastNodes} node
- * mdast node.
- * @param {MdastParents | undefined} [parent]
- * Parent of `node`.
- * @returns {Array | HastElementContent | undefined}
- * Resulting hast node.
- */
- function one(node, parent) {
- const type = node.type
- const handle = state.handlers[type]
-
- if (state_own.call(state.handlers, type) && handle) {
- return handle(state, node, parent)
- }
-
- if (state.options.passThrough && state.options.passThrough.includes(type)) {
- if ('children' in node) {
- const {children, ...shallow} = node
- const result = structured_clone_esm(shallow)
- // @ts-expect-error: TS doesn’t understand…
- result.children = state.all(node)
- // @ts-expect-error: TS doesn’t understand…
- return result
- }
-
- // @ts-expect-error: it’s custom.
- return structured_clone_esm(node)
- }
-
- const unknown = state.options.unknownHandler || defaultUnknownHandler
-
- return unknown(state, node, parent)
- }
-
- /**
- * Transform the children of an mdast node into hast nodes.
- *
- * @param {MdastNodes} parent
- * mdast node to compile
- * @returns {Array}
- * Resulting hast nodes.
- */
- function all(parent) {
- /** @type {Array} */
- const values = []
-
- if ('children' in parent) {
- const nodes = parent.children
- let index = -1
- while (++index < nodes.length) {
- const result = state.one(nodes[index], parent)
-
- // To do: see if we van clean this? Can we merge texts?
- if (result) {
- if (index && nodes[index - 1].type === 'break') {
- if (!Array.isArray(result) && result.type === 'text') {
- result.value = trimMarkdownSpaceStart(result.value)
- }
-
- if (!Array.isArray(result) && result.type === 'element') {
- const head = result.children[0]
-
- if (head && head.type === 'text') {
- head.value = trimMarkdownSpaceStart(head.value)
- }
- }
- }
-
- if (Array.isArray(result)) {
- values.push(...result)
- } else {
- values.push(result)
- }
- }
- }
- }
-
- return values
- }
-}
-
-/**
- * Copy a node’s positional info.
- *
- * @param {MdastNodes} from
- * mdast node to copy from.
- * @param {HastNodes} to
- * hast node to copy into.
- * @returns {undefined}
- * Nothing.
- */
-function patch(from, to) {
- if (from.position) to.position = position(from)
-}
-
-/**
- * Honor the `data` of `from` and maybe generate an element instead of `to`.
- *
- * @template {HastNodes} Type
- * Node type.
- * @param {MdastNodes} from
- * mdast node to use data from.
- * @param {Type} to
- * hast node to change.
- * @returns {HastElement | Type}
- * Nothing.
- */
-function applyData(from, to) {
- /** @type {HastElement | Type} */
- let result = to
-
- // Handle `data.hName`, `data.hProperties, `data.hChildren`.
- if (from && from.data) {
- const hName = from.data.hName
- const hChildren = from.data.hChildren
- const hProperties = from.data.hProperties
-
- if (typeof hName === 'string') {
- // Transforming the node resulted in an element with a different name
- // than wanted:
- if (result.type === 'element') {
- result.tagName = hName
- }
- // Transforming the node resulted in a non-element, which happens for
- // raw, text, and root nodes (unless custom handlers are passed).
- // The intent of `hName` is to create an element, but likely also to keep
- // the content around (otherwise: pass `hChildren`).
- else {
- /** @type {Array} */
- // @ts-expect-error: assume no doctypes in `root`.
- const children = 'children' in result ? result.children : [result]
- result = {type: 'element', tagName: hName, properties: {}, children}
- }
- }
-
- if (result.type === 'element' && hProperties) {
- Object.assign(result.properties, structured_clone_esm(hProperties))
- }
-
- if (
- 'children' in result &&
- result.children &&
- hChildren !== null &&
- hChildren !== undefined
- ) {
- result.children = hChildren
- }
- }
-
- return result
-}
-
-/**
- * Transform an unknown node.
- *
- * @param {State} state
- * Info passed around.
- * @param {MdastNodes} node
- * Unknown mdast node.
- * @returns {HastElement | HastText}
- * Resulting hast node.
- */
-function defaultUnknownHandler(state, node) {
- const data = node.data || {}
- /** @type {HastElement | HastText} */
- const result =
- 'value' in node &&
- !(state_own.call(data, 'hProperties') || state_own.call(data, 'hChildren'))
- ? {type: 'text', value: node.value}
- : {
- type: 'element',
- tagName: 'div',
- properties: {},
- children: state.all(node)
- }
-
- state.patch(node, result)
- return state.applyData(node, result)
-}
-
-/**
- * Wrap `nodes` with line endings between each node.
- *
- * @template {HastRootContent} Type
- * Node type.
- * @param {Array} nodes
- * List of nodes to wrap.
- * @param {boolean | undefined} [loose=false]
- * Whether to add line endings at start and end (default: `false`).
- * @returns {Array}
- * Wrapped nodes.
- */
-function wrap(nodes, loose) {
- /** @type {Array} */
- const result = []
- let index = -1
-
- if (loose) {
- result.push({type: 'text', value: '\n'})
- }
-
- while (++index < nodes.length) {
- if (index) result.push({type: 'text', value: '\n'})
- result.push(nodes[index])
- }
-
- if (loose && nodes.length > 0) {
- result.push({type: 'text', value: '\n'})
- }
-
- return result
-}
-
-/**
- * Trim spaces and tabs at the start of `value`.
- *
- * @param {string} value
- * Value to trim.
- * @returns {string}
- * Result.
- */
-function trimMarkdownSpaceStart(value) {
- let index = 0
- let code = value.charCodeAt(index)
-
- while (code === 9 || code === 32) {
- index++
- code = value.charCodeAt(index)
- }
-
- return value.slice(index)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_mdast-util-to-hast@13.2.0@mdast-util-to-hast/lib/index.js
-/**
- * @typedef {import('hast').Nodes} HastNodes
- * @typedef {import('mdast').Nodes} MdastNodes
- * @typedef {import('./state.js').Options} Options
- */
-
-
-
-
-
-/**
- * Transform mdast to hast.
- *
- * ##### Notes
- *
- * ###### HTML
- *
- * Raw HTML is available in mdast as `html` nodes and can be embedded in hast
- * as semistandard `raw` nodes.
- * Most utilities ignore `raw` nodes but two notable ones don’t:
- *
- * * `hast-util-to-html` also has an option `allowDangerousHtml` which will
- * output the raw HTML.
- * This is typically discouraged as noted by the option name but is useful
- * if you completely trust authors
- * * `hast-util-raw` can handle the raw embedded HTML strings by parsing them
- * into standard hast nodes (`element`, `text`, etc).
- * This is a heavy task as it needs a full HTML parser, but it is the only
- * way to support untrusted content
- *
- * ###### Footnotes
- *
- * Many options supported here relate to footnotes.
- * Footnotes are not specified by CommonMark, which we follow by default.
- * They are supported by GitHub, so footnotes can be enabled in markdown with
- * `mdast-util-gfm`.
- *
- * The options `footnoteBackLabel` and `footnoteLabel` define natural language
- * that explains footnotes, which is hidden for sighted users but shown to
- * assistive technology.
- * When your page is not in English, you must define translated values.
- *
- * Back references use ARIA attributes, but the section label itself uses a
- * heading that is hidden with an `sr-only` class.
- * To show it to sighted users, define different attributes in
- * `footnoteLabelProperties`.
- *
- * ###### Clobbering
- *
- * Footnotes introduces a problem, as it links footnote calls to footnote
- * definitions on the page through `id` attributes generated from user content,
- * which results in DOM clobbering.
- *
- * DOM clobbering is this:
- *
- * ```html
- *
- *
- * ```
- *
- * Elements by their ID are made available by browsers on the `window` object,
- * which is a security risk.
- * Using a prefix solves this problem.
- *
- * More information on how to handle clobbering and the prefix is explained in
- * Example: headings (DOM clobbering) in `rehype-sanitize`.
- *
- * ###### Unknown nodes
- *
- * Unknown nodes are nodes with a type that isn’t in `handlers` or `passThrough`.
- * The default behavior for unknown nodes is:
- *
- * * when the node has a `value` (and doesn’t have `data.hName`,
- * `data.hProperties`, or `data.hChildren`, see later), create a hast `text`
- * node
- * * otherwise, create a `` element (which could be changed with
- * `data.hName`), with its children mapped from mdast to hast as well
- *
- * This behavior can be changed by passing an `unknownHandler`.
- *
- * @param {MdastNodes} tree
- * mdast tree.
- * @param {Options | null | undefined} [options]
- * Configuration (optional).
- * @returns {HastNodes}
- * hast tree.
- */
-function toHast(tree, options) {
- const state = createState(tree, options)
- const node = state.one(tree, undefined)
- const foot = footer(state)
- /** @type {HastNodes} */
- const result = Array.isArray(node)
- ? {type: 'root', children: node}
- : node || {type: 'root', children: []}
-
- if (foot) {
- // If there’s a footer, there were definitions, meaning block
- // content.
- // So `result` is a parent node.
- ok('children' in result)
- result.children.push({type: 'text', value: '\n'}, foot)
- }
-
- return result
-}
-
-;// CONCATENATED MODULE: ./node_modules/_remark-rehype@11.1.0@remark-rehype/lib/index.js
-// Include `data` fields in mdast and `raw` nodes in hast.
-///
-
-/**
- * @typedef {import('hast').Root} HastRoot
- * @typedef {import('mdast').Root} MdastRoot
- * @typedef {import('mdast-util-to-hast').Options} ToHastOptions
- * @typedef {import('unified').Processor} Processor
- * @typedef {import('vfile').VFile} VFile
- */
-
-/**
- * @typedef {Omit} Options
- *
- * @callback TransformBridge
- * Bridge-mode.
- *
- * Runs the destination with the new hast tree.
- * Discards result.
- * @param {MdastRoot} tree
- * Tree.
- * @param {VFile} file
- * File.
- * @returns {Promise}
- * Nothing.
- *
- * @callback TransformMutate
- * Mutate-mode.
- *
- * Further transformers run on the hast tree.
- * @param {MdastRoot} tree
- * Tree.
- * @param {VFile} file
- * File.
- * @returns {HastRoot}
- * Tree (hast).
- */
-
-
-
-/**
- * Turn markdown into HTML.
- *
- * ##### Notes
- *
- * ###### Signature
- *
- * * if a processor is given, runs the (rehype) plugins used on it with a
- * hast tree, then discards the result (*bridge mode*)
- * * otherwise, returns a hast tree, the plugins used after `remarkRehype`
- * are rehype plugins (*mutate mode*)
- *
- * > 👉 **Note**: It’s highly unlikely that you want to pass a `processor`.
- *
- * ###### HTML
- *
- * Raw HTML is available in mdast as `html` nodes and can be embedded in hast
- * as semistandard `raw` nodes.
- * Most plugins ignore `raw` nodes but two notable ones don’t:
- *
- * * `rehype-stringify` also has an option `allowDangerousHtml` which will
- * output the raw HTML.
- * This is typically discouraged as noted by the option name but is useful if
- * you completely trust authors
- * * `rehype-raw` can handle the raw embedded HTML strings by parsing them
- * into standard hast nodes (`element`, `text`, etc).
- * This is a heavy task as it needs a full HTML parser, but it is the only way
- * to support untrusted content
- *
- * ###### Footnotes
- *
- * Many options supported here relate to footnotes.
- * Footnotes are not specified by CommonMark, which we follow by default.
- * They are supported by GitHub, so footnotes can be enabled in markdown with
- * `remark-gfm`.
- *
- * The options `footnoteBackLabel` and `footnoteLabel` define natural language
- * that explains footnotes, which is hidden for sighted users but shown to
- * assistive technology.
- * When your page is not in English, you must define translated values.
- *
- * Back references use ARIA attributes, but the section label itself uses a
- * heading that is hidden with an `sr-only` class.
- * To show it to sighted users, define different attributes in
- * `footnoteLabelProperties`.
- *
- * ###### Clobbering
- *
- * Footnotes introduces a problem, as it links footnote calls to footnote
- * definitions on the page through `id` attributes generated from user content,
- * which results in DOM clobbering.
- *
- * DOM clobbering is this:
- *
- * ```html
- *
- *
- * ```
- *
- * Elements by their ID are made available by browsers on the `window` object,
- * which is a security risk.
- * Using a prefix solves this problem.
- *
- * More information on how to handle clobbering and the prefix is explained in
- * *Example: headings (DOM clobbering)* in `rehype-sanitize`.
- *
- * ###### Unknown nodes
- *
- * Unknown nodes are nodes with a type that isn’t in `handlers` or `passThrough`.
- * The default behavior for unknown nodes is:
- *
- * * when the node has a `value` (and doesn’t have `data.hName`,
- * `data.hProperties`, or `data.hChildren`, see later), create a hast `text`
- * node
- * * otherwise, create a `` element (which could be changed with
- * `data.hName`), with its children mapped from mdast to hast as well
- *
- * This behavior can be changed by passing an `unknownHandler`.
- *
- * @overload
- * @param {Processor} processor
- * @param {Readonly | null | undefined} [options]
- * @returns {TransformBridge}
- *
- * @overload
- * @param {Readonly | null | undefined} [options]
- * @returns {TransformMutate}
- *
- * @param {Readonly | Processor | null | undefined} [destination]
- * Processor or configuration (optional).
- * @param {Readonly | null | undefined} [options]
- * When a processor was given, configuration (optional).
- * @returns {TransformBridge | TransformMutate}
- * Transform.
- */
-function remarkRehype(destination, options) {
- if (destination && 'run' in destination) {
- /**
- * @type {TransformBridge}
- */
- return async function (tree, file) {
- // Cast because root in -> root out.
- const hastTree = /** @type {HastRoot} */ (
- toHast(tree, {file, ...options})
- )
- await destination.run(hastTree, file)
- }
- }
-
- /**
- * @type {TransformMutate}
- */
- return function (tree, file) {
- // Cast because root in -> root out.
- return /** @type {HastRoot} */ (
- toHast(tree, {file, ...(options || destination)})
- )
- }
-}
-
-;// CONCATENATED MODULE: ./node_modules/_bail@2.0.2@bail/index.js
-/**
- * Throw a given error.
- *
- * @param {Error|null|undefined} [error]
- * Maybe error.
- * @returns {asserts error is null|undefined}
- */
-function bail(error) {
- if (error) {
- throw error
- }
-}
-
-// EXTERNAL MODULE: ./node_modules/_extend@3.0.2@extend/index.js
-var _extend_3_0_2_extend = __webpack_require__(58847);
-;// CONCATENATED MODULE: ./node_modules/_is-plain-obj@4.1.0@is-plain-obj/index.js
-function isPlainObject(value) {
- if (typeof value !== 'object' || value === null) {
- return false;
- }
-
- const prototype = Object.getPrototypeOf(value);
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
-}
-
-;// CONCATENATED MODULE: ./node_modules/_trough@2.2.0@trough/lib/index.js
-// To do: remove `void`s
-// To do: remove `null` from output of our APIs, allow it as user APIs.
-
-/**
- * @typedef {(error?: Error | null | undefined, ...output: Array) => void} Callback
- * Callback.
- *
- * @typedef {(...input: Array) => any} Middleware
- * Ware.
- *
- * @typedef Pipeline
- * Pipeline.
- * @property {Run} run
- * Run the pipeline.
- * @property {Use} use
- * Add middleware.
- *
- * @typedef {(...input: Array) => void} Run
- * Call all middleware.
- *
- * Calls `done` on completion with either an error or the output of the
- * last middleware.
- *
- * > 👉 **Note**: as the length of input defines whether async functions get a
- * > `next` function,
- * > it’s recommended to keep `input` at one value normally.
-
- *
- * @typedef {(fn: Middleware) => Pipeline} Use
- * Add middleware.
- */
-
-/**
- * Create new middleware.
- *
- * @returns {Pipeline}
- * Pipeline.
- */
-function trough() {
- /** @type {Array} */
- const fns = []
- /** @type {Pipeline} */
- const pipeline = {run, use}
-
- return pipeline
-
- /** @type {Run} */
- function run(...values) {
- let middlewareIndex = -1
- /** @type {Callback} */
- const callback = values.pop()
-
- if (typeof callback !== 'function') {
- throw new TypeError('Expected function as last argument, not ' + callback)
- }
-
- next(null, ...values)
-
- /**
- * Run the next `fn`, or we’re done.
- *
- * @param {Error | null | undefined} error
- * @param {Array} output
- */
- function next(error, ...output) {
- const fn = fns[++middlewareIndex]
- let index = -1
-
- if (error) {
- callback(error)
- return
- }
-
- // Copy non-nullish input into values.
- while (++index < values.length) {
- if (output[index] === null || output[index] === undefined) {
- output[index] = values[index]
- }
- }
-
- // Save the newly created `output` for the next call.
- values = output
-
- // Next or done.
- if (fn) {
- lib_wrap(fn, next)(...output)
- } else {
- callback(null, ...output)
- }
- }
- }
-
- /** @type {Use} */
- function use(middelware) {
- if (typeof middelware !== 'function') {
- throw new TypeError(
- 'Expected `middelware` to be a function, not ' + middelware
- )
- }
-
- fns.push(middelware)
- return pipeline
- }
-}
-
-/**
- * Wrap `middleware` into a uniform interface.
- *
- * You can pass all input to the resulting function.
- * `callback` is then called with the output of `middleware`.
- *
- * If `middleware` accepts more arguments than the later given in input,
- * an extra `done` function is passed to it after that input,
- * which must be called by `middleware`.
- *
- * The first value in `input` is the main input value.
- * All other input values are the rest input values.
- * The values given to `callback` are the input values,
- * merged with every non-nullish output value.
- *
- * * if `middleware` throws an error,
- * returns a promise that is rejected,
- * or calls the given `done` function with an error,
- * `callback` is called with that error
- * * if `middleware` returns a value or returns a promise that is resolved,
- * that value is the main output value
- * * if `middleware` calls `done`,
- * all non-nullish values except for the first one (the error) overwrite the
- * output values
- *
- * @param {Middleware} middleware
- * Function to wrap.
- * @param {Callback} callback
- * Callback called with the output of `middleware`.
- * @returns {Run}
- * Wrapped middleware.
- */
-function lib_wrap(middleware, callback) {
- /** @type {boolean} */
- let called
-
- return wrapped
-
- /**
- * Call `middleware`.
- * @this {any}
- * @param {Array} parameters
- * @returns {void}
- */
- function wrapped(...parameters) {
- const fnExpectsCallback = middleware.length > parameters.length
- /** @type {any} */
- let result
-
- if (fnExpectsCallback) {
- parameters.push(done)
- }
-
- try {
- result = middleware.apply(this, parameters)
- } catch (error) {
- const exception = /** @type {Error} */ (error)
-
- // Well, this is quite the pickle.
- // `middleware` received a callback and called it synchronously, but that
- // threw an error.
- // The only thing left to do is to throw the thing instead.
- if (fnExpectsCallback && called) {
- throw exception
- }
-
- return done(exception)
- }
-
- if (!fnExpectsCallback) {
- if (result && result.then && typeof result.then === 'function') {
- result.then(then, done)
- } else if (result instanceof Error) {
- done(result)
- } else {
- then(result)
- }
- }
- }
-
- /**
- * Call `callback`, only once.
- *
- * @type {Callback}
- */
- function done(error, ...output) {
- if (!called) {
- called = true
- callback(error, ...output)
- }
- }
-
- /**
- * Call `done` with one value.
- *
- * @param {any} [value]
- */
- function then(value) {
- done(null, value)
- }
-}
-
-;// CONCATENATED MODULE: ./node_modules/_vfile@6.0.2@vfile/lib/minpath.browser.js
-// A derivative work based on:
-// .
-// Which is licensed:
-//
-// MIT License
-//
-// Copyright (c) 2013 James Halliday
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-// the Software, and to permit persons to whom the Software is furnished to do so,
-// subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-// A derivative work based on:
-//
-// Parts of that are extracted from Node’s internal `path` module:
-// .
-// Which is licensed:
-//
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-const minpath = {basename, dirname, extname, join, sep: '/'}
-
-/* eslint-disable max-depth, complexity */
-
-/**
- * Get the basename from a path.
- *
- * @param {string} path
- * File path.
- * @param {string | null | undefined} [extname]
- * Extension to strip.
- * @returns {string}
- * Stem or basename.
- */
-function basename(path, extname) {
- if (extname !== undefined && typeof extname !== 'string') {
- throw new TypeError('"ext" argument must be a string')
- }
-
- assertPath(path)
- let start = 0
- let end = -1
- let index = path.length
- /** @type {boolean | undefined} */
- let seenNonSlash
-
- if (
- extname === undefined ||
- extname.length === 0 ||
- extname.length > path.length
- ) {
- while (index--) {
- if (path.codePointAt(index) === 47 /* `/` */) {
- // If we reached a path separator that was not part of a set of path
- // separators at the end of the string, stop now.
- if (seenNonSlash) {
- start = index + 1
- break
- }
- } else if (end < 0) {
- // We saw the first non-path separator, mark this as the end of our
- // path component.
- seenNonSlash = true
- end = index + 1
- }
- }
-
- return end < 0 ? '' : path.slice(start, end)
- }
-
- if (extname === path) {
- return ''
- }
-
- let firstNonSlashEnd = -1
- let extnameIndex = extname.length - 1
-
- while (index--) {
- if (path.codePointAt(index) === 47 /* `/` */) {
- // If we reached a path separator that was not part of a set of path
- // separators at the end of the string, stop now.
- if (seenNonSlash) {
- start = index + 1
- break
- }
- } else {
- if (firstNonSlashEnd < 0) {
- // We saw the first non-path separator, remember this index in case
- // we need it if the extension ends up not matching.
- seenNonSlash = true
- firstNonSlashEnd = index + 1
- }
-
- if (extnameIndex > -1) {
- // Try to match the explicit extension.
- if (path.codePointAt(index) === extname.codePointAt(extnameIndex--)) {
- if (extnameIndex < 0) {
- // We matched the extension, so mark this as the end of our path
- // component
- end = index
- }
- } else {
- // Extension does not match, so our result is the entire path
- // component
- extnameIndex = -1
- end = firstNonSlashEnd
- }
- }
- }
- }
-
- if (start === end) {
- end = firstNonSlashEnd
- } else if (end < 0) {
- end = path.length
- }
-
- return path.slice(start, end)
-}
-
-/**
- * Get the dirname from a path.
- *
- * @param {string} path
- * File path.
- * @returns {string}
- * File path.
- */
-function dirname(path) {
- assertPath(path)
-
- if (path.length === 0) {
- return '.'
- }
-
- let end = -1
- let index = path.length
- /** @type {boolean | undefined} */
- let unmatchedSlash
-
- // Prefix `--` is important to not run on `0`.
- while (--index) {
- if (path.codePointAt(index) === 47 /* `/` */) {
- if (unmatchedSlash) {
- end = index
- break
- }
- } else if (!unmatchedSlash) {
- // We saw the first non-path separator
- unmatchedSlash = true
- }
- }
-
- return end < 0
- ? path.codePointAt(0) === 47 /* `/` */
- ? '/'
- : '.'
- : end === 1 && path.codePointAt(0) === 47 /* `/` */
- ? '//'
- : path.slice(0, end)
-}
-
-/**
- * Get an extname from a path.
- *
- * @param {string} path
- * File path.
- * @returns {string}
- * Extname.
- */
-function extname(path) {
- assertPath(path)
-
- let index = path.length
-
- let end = -1
- let startPart = 0
- let startDot = -1
- // Track the state of characters (if any) we see before our first dot and
- // after any path separator we find.
- let preDotState = 0
- /** @type {boolean | undefined} */
- let unmatchedSlash
-
- while (index--) {
- const code = path.codePointAt(index)
-
- if (code === 47 /* `/` */) {
- // If we reached a path separator that was not part of a set of path
- // separators at the end of the string, stop now.
- if (unmatchedSlash) {
- startPart = index + 1
- break
- }
-
- continue
- }
-
- if (end < 0) {
- // We saw the first non-path separator, mark this as the end of our
- // extension.
- unmatchedSlash = true
- end = index + 1
- }
-
- if (code === 46 /* `.` */) {
- // If this is our first dot, mark it as the start of our extension.
- if (startDot < 0) {
- startDot = index
- } else if (preDotState !== 1) {
- preDotState = 1
- }
- } else if (startDot > -1) {
- // We saw a non-dot and non-path separator before our dot, so we should
- // have a good chance at having a non-empty extension.
- preDotState = -1
- }
- }
-
- if (
- startDot < 0 ||
- end < 0 ||
- // We saw a non-dot character immediately before the dot.
- preDotState === 0 ||
- // The (right-most) trimmed path component is exactly `..`.
- (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
- ) {
- return ''
- }
-
- return path.slice(startDot, end)
-}
-
-/**
- * Join segments from a path.
- *
- * @param {Array} segments
- * Path segments.
- * @returns {string}
- * File path.
- */
-function join(...segments) {
- let index = -1
- /** @type {string | undefined} */
- let joined
-
- while (++index < segments.length) {
- assertPath(segments[index])
-
- if (segments[index]) {
- joined =
- joined === undefined ? segments[index] : joined + '/' + segments[index]
- }
- }
-
- return joined === undefined ? '.' : minpath_browser_normalize(joined)
-}
-
-/**
- * Normalize a basic file path.
- *
- * @param {string} path
- * File path.
- * @returns {string}
- * File path.
- */
-// Note: `normalize` is not exposed as `path.normalize`, so some code is
-// manually removed from it.
-function minpath_browser_normalize(path) {
- assertPath(path)
-
- const absolute = path.codePointAt(0) === 47 /* `/` */
-
- // Normalize the path according to POSIX rules.
- let value = normalizeString(path, !absolute)
-
- if (value.length === 0 && !absolute) {
- value = '.'
- }
-
- if (value.length > 0 && path.codePointAt(path.length - 1) === 47 /* / */) {
- value += '/'
- }
-
- return absolute ? '/' + value : value
-}
-
-/**
- * Resolve `.` and `..` elements in a path with directory names.
- *
- * @param {string} path
- * File path.
- * @param {boolean} allowAboveRoot
- * Whether `..` can move above root.
- * @returns {string}
- * File path.
- */
-function normalizeString(path, allowAboveRoot) {
- let result = ''
- let lastSegmentLength = 0
- let lastSlash = -1
- let dots = 0
- let index = -1
- /** @type {number | undefined} */
- let code
- /** @type {number} */
- let lastSlashIndex
-
- while (++index <= path.length) {
- if (index < path.length) {
- code = path.codePointAt(index)
- } else if (code === 47 /* `/` */) {
- break
- } else {
- code = 47 /* `/` */
- }
-
- if (code === 47 /* `/` */) {
- if (lastSlash === index - 1 || dots === 1) {
- // Empty.
- } else if (lastSlash !== index - 1 && dots === 2) {
- if (
- result.length < 2 ||
- lastSegmentLength !== 2 ||
- result.codePointAt(result.length - 1) !== 46 /* `.` */ ||
- result.codePointAt(result.length - 2) !== 46 /* `.` */
- ) {
- if (result.length > 2) {
- lastSlashIndex = result.lastIndexOf('/')
-
- if (lastSlashIndex !== result.length - 1) {
- if (lastSlashIndex < 0) {
- result = ''
- lastSegmentLength = 0
- } else {
- result = result.slice(0, lastSlashIndex)
- lastSegmentLength = result.length - 1 - result.lastIndexOf('/')
- }
-
- lastSlash = index
- dots = 0
- continue
- }
- } else if (result.length > 0) {
- result = ''
- lastSegmentLength = 0
- lastSlash = index
- dots = 0
- continue
- }
- }
-
- if (allowAboveRoot) {
- result = result.length > 0 ? result + '/..' : '..'
- lastSegmentLength = 2
- }
- } else {
- if (result.length > 0) {
- result += '/' + path.slice(lastSlash + 1, index)
- } else {
- result = path.slice(lastSlash + 1, index)
- }
-
- lastSegmentLength = index - lastSlash - 1
- }
-
- lastSlash = index
- dots = 0
- } else if (code === 46 /* `.` */ && dots > -1) {
- dots++
- } else {
- dots = -1
- }
- }
-
- return result
-}
-
-/**
- * Make sure `path` is a string.
- *
- * @param {string} path
- * File path.
- * @returns {asserts path is string}
- * Nothing.
- */
-function assertPath(path) {
- if (typeof path !== 'string') {
- throw new TypeError(
- 'Path must be a string. Received ' + JSON.stringify(path)
- )
- }
-}
-
-/* eslint-enable max-depth, complexity */
-
-;// CONCATENATED MODULE: ./node_modules/_vfile@6.0.2@vfile/lib/minproc.browser.js
-// Somewhat based on:
-// .
-// But I don’t think one tiny line of code can be copyrighted. 😅
-const minproc = {cwd}
-
-function cwd() {
- return '/'
-}
-
-;// CONCATENATED MODULE: ./node_modules/_vfile@6.0.2@vfile/lib/minurl.shared.js
-/**
- * Checks if a value has the shape of a WHATWG URL object.
- *
- * Using a symbol or instanceof would not be able to recognize URL objects
- * coming from other implementations (e.g. in Electron), so instead we are
- * checking some well known properties for a lack of a better test.
- *
- * We use `href` and `protocol` as they are the only properties that are
- * easy to retrieve and calculate due to the lazy nature of the getters.
- *
- * We check for auth attribute to distinguish legacy url instance with
- * WHATWG URL instance.
- *
- * @param {unknown} fileUrlOrPath
- * File path or URL.
- * @returns {fileUrlOrPath is URL}
- * Whether it’s a URL.
- */
-// From:
-function isUrl(fileUrlOrPath) {
- return Boolean(
- fileUrlOrPath !== null &&
- typeof fileUrlOrPath === 'object' &&
- 'href' in fileUrlOrPath &&
- fileUrlOrPath.href &&
- 'protocol' in fileUrlOrPath &&
- fileUrlOrPath.protocol &&
- // @ts-expect-error: indexing is fine.
- fileUrlOrPath.auth === undefined
- )
-}
-
-;// CONCATENATED MODULE: ./node_modules/_vfile@6.0.2@vfile/lib/minurl.browser.js
-
-
-
-
-// See:
-
-/**
- * @param {URL | string} path
- * File URL.
- * @returns {string}
- * File URL.
- */
-function urlToPath(path) {
- if (typeof path === 'string') {
- path = new URL(path)
- } else if (!isUrl(path)) {
- /** @type {NodeJS.ErrnoException} */
- const error = new TypeError(
- 'The "path" argument must be of type string or an instance of URL. Received `' +
- path +
- '`'
- )
- error.code = 'ERR_INVALID_ARG_TYPE'
- throw error
- }
-
- if (path.protocol !== 'file:') {
- /** @type {NodeJS.ErrnoException} */
- const error = new TypeError('The URL must be of scheme file')
- error.code = 'ERR_INVALID_URL_SCHEME'
- throw error
- }
-
- return getPathFromURLPosix(path)
-}
-
-/**
- * Get a path from a POSIX URL.
- *
- * @param {URL} url
- * URL.
- * @returns {string}
- * File path.
- */
-function getPathFromURLPosix(url) {
- if (url.hostname !== '') {
- /** @type {NodeJS.ErrnoException} */
- const error = new TypeError(
- 'File URL host must be "localhost" or empty on darwin'
- )
- error.code = 'ERR_INVALID_FILE_URL_HOST'
- throw error
- }
-
- const pathname = url.pathname
- let index = -1
-
- while (++index < pathname.length) {
- if (
- pathname.codePointAt(index) === 37 /* `%` */ &&
- pathname.codePointAt(index + 1) === 50 /* `2` */
- ) {
- const third = pathname.codePointAt(index + 2)
- if (third === 70 /* `F` */ || third === 102 /* `f` */) {
- /** @type {NodeJS.ErrnoException} */
- const error = new TypeError(
- 'File URL path must not include encoded / characters'
- )
- error.code = 'ERR_INVALID_FILE_URL_PATH'
- throw error
- }
- }
- }
-
- return decodeURIComponent(pathname)
-}
-
-;// CONCATENATED MODULE: ./node_modules/_vfile@6.0.2@vfile/lib/index.js
-/**
- * @import {Node, Point, Position} from 'unist'
- * @import {Options as MessageOptions} from 'vfile-message'
- * @import {Compatible, Data, Map, Options, Value} from 'vfile'
- */
-
-/**
- * @typedef {object & {type: string, position?: Position | undefined}} NodeLike
- */
-
-
-
-
-
-
-/**
- * Order of setting (least specific to most), we need this because otherwise
- * `{stem: 'a', path: '~/b.js'}` would throw, as a path is needed before a
- * stem can be set.
- */
-const order = /** @type {const} */ ([
- 'history',
- 'path',
- 'basename',
- 'stem',
- 'extname',
- 'dirname'
-])
-
-class VFile {
- /**
- * Create a new virtual file.
- *
- * `options` is treated as:
- *
- * * `string` or `Uint8Array` — `{value: options}`
- * * `URL` — `{path: options}`
- * * `VFile` — shallow copies its data over to the new file
- * * `object` — all fields are shallow copied over to the new file
- *
- * Path related fields are set in the following order (least specific to
- * most specific): `history`, `path`, `basename`, `stem`, `extname`,
- * `dirname`.
- *
- * You cannot set `dirname` or `extname` without setting either `history`,
- * `path`, `basename`, or `stem` too.
- *
- * @param {Compatible | null | undefined} [value]
- * File value.
- * @returns
- * New instance.
- */
- constructor(value) {
- /** @type {Options | VFile} */
- let options
-
- if (!value) {
- options = {}
- } else if (isUrl(value)) {
- options = {path: value}
- } else if (typeof value === 'string' || isUint8Array(value)) {
- options = {value}
- } else {
- options = value
- }
-
- /* eslint-disable no-unused-expressions */
-
- /**
- * Base of `path` (default: `process.cwd()` or `'/'` in browsers).
- *
- * @type {string}
- */
- // Prevent calling `cwd` (which could be expensive) if it’s not needed;
- // the empty string will be overridden in the next block.
- this.cwd = 'cwd' in options ? '' : minproc.cwd()
-
- /**
- * Place to store custom info (default: `{}`).
- *
- * It’s OK to store custom data directly on the file but moving it to
- * `data` is recommended.
- *
- * @type {Data}
- */
- this.data = {}
-
- /**
- * List of file paths the file moved between.
- *
- * The first is the original path and the last is the current path.
- *
- * @type {Array}
- */
- this.history = []
-
- /**
- * List of messages associated with the file.
- *
- * @type {Array}
- */
- this.messages = []
-
- /**
- * Raw value.
- *
- * @type {Value}
- */
- this.value
-
- // The below are non-standard, they are “well-known”.
- // As in, used in several tools.
- /**
- * Source map.
- *
- * This type is equivalent to the `RawSourceMap` type from the `source-map`
- * module.
- *
- * @type {Map | null | undefined}
- */
- this.map
-
- /**
- * Custom, non-string, compiled, representation.
- *
- * This is used by unified to store non-string results.
- * One example is when turning markdown into React nodes.
- *
- * @type {unknown}
- */
- this.result
-
- /**
- * Whether a file was saved to disk.
- *
- * This is used by vfile reporters.
- *
- * @type {boolean}
- */
- this.stored
- /* eslint-enable no-unused-expressions */
-
- // Set path related properties in the correct order.
- let index = -1
-
- while (++index < order.length) {
- const field = order[index]
-
- // Note: we specifically use `in` instead of `hasOwnProperty` to accept
- // `vfile`s too.
- if (
- field in options &&
- options[field] !== undefined &&
- options[field] !== null
- ) {
- // @ts-expect-error: TS doesn’t understand basic reality.
- this[field] = field === 'history' ? [...options[field]] : options[field]
- }
- }
-
- /** @type {string} */
- let field
-
- // Set non-path related properties.
- for (field in options) {
- // @ts-expect-error: fine to set other things.
- if (!order.includes(field)) {
- // @ts-expect-error: fine to set other things.
- this[field] = options[field]
- }
- }
- }
-
- /**
- * Get the basename (including extname) (example: `'index.min.js'`).
- *
- * @returns {string | undefined}
- * Basename.
- */
- get basename() {
- return typeof this.path === 'string'
- ? minpath.basename(this.path)
- : undefined
- }
-
- /**
- * Set basename (including extname) (`'index.min.js'`).
- *
- * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
- * on windows).
- * Cannot be nullified (use `file.path = file.dirname` instead).
- *
- * @param {string} basename
- * Basename.
- * @returns {undefined}
- * Nothing.
- */
- set basename(basename) {
- assertNonEmpty(basename, 'basename')
- assertPart(basename, 'basename')
- this.path = minpath.join(this.dirname || '', basename)
- }
-
- /**
- * Get the parent path (example: `'~'`).
- *
- * @returns {string | undefined}
- * Dirname.
- */
- get dirname() {
- return typeof this.path === 'string'
- ? minpath.dirname(this.path)
- : undefined
- }
-
- /**
- * Set the parent path (example: `'~'`).
- *
- * Cannot be set if there’s no `path` yet.
- *
- * @param {string | undefined} dirname
- * Dirname.
- * @returns {undefined}
- * Nothing.
- */
- set dirname(dirname) {
- lib_assertPath(this.basename, 'dirname')
- this.path = minpath.join(dirname || '', this.basename)
- }
-
- /**
- * Get the extname (including dot) (example: `'.js'`).
- *
- * @returns {string | undefined}
- * Extname.
- */
- get extname() {
- return typeof this.path === 'string'
- ? minpath.extname(this.path)
- : undefined
- }
-
- /**
- * Set the extname (including dot) (example: `'.js'`).
- *
- * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
- * on windows).
- * Cannot be set if there’s no `path` yet.
- *
- * @param {string | undefined} extname
- * Extname.
- * @returns {undefined}
- * Nothing.
- */
- set extname(extname) {
- assertPart(extname, 'extname')
- lib_assertPath(this.dirname, 'extname')
-
- if (extname) {
- if (extname.codePointAt(0) !== 46 /* `.` */) {
- throw new Error('`extname` must start with `.`')
- }
-
- if (extname.includes('.', 1)) {
- throw new Error('`extname` cannot contain multiple dots')
- }
- }
-
- this.path = minpath.join(this.dirname, this.stem + (extname || ''))
- }
-
- /**
- * Get the full path (example: `'~/index.min.js'`).
- *
- * @returns {string}
- * Path.
- */
- get path() {
- return this.history[this.history.length - 1]
- }
-
- /**
- * Set the full path (example: `'~/index.min.js'`).
- *
- * Cannot be nullified.
- * You can set a file URL (a `URL` object with a `file:` protocol) which will
- * be turned into a path with `url.fileURLToPath`.
- *
- * @param {URL | string} path
- * Path.
- * @returns {undefined}
- * Nothing.
- */
- set path(path) {
- if (isUrl(path)) {
- path = urlToPath(path)
- }
-
- assertNonEmpty(path, 'path')
-
- if (this.path !== path) {
- this.history.push(path)
- }
- }
-
- /**
- * Get the stem (basename w/o extname) (example: `'index.min'`).
- *
- * @returns {string | undefined}
- * Stem.
- */
- get stem() {
- return typeof this.path === 'string'
- ? minpath.basename(this.path, this.extname)
- : undefined
- }
-
- /**
- * Set the stem (basename w/o extname) (example: `'index.min'`).
- *
- * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
- * on windows).
- * Cannot be nullified (use `file.path = file.dirname` instead).
- *
- * @param {string} stem
- * Stem.
- * @returns {undefined}
- * Nothing.
- */
- set stem(stem) {
- assertNonEmpty(stem, 'stem')
- assertPart(stem, 'stem')
- this.path = minpath.join(this.dirname || '', stem + (this.extname || ''))
- }
-
- // Normal prototypal methods.
- /**
- * Create a fatal message for `reason` associated with the file.
- *
- * The `fatal` field of the message is set to `true` (error; file not usable)
- * and the `file` field is set to the current file path.
- * The message is added to the `messages` field on `file`.
- *
- * > 🪦 **Note**: also has obsolete signatures.
- *
- * @overload
- * @param {string} reason
- * @param {MessageOptions | null | undefined} [options]
- * @returns {never}
- *
- * @overload
- * @param {string} reason
- * @param {Node | NodeLike | null | undefined} parent
- * @param {string | null | undefined} [origin]
- * @returns {never}
- *
- * @overload
- * @param {string} reason
- * @param {Point | Position | null | undefined} place
- * @param {string | null | undefined} [origin]
- * @returns {never}
- *
- * @overload
- * @param {string} reason
- * @param {string | null | undefined} [origin]
- * @returns {never}
- *
- * @overload
- * @param {Error | VFileMessage} cause
- * @param {Node | NodeLike | null | undefined} parent
- * @param {string | null | undefined} [origin]
- * @returns {never}
- *
- * @overload
- * @param {Error | VFileMessage} cause
- * @param {Point | Position | null | undefined} place
- * @param {string | null | undefined} [origin]
- * @returns {never}
- *
- * @overload
- * @param {Error | VFileMessage} cause
- * @param {string | null | undefined} [origin]
- * @returns {never}
- *
- * @param {Error | VFileMessage | string} causeOrReason
- * Reason for message, should use markdown.
- * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
- * Configuration (optional).
- * @param {string | null | undefined} [origin]
- * Place in code where the message originates (example:
- * `'my-package:my-rule'` or `'my-rule'`).
- * @returns {never}
- * Never.
- * @throws {VFileMessage}
- * Message.
- */
- fail(causeOrReason, optionsOrParentOrPlace, origin) {
- // @ts-expect-error: the overloads are fine.
- const message = this.message(causeOrReason, optionsOrParentOrPlace, origin)
-
- message.fatal = true
-
- throw message
- }
-
- /**
- * Create an info message for `reason` associated with the file.
- *
- * The `fatal` field of the message is set to `undefined` (info; change
- * likely not needed) and the `file` field is set to the current file path.
- * The message is added to the `messages` field on `file`.
- *
- * > 🪦 **Note**: also has obsolete signatures.
- *
- * @overload
- * @param {string} reason
- * @param {MessageOptions | null | undefined} [options]
- * @returns {VFileMessage}
- *
- * @overload
- * @param {string} reason
- * @param {Node | NodeLike | null | undefined} parent
- * @param {string | null | undefined} [origin]
- * @returns {VFileMessage}
- *
- * @overload
- * @param {string} reason
- * @param {Point | Position | null | undefined} place
- * @param {string | null | undefined} [origin]
- * @returns {VFileMessage}
- *
- * @overload
- * @param {string} reason
- * @param {string | null | undefined} [origin]
- * @returns {VFileMessage}
- *
- * @overload
- * @param {Error | VFileMessage} cause
- * @param {Node | NodeLike | null | undefined} parent
- * @param {string | null | undefined} [origin]
- * @returns {VFileMessage}
- *
- * @overload
- * @param {Error | VFileMessage} cause
- * @param {Point | Position | null | undefined} place
- * @param {string | null | undefined} [origin]
- * @returns {VFileMessage}
- *
- * @overload
- * @param {Error | VFileMessage} cause
- * @param {string | null | undefined} [origin]
- * @returns {VFileMessage}
- *
- * @param {Error | VFileMessage | string} causeOrReason
- * Reason for message, should use markdown.
- * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
- * Configuration (optional).
- * @param {string | null | undefined} [origin]
- * Place in code where the message originates (example:
- * `'my-package:my-rule'` or `'my-rule'`).
- * @returns {VFileMessage}
- * Message.
- */
- info(causeOrReason, optionsOrParentOrPlace, origin) {
- // @ts-expect-error: the overloads are fine.
- const message = this.message(causeOrReason, optionsOrParentOrPlace, origin)
-
- message.fatal = undefined
-
- return message
- }
-
- /**
- * Create a message for `reason` associated with the file.
- *
- * The `fatal` field of the message is set to `false` (warning; change may be
- * needed) and the `file` field is set to the current file path.
- * The message is added to the `messages` field on `file`.
- *
- * > 🪦 **Note**: also has obsolete signatures.
- *
- * @overload
- * @param {string} reason
- * @param {MessageOptions | null | undefined} [options]
- * @returns {VFileMessage}
- *
- * @overload
- * @param {string} reason
- * @param {Node | NodeLike | null | undefined} parent
- * @param {string | null | undefined} [origin]
- * @returns {VFileMessage}
- *
- * @overload
- * @param {string} reason
- * @param {Point | Position | null | undefined} place
- * @param {string | null | undefined} [origin]
- * @returns {VFileMessage}
- *
- * @overload
- * @param {string} reason
- * @param {string | null | undefined} [origin]
- * @returns {VFileMessage}
- *
- * @overload
- * @param {Error | VFileMessage} cause
- * @param {Node | NodeLike | null | undefined} parent
- * @param {string | null | undefined} [origin]
- * @returns {VFileMessage}
- *
- * @overload
- * @param {Error | VFileMessage} cause
- * @param {Point | Position | null | undefined} place
- * @param {string | null | undefined} [origin]
- * @returns {VFileMessage}
- *
- * @overload
- * @param {Error | VFileMessage} cause
- * @param {string | null | undefined} [origin]
- * @returns {VFileMessage}
- *
- * @param {Error | VFileMessage | string} causeOrReason
- * Reason for message, should use markdown.
- * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
- * Configuration (optional).
- * @param {string | null | undefined} [origin]
- * Place in code where the message originates (example:
- * `'my-package:my-rule'` or `'my-rule'`).
- * @returns {VFileMessage}
- * Message.
- */
- message(causeOrReason, optionsOrParentOrPlace, origin) {
- const message = new VFileMessage(
- // @ts-expect-error: the overloads are fine.
- causeOrReason,
- optionsOrParentOrPlace,
- origin
- )
-
- if (this.path) {
- message.name = this.path + ':' + message.name
- message.file = this.path
- }
-
- message.fatal = false
-
- this.messages.push(message)
-
- return message
- }
-
- /**
- * Serialize the file.
- *
- * > **Note**: which encodings are supported depends on the engine.
- * > For info on Node.js, see:
- * > .
- *
- * @param {string | null | undefined} [encoding='utf8']
- * Character encoding to understand `value` as when it’s a `Uint8Array`
- * (default: `'utf-8'`).
- * @returns {string}
- * Serialized file.
- */
- toString(encoding) {
- if (this.value === undefined) {
- return ''
- }
-
- if (typeof this.value === 'string') {
- return this.value
- }
-
- const decoder = new TextDecoder(encoding || undefined)
- return decoder.decode(this.value)
- }
-}
-
-/**
- * Assert that `part` is not a path (as in, does not contain `path.sep`).
- *
- * @param {string | null | undefined} part
- * File path part.
- * @param {string} name
- * Part name.
- * @returns {undefined}
- * Nothing.
- */
-function assertPart(part, name) {
- if (part && part.includes(minpath.sep)) {
- throw new Error(
- '`' + name + '` cannot be a path: did not expect `' + minpath.sep + '`'
- )
- }
-}
-
-/**
- * Assert that `part` is not empty.
- *
- * @param {string | undefined} part
- * Thing.
- * @param {string} name
- * Part name.
- * @returns {asserts part is string}
- * Nothing.
- */
-function assertNonEmpty(part, name) {
- if (!part) {
- throw new Error('`' + name + '` cannot be empty')
- }
-}
-
-/**
- * Assert `path` exists.
- *
- * @param {string | undefined} path
- * Path.
- * @param {string} name
- * Dependency name.
- * @returns {asserts path is string}
- * Nothing.
- */
-function lib_assertPath(path, name) {
- if (!path) {
- throw new Error('Setting `' + name + '` requires `path` to be set too')
- }
-}
-
-/**
- * Assert `value` is an `Uint8Array`.
- *
- * @param {unknown} value
- * thing.
- * @returns {value is Uint8Array}
- * Whether `value` is an `Uint8Array`.
- */
-function isUint8Array(value) {
- return Boolean(
- value &&
- typeof value === 'object' &&
- 'byteLength' in value &&
- 'byteOffset' in value
- )
-}
-
-;// CONCATENATED MODULE: ./node_modules/_unified@11.0.5@unified/lib/callable-instance.js
-const CallableInstance =
- /**
- * @type {new , Result>(property: string | symbol) => (...parameters: Parameters) => Result}
- */
- (
- /** @type {unknown} */
- (
- /**
- * @this {Function}
- * @param {string | symbol} property
- * @returns {(...parameters: Array) => unknown}
- */
- function (property) {
- const self = this
- const constr = self.constructor
- const proto = /** @type {Record} */ (
- // Prototypes do exist.
- // type-coverage:ignore-next-line
- constr.prototype
- )
- const value = proto[property]
- /** @type {(...parameters: Array) => unknown} */
- const apply = function () {
- return value.apply(apply, arguments)
- }
-
- Object.setPrototypeOf(apply, proto)
-
- // Not needed for us in `unified`: we only call this on the `copy`
- // function,
- // and we don't need to add its fields (`length`, `name`)
- // over.
- // See also: GH-246.
- // const names = Object.getOwnPropertyNames(value)
- //
- // for (const p of names) {
- // const descriptor = Object.getOwnPropertyDescriptor(value, p)
- // if (descriptor) Object.defineProperty(apply, p, descriptor)
- // }
-
- return apply
- }
- )
- )
-
-;// CONCATENATED MODULE: ./node_modules/_unified@11.0.5@unified/lib/index.js
-/**
- * @typedef {import('trough').Pipeline} Pipeline
- *
- * @typedef {import('unist').Node} Node
- *
- * @typedef {import('vfile').Compatible} Compatible
- * @typedef {import('vfile').Value} Value
- *
- * @typedef {import('../index.js').CompileResultMap} CompileResultMap
- * @typedef {import('../index.js').Data} Data
- * @typedef {import('../index.js').Settings} Settings
- */
-
-/**
- * @typedef {CompileResultMap[keyof CompileResultMap]} CompileResults
- * Acceptable results from compilers.
- *
- * To register custom results, add them to
- * {@linkcode CompileResultMap}.
- */
-
-/**
- * @template {Node} [Tree=Node]
- * The node that the compiler receives (default: `Node`).
- * @template {CompileResults} [Result=CompileResults]
- * The thing that the compiler yields (default: `CompileResults`).
- * @callback Compiler
- * A **compiler** handles the compiling of a syntax tree to something else
- * (in most cases, text) (TypeScript type).
- *
- * It is used in the stringify phase and called with a {@linkcode Node}
- * and {@linkcode VFile} representation of the document to compile.
- * It should return the textual representation of the given tree (typically
- * `string`).
- *
- * > **Note**: unified typically compiles by serializing: most compilers
- * > return `string` (or `Uint8Array`).
- * > Some compilers, such as the one configured with
- * > [`rehype-react`][rehype-react], return other values (in this case, a
- * > React tree).
- * > If you’re using a compiler that doesn’t serialize, expect different
- * > result values.
- * >
- * > To register custom results in TypeScript, add them to
- * > {@linkcode CompileResultMap}.
- *
- * [rehype-react]: https://github.com/rehypejs/rehype-react
- * @param {Tree} tree
- * Tree to compile.
- * @param {VFile} file
- * File associated with `tree`.
- * @returns {Result}
- * New content: compiled text (`string` or `Uint8Array`, for `file.value`) or
- * something else (for `file.result`).
- */
-
-/**
- * @template {Node} [Tree=Node]
- * The node that the parser yields (default: `Node`)
- * @callback Parser
- * A **parser** handles the parsing of text to a syntax tree.
- *
- * It is used in the parse phase and is called with a `string` and
- * {@linkcode VFile} of the document to parse.
- * It must return the syntax tree representation of the given file
- * ({@linkcode Node}).
- * @param {string} document
- * Document to parse.
- * @param {VFile} file
- * File associated with `document`.
- * @returns {Tree}
- * Node representing the given file.
- */
-
-/**
- * @typedef {(
- * Plugin, any, any> |
- * PluginTuple, any, any> |
- * Preset
- * )} Pluggable
- * Union of the different ways to add plugins and settings.
- */
-
-/**
- * @typedef {Array} PluggableList
- * List of plugins and presets.
- */
-
-// Note: we can’t use `callback` yet as it messes up `this`:
-// .
-/**
- * @template {Array} [PluginParameters=[]]
- * Arguments passed to the plugin (default: `[]`, the empty tuple).
- * @template {Node | string | undefined} [Input=Node]
- * Value that is expected as input (default: `Node`).
- *
- * * If the plugin returns a {@linkcode Transformer}, this
- * should be the node it expects.
- * * If the plugin sets a {@linkcode Parser}, this should be
- * `string`.
- * * If the plugin sets a {@linkcode Compiler}, this should be the
- * node it expects.
- * @template [Output=Input]
- * Value that is yielded as output (default: `Input`).
- *
- * * If the plugin returns a {@linkcode Transformer}, this
- * should be the node that that yields.
- * * If the plugin sets a {@linkcode Parser}, this should be the
- * node that it yields.
- * * If the plugin sets a {@linkcode Compiler}, this should be
- * result it yields.
- * @typedef {(
- * (this: Processor, ...parameters: PluginParameters) =>
- * Input extends string ? // Parser.
- * Output extends Node | undefined ? undefined | void : never :
- * Output extends CompileResults ? // Compiler.
- * Input extends Node | undefined ? undefined | void : never :
- * Transformer<
- * Input extends Node ? Input : Node,
- * Output extends Node ? Output : Node
- * > | undefined | void
- * )} Plugin
- * Single plugin.
- *
- * Plugins configure the processors they are applied on in the following
- * ways:
- *
- * * they change the processor, such as the parser, the compiler, or by
- * configuring data
- * * they specify how to handle trees and files
- *
- * In practice, they are functions that can receive options and configure the
- * processor (`this`).
- *
- * > **Note**: plugins are called when the processor is *frozen*, not when
- * > they are applied.
- */
-
-/**
- * Tuple of a plugin and its configuration.
- *
- * The first item is a plugin, the rest are its parameters.
- *
- * @template {Array} [TupleParameters=[]]
- * Arguments passed to the plugin (default: `[]`, the empty tuple).
- * @template {Node | string | undefined} [Input=undefined]
- * Value that is expected as input (optional).
- *
- * * If the plugin returns a {@linkcode Transformer}, this
- * should be the node it expects.
- * * If the plugin sets a {@linkcode Parser}, this should be
- * `string`.
- * * If the plugin sets a {@linkcode Compiler}, this should be the
- * node it expects.
- * @template [Output=undefined] (optional).
- * Value that is yielded as output.
- *
- * * If the plugin returns a {@linkcode Transformer}, this
- * should be the node that that yields.
- * * If the plugin sets a {@linkcode Parser}, this should be the
- * node that it yields.
- * * If the plugin sets a {@linkcode Compiler}, this should be
- * result it yields.
- * @typedef {(
- * [
- * plugin: Plugin,
- * ...parameters: TupleParameters
- * ]
- * )} PluginTuple
- */
-
-/**
- * @typedef Preset
- * Sharable configuration.
- *
- * They can contain plugins and settings.
- * @property {PluggableList | undefined} [plugins]
- * List of plugins and presets (optional).
- * @property {Settings | undefined} [settings]
- * Shared settings for parsers and compilers (optional).
- */
-
-/**
- * @template {VFile} [File=VFile]
- * The file that the callback receives (default: `VFile`).
- * @callback ProcessCallback
- * Callback called when the process is done.
- *
- * Called with either an error or a result.
- * @param {Error | undefined} [error]
- * Fatal error (optional).
- * @param {File | undefined} [file]
- * Processed file (optional).
- * @returns {undefined}
- * Nothing.
- */
-
-/**
- * @template {Node} [Tree=Node]
- * The tree that the callback receives (default: `Node`).
- * @callback RunCallback
- * Callback called when transformers are done.
- *
- * Called with either an error or results.
- * @param {Error | undefined} [error]
- * Fatal error (optional).
- * @param {Tree | undefined} [tree]
- * Transformed tree (optional).
- * @param {VFile | undefined} [file]
- * File (optional).
- * @returns {undefined}
- * Nothing.
- */
-
-/**
- * @template {Node} [Output=Node]
- * Node type that the transformer yields (default: `Node`).
- * @callback TransformCallback
- * Callback passed to transforms.
- *
- * If the signature of a `transformer` accepts a third argument, the
- * transformer may perform asynchronous operations, and must call it.
- * @param {Error | undefined} [error]
- * Fatal error to stop the process (optional).
- * @param {Output | undefined} [tree]
- * New, changed, tree (optional).
- * @param {VFile | undefined} [file]
- * New, changed, file (optional).
- * @returns {undefined}
- * Nothing.
- */
-
-/**
- * @template {Node} [Input=Node]
- * Node type that the transformer expects (default: `Node`).
- * @template {Node} [Output=Input]
- * Node type that the transformer yields (default: `Input`).
- * @callback Transformer
- * Transformers handle syntax trees and files.
- *
- * They are functions that are called each time a syntax tree and file are
- * passed through the run phase.
- * When an error occurs in them (either because it’s thrown, returned,
- * rejected, or passed to `next`), the process stops.
- *
- * The run phase is handled by [`trough`][trough], see its documentation for
- * the exact semantics of these functions.
- *
- * > **Note**: you should likely ignore `next`: don’t accept it.
- * > it supports callback-style async work.
- * > But promises are likely easier to reason about.
- *
- * [trough]: https://github.com/wooorm/trough#function-fninput-next
- * @param {Input} tree
- * Tree to handle.
- * @param {VFile} file
- * File to handle.
- * @param {TransformCallback