4345 lines
126 KiB
JavaScript
4345 lines
126 KiB
JavaScript
import {
|
||
VFileMessage,
|
||
stringifyPosition,
|
||
toJsxRuntime
|
||
} from "./chunk-7DH7CPOK.js";
|
||
import {
|
||
require_jsx_runtime
|
||
} from "./chunk-4UTF2CDO.js";
|
||
import {
|
||
attention,
|
||
autolink,
|
||
blankLine,
|
||
blockQuote,
|
||
characterEscape,
|
||
characterReference,
|
||
codeFenced,
|
||
codeIndented,
|
||
codeText,
|
||
combineExtensions,
|
||
content,
|
||
decodeNamedCharacterReference,
|
||
decodeNumericCharacterReference,
|
||
decodeString,
|
||
definition,
|
||
factorySpace,
|
||
hardBreakEscape,
|
||
headingAtx,
|
||
htmlFlow,
|
||
htmlText,
|
||
labelEnd,
|
||
labelStartImage,
|
||
labelStartLink,
|
||
lineEnding,
|
||
list,
|
||
normalizeIdentifier,
|
||
normalizeUri,
|
||
push,
|
||
resolveAll,
|
||
setextUnderline,
|
||
splice,
|
||
subtokenize,
|
||
thematicBreak,
|
||
toString
|
||
} from "./chunk-7LN5YD3C.js";
|
||
import {
|
||
markdownLineEnding
|
||
} from "./chunk-NZRYQAB5.js";
|
||
import "./chunk-SXG5A6WW.js";
|
||
import {
|
||
esm_default
|
||
} from "./chunk-DGNA47UV.js";
|
||
import {
|
||
pointEnd,
|
||
pointStart,
|
||
position
|
||
} from "./chunk-JBIZ2Z6H.js";
|
||
import {
|
||
visit
|
||
} from "./chunk-MVAV3KYZ.js";
|
||
import {
|
||
ok,
|
||
unreachable
|
||
} from "./chunk-F5J6TPXX.js";
|
||
import {
|
||
require_react
|
||
} from "./chunk-BXEBRY3I.js";
|
||
import {
|
||
__commonJS,
|
||
__export,
|
||
__toESM
|
||
} from "./chunk-V4OQ3NZ2.js";
|
||
|
||
// node_modules/extend/index.js
|
||
var require_extend = __commonJS({
|
||
"node_modules/extend/index.js"(exports, module) {
|
||
"use strict";
|
||
var hasOwn = Object.prototype.hasOwnProperty;
|
||
var toStr = Object.prototype.toString;
|
||
var defineProperty = Object.defineProperty;
|
||
var gOPD = Object.getOwnPropertyDescriptor;
|
||
var isArray = function isArray2(arr) {
|
||
if (typeof Array.isArray === "function") {
|
||
return Array.isArray(arr);
|
||
}
|
||
return toStr.call(arr) === "[object Array]";
|
||
};
|
||
var isPlainObject2 = function isPlainObject3(obj) {
|
||
if (!obj || toStr.call(obj) !== "[object Object]") {
|
||
return false;
|
||
}
|
||
var hasOwnConstructor = hasOwn.call(obj, "constructor");
|
||
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, "isPrototypeOf");
|
||
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
|
||
return false;
|
||
}
|
||
var key;
|
||
for (key in obj) {
|
||
}
|
||
return typeof key === "undefined" || hasOwn.call(obj, key);
|
||
};
|
||
var setProperty = function setProperty2(target, options) {
|
||
if (defineProperty && options.name === "__proto__") {
|
||
defineProperty(target, options.name, {
|
||
enumerable: true,
|
||
configurable: true,
|
||
value: options.newValue,
|
||
writable: true
|
||
});
|
||
} else {
|
||
target[options.name] = options.newValue;
|
||
}
|
||
};
|
||
var getProperty = function getProperty2(obj, name) {
|
||
if (name === "__proto__") {
|
||
if (!hasOwn.call(obj, name)) {
|
||
return void 0;
|
||
} else if (gOPD) {
|
||
return gOPD(obj, name).value;
|
||
}
|
||
}
|
||
return obj[name];
|
||
};
|
||
module.exports = function extend2() {
|
||
var options, name, src, copy, copyIsArray, clone;
|
||
var target = arguments[0];
|
||
var i = 1;
|
||
var length = arguments.length;
|
||
var deep = false;
|
||
if (typeof target === "boolean") {
|
||
deep = target;
|
||
target = arguments[1] || {};
|
||
i = 2;
|
||
}
|
||
if (target == null || typeof target !== "object" && typeof target !== "function") {
|
||
target = {};
|
||
}
|
||
for (; i < length; ++i) {
|
||
options = arguments[i];
|
||
if (options != null) {
|
||
for (name in options) {
|
||
src = getProperty(target, name);
|
||
copy = getProperty(options, name);
|
||
if (target !== copy) {
|
||
if (deep && copy && (isPlainObject2(copy) || (copyIsArray = isArray(copy)))) {
|
||
if (copyIsArray) {
|
||
copyIsArray = false;
|
||
clone = src && isArray(src) ? src : [];
|
||
} else {
|
||
clone = src && isPlainObject2(src) ? src : {};
|
||
}
|
||
setProperty(target, { name, newValue: extend2(deep, clone, copy) });
|
||
} else if (typeof copy !== "undefined") {
|
||
setProperty(target, { name, newValue: copy });
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return target;
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/html-url-attributes/lib/index.js
|
||
var urlAttributes = {
|
||
action: ["form"],
|
||
cite: ["blockquote", "del", "ins", "q"],
|
||
data: ["object"],
|
||
formAction: ["button", "input"],
|
||
href: ["a", "area", "base", "link"],
|
||
icon: ["menuitem"],
|
||
itemId: null,
|
||
manifest: ["html"],
|
||
ping: ["a", "area"],
|
||
poster: ["video"],
|
||
src: [
|
||
"audio",
|
||
"embed",
|
||
"iframe",
|
||
"img",
|
||
"input",
|
||
"script",
|
||
"source",
|
||
"track",
|
||
"video"
|
||
]
|
||
};
|
||
|
||
// node_modules/react-markdown/lib/index.js
|
||
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
||
var import_react = __toESM(require_react(), 1);
|
||
|
||
// node_modules/micromark/lib/compile.js
|
||
var hasOwnProperty = {}.hasOwnProperty;
|
||
|
||
// node_modules/micromark/lib/initialize/content.js
|
||
var content2 = {
|
||
tokenize: initializeContent
|
||
};
|
||
function initializeContent(effects) {
|
||
const contentStart = effects.attempt(this.parser.constructs.contentInitial, afterContentStartConstruct, paragraphInitial);
|
||
let previous;
|
||
return contentStart;
|
||
function afterContentStartConstruct(code2) {
|
||
if (code2 === null) {
|
||
effects.consume(code2);
|
||
return;
|
||
}
|
||
effects.enter("lineEnding");
|
||
effects.consume(code2);
|
||
effects.exit("lineEnding");
|
||
return factorySpace(effects, contentStart, "linePrefix");
|
||
}
|
||
function paragraphInitial(code2) {
|
||
effects.enter("paragraph");
|
||
return lineStart(code2);
|
||
}
|
||
function lineStart(code2) {
|
||
const token = effects.enter("chunkText", {
|
||
contentType: "text",
|
||
previous
|
||
});
|
||
if (previous) {
|
||
previous.next = token;
|
||
}
|
||
previous = token;
|
||
return data(code2);
|
||
}
|
||
function data(code2) {
|
||
if (code2 === null) {
|
||
effects.exit("chunkText");
|
||
effects.exit("paragraph");
|
||
effects.consume(code2);
|
||
return;
|
||
}
|
||
if (markdownLineEnding(code2)) {
|
||
effects.consume(code2);
|
||
effects.exit("chunkText");
|
||
return lineStart;
|
||
}
|
||
effects.consume(code2);
|
||
return data;
|
||
}
|
||
}
|
||
|
||
// node_modules/micromark/lib/initialize/document.js
|
||
var document = {
|
||
tokenize: initializeDocument
|
||
};
|
||
var containerConstruct = {
|
||
tokenize: tokenizeContainer
|
||
};
|
||
function initializeDocument(effects) {
|
||
const self = this;
|
||
const stack = [];
|
||
let continued = 0;
|
||
let childFlow;
|
||
let childToken;
|
||
let lineStartOffset;
|
||
return start;
|
||
function start(code2) {
|
||
if (continued < stack.length) {
|
||
const item = stack[continued];
|
||
self.containerState = item[1];
|
||
return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code2);
|
||
}
|
||
return checkNewContainers(code2);
|
||
}
|
||
function documentContinue(code2) {
|
||
continued++;
|
||
if (self.containerState._closeFlow) {
|
||
self.containerState._closeFlow = void 0;
|
||
if (childFlow) {
|
||
closeFlow();
|
||
}
|
||
const indexBeforeExits = self.events.length;
|
||
let indexBeforeFlow = indexBeforeExits;
|
||
let point2;
|
||
while (indexBeforeFlow--) {
|
||
if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === "chunkFlow") {
|
||
point2 = self.events[indexBeforeFlow][1].end;
|
||
break;
|
||
}
|
||
}
|
||
exitContainers(continued);
|
||
let index = indexBeforeExits;
|
||
while (index < self.events.length) {
|
||
self.events[index][1].end = {
|
||
...point2
|
||
};
|
||
index++;
|
||
}
|
||
splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
|
||
self.events.length = index;
|
||
return checkNewContainers(code2);
|
||
}
|
||
return start(code2);
|
||
}
|
||
function checkNewContainers(code2) {
|
||
if (continued === stack.length) {
|
||
if (!childFlow) {
|
||
return documentContinued(code2);
|
||
}
|
||
if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) {
|
||
return flowStart(code2);
|
||
}
|
||
self.interrupt = Boolean(childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack);
|
||
}
|
||
self.containerState = {};
|
||
return effects.check(containerConstruct, thereIsANewContainer, thereIsNoNewContainer)(code2);
|
||
}
|
||
function thereIsANewContainer(code2) {
|
||
if (childFlow) closeFlow();
|
||
exitContainers(continued);
|
||
return documentContinued(code2);
|
||
}
|
||
function thereIsNoNewContainer(code2) {
|
||
self.parser.lazy[self.now().line] = continued !== stack.length;
|
||
lineStartOffset = self.now().offset;
|
||
return flowStart(code2);
|
||
}
|
||
function documentContinued(code2) {
|
||
self.containerState = {};
|
||
return effects.attempt(containerConstruct, containerContinue, flowStart)(code2);
|
||
}
|
||
function containerContinue(code2) {
|
||
continued++;
|
||
stack.push([self.currentConstruct, self.containerState]);
|
||
return documentContinued(code2);
|
||
}
|
||
function flowStart(code2) {
|
||
if (code2 === null) {
|
||
if (childFlow) closeFlow();
|
||
exitContainers(0);
|
||
effects.consume(code2);
|
||
return;
|
||
}
|
||
childFlow = childFlow || self.parser.flow(self.now());
|
||
effects.enter("chunkFlow", {
|
||
_tokenizer: childFlow,
|
||
contentType: "flow",
|
||
previous: childToken
|
||
});
|
||
return flowContinue(code2);
|
||
}
|
||
function flowContinue(code2) {
|
||
if (code2 === null) {
|
||
writeToChild(effects.exit("chunkFlow"), true);
|
||
exitContainers(0);
|
||
effects.consume(code2);
|
||
return;
|
||
}
|
||
if (markdownLineEnding(code2)) {
|
||
effects.consume(code2);
|
||
writeToChild(effects.exit("chunkFlow"));
|
||
continued = 0;
|
||
self.interrupt = void 0;
|
||
return start;
|
||
}
|
||
effects.consume(code2);
|
||
return flowContinue;
|
||
}
|
||
function writeToChild(token, endOfFile) {
|
||
const stream = self.sliceStream(token);
|
||
if (endOfFile) stream.push(null);
|
||
token.previous = childToken;
|
||
if (childToken) childToken.next = token;
|
||
childToken = token;
|
||
childFlow.defineSkip(token.start);
|
||
childFlow.write(stream);
|
||
if (self.parser.lazy[token.start.line]) {
|
||
let index = childFlow.events.length;
|
||
while (index--) {
|
||
if (
|
||
// The token starts before the line ending…
|
||
childFlow.events[index][1].start.offset < lineStartOffset && // …and either is not ended yet…
|
||
(!childFlow.events[index][1].end || // …or ends after it.
|
||
childFlow.events[index][1].end.offset > lineStartOffset)
|
||
) {
|
||
return;
|
||
}
|
||
}
|
||
const indexBeforeExits = self.events.length;
|
||
let indexBeforeFlow = indexBeforeExits;
|
||
let seen;
|
||
let point2;
|
||
while (indexBeforeFlow--) {
|
||
if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === "chunkFlow") {
|
||
if (seen) {
|
||
point2 = self.events[indexBeforeFlow][1].end;
|
||
break;
|
||
}
|
||
seen = true;
|
||
}
|
||
}
|
||
exitContainers(continued);
|
||
index = indexBeforeExits;
|
||
while (index < self.events.length) {
|
||
self.events[index][1].end = {
|
||
...point2
|
||
};
|
||
index++;
|
||
}
|
||
splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
|
||
self.events.length = index;
|
||
}
|
||
}
|
||
function exitContainers(size) {
|
||
let index = stack.length;
|
||
while (index-- > size) {
|
||
const entry = stack[index];
|
||
self.containerState = entry[1];
|
||
entry[0].exit.call(self, effects);
|
||
}
|
||
stack.length = size;
|
||
}
|
||
function closeFlow() {
|
||
childFlow.write([null]);
|
||
childToken = void 0;
|
||
childFlow = void 0;
|
||
self.containerState._closeFlow = void 0;
|
||
}
|
||
}
|
||
function tokenizeContainer(effects, ok2, nok) {
|
||
return factorySpace(effects, effects.attempt(this.parser.constructs.document, ok2, nok), "linePrefix", this.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4);
|
||
}
|
||
|
||
// node_modules/micromark/lib/initialize/flow.js
|
||
var flow = {
|
||
tokenize: initializeFlow
|
||
};
|
||
function initializeFlow(effects) {
|
||
const self = this;
|
||
const initial = effects.attempt(
|
||
// Try to parse a blank line.
|
||
blankLine,
|
||
atBlankEnding,
|
||
// Try to parse initial flow (essentially, only code).
|
||
effects.attempt(this.parser.constructs.flowInitial, afterConstruct, factorySpace(effects, effects.attempt(this.parser.constructs.flow, afterConstruct, effects.attempt(content, afterConstruct)), "linePrefix"))
|
||
);
|
||
return initial;
|
||
function atBlankEnding(code2) {
|
||
if (code2 === null) {
|
||
effects.consume(code2);
|
||
return;
|
||
}
|
||
effects.enter("lineEndingBlank");
|
||
effects.consume(code2);
|
||
effects.exit("lineEndingBlank");
|
||
self.currentConstruct = void 0;
|
||
return initial;
|
||
}
|
||
function afterConstruct(code2) {
|
||
if (code2 === null) {
|
||
effects.consume(code2);
|
||
return;
|
||
}
|
||
effects.enter("lineEnding");
|
||
effects.consume(code2);
|
||
effects.exit("lineEnding");
|
||
self.currentConstruct = void 0;
|
||
return initial;
|
||
}
|
||
}
|
||
|
||
// node_modules/micromark/lib/initialize/text.js
|
||
var resolver = {
|
||
resolveAll: createResolver()
|
||
};
|
||
var string = initializeFactory("string");
|
||
var text = initializeFactory("text");
|
||
function initializeFactory(field) {
|
||
return {
|
||
resolveAll: createResolver(field === "text" ? resolveAllLineSuffixes : void 0),
|
||
tokenize: initializeText
|
||
};
|
||
function initializeText(effects) {
|
||
const self = this;
|
||
const constructs = this.parser.constructs[field];
|
||
const text4 = effects.attempt(constructs, start, notText);
|
||
return start;
|
||
function start(code2) {
|
||
return atBreak(code2) ? text4(code2) : notText(code2);
|
||
}
|
||
function notText(code2) {
|
||
if (code2 === null) {
|
||
effects.consume(code2);
|
||
return;
|
||
}
|
||
effects.enter("data");
|
||
effects.consume(code2);
|
||
return data;
|
||
}
|
||
function data(code2) {
|
||
if (atBreak(code2)) {
|
||
effects.exit("data");
|
||
return text4(code2);
|
||
}
|
||
effects.consume(code2);
|
||
return data;
|
||
}
|
||
function atBreak(code2) {
|
||
if (code2 === null) {
|
||
return true;
|
||
}
|
||
const list3 = constructs[code2];
|
||
let index = -1;
|
||
if (list3) {
|
||
while (++index < list3.length) {
|
||
const item = list3[index];
|
||
if (!item.previous || item.previous.call(self, self.previous)) {
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
function createResolver(extraResolver) {
|
||
return resolveAllText;
|
||
function resolveAllText(events, context) {
|
||
let index = -1;
|
||
let enter;
|
||
while (++index <= events.length) {
|
||
if (enter === void 0) {
|
||
if (events[index] && events[index][1].type === "data") {
|
||
enter = index;
|
||
index++;
|
||
}
|
||
} else if (!events[index] || events[index][1].type !== "data") {
|
||
if (index !== enter + 2) {
|
||
events[enter][1].end = events[index - 1][1].end;
|
||
events.splice(enter + 2, index - enter - 2);
|
||
index = enter + 2;
|
||
}
|
||
enter = void 0;
|
||
}
|
||
}
|
||
return extraResolver ? extraResolver(events, context) : events;
|
||
}
|
||
}
|
||
function resolveAllLineSuffixes(events, context) {
|
||
let eventIndex = 0;
|
||
while (++eventIndex <= events.length) {
|
||
if ((eventIndex === events.length || events[eventIndex][1].type === "lineEnding") && events[eventIndex - 1][1].type === "data") {
|
||
const data = events[eventIndex - 1][1];
|
||
const chunks = context.sliceStream(data);
|
||
let index = chunks.length;
|
||
let bufferIndex = -1;
|
||
let size = 0;
|
||
let tabs;
|
||
while (index--) {
|
||
const chunk = chunks[index];
|
||
if (typeof chunk === "string") {
|
||
bufferIndex = chunk.length;
|
||
while (chunk.charCodeAt(bufferIndex - 1) === 32) {
|
||
size++;
|
||
bufferIndex--;
|
||
}
|
||
if (bufferIndex) break;
|
||
bufferIndex = -1;
|
||
} else if (chunk === -2) {
|
||
tabs = true;
|
||
size++;
|
||
} else if (chunk === -1) {
|
||
} else {
|
||
index++;
|
||
break;
|
||
}
|
||
}
|
||
if (context._contentTypeTextTrailing && eventIndex === events.length) {
|
||
size = 0;
|
||
}
|
||
if (size) {
|
||
const token = {
|
||
type: eventIndex === events.length || tabs || size < 2 ? "lineSuffix" : "hardBreakTrailing",
|
||
start: {
|
||
_bufferIndex: index ? bufferIndex : data.start._bufferIndex + bufferIndex,
|
||
_index: data.start._index + index,
|
||
line: data.end.line,
|
||
column: data.end.column - size,
|
||
offset: data.end.offset - size
|
||
},
|
||
end: {
|
||
...data.end
|
||
}
|
||
};
|
||
data.end = {
|
||
...token.start
|
||
};
|
||
if (data.start.offset === data.end.offset) {
|
||
Object.assign(data, token);
|
||
} else {
|
||
events.splice(eventIndex, 0, ["enter", token, context], ["exit", token, context]);
|
||
eventIndex += 2;
|
||
}
|
||
}
|
||
eventIndex++;
|
||
}
|
||
}
|
||
return events;
|
||
}
|
||
|
||
// node_modules/micromark/lib/constructs.js
|
||
var constructs_exports = {};
|
||
__export(constructs_exports, {
|
||
attentionMarkers: () => attentionMarkers,
|
||
contentInitial: () => contentInitial,
|
||
disable: () => disable,
|
||
document: () => document2,
|
||
flow: () => flow2,
|
||
flowInitial: () => flowInitial,
|
||
insideSpan: () => insideSpan,
|
||
string: () => string2,
|
||
text: () => text2
|
||
});
|
||
var document2 = {
|
||
[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
|
||
};
|
||
var contentInitial = {
|
||
[91]: definition
|
||
};
|
||
var flowInitial = {
|
||
[-2]: codeIndented,
|
||
[-1]: codeIndented,
|
||
[32]: codeIndented
|
||
};
|
||
var flow2 = {
|
||
[35]: headingAtx,
|
||
[42]: thematicBreak,
|
||
[45]: [setextUnderline, thematicBreak],
|
||
[60]: htmlFlow,
|
||
[61]: setextUnderline,
|
||
[95]: thematicBreak,
|
||
[96]: codeFenced,
|
||
[126]: codeFenced
|
||
};
|
||
var string2 = {
|
||
[38]: characterReference,
|
||
[92]: characterEscape
|
||
};
|
||
var text2 = {
|
||
[-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
|
||
};
|
||
var insideSpan = {
|
||
null: [attention, resolver]
|
||
};
|
||
var attentionMarkers = {
|
||
null: [42, 95]
|
||
};
|
||
var disable = {
|
||
null: []
|
||
};
|
||
|
||
// node_modules/micromark/lib/create-tokenizer.js
|
||
function createTokenizer(parser, initialize, from) {
|
||
let point2 = {
|
||
_bufferIndex: -1,
|
||
_index: 0,
|
||
line: from && from.line || 1,
|
||
column: from && from.column || 1,
|
||
offset: from && from.offset || 0
|
||
};
|
||
const columnStart = {};
|
||
const resolveAllConstructs = [];
|
||
let chunks = [];
|
||
let stack = [];
|
||
let consumed = true;
|
||
const effects = {
|
||
attempt: constructFactory(onsuccessfulconstruct),
|
||
check: constructFactory(onsuccessfulcheck),
|
||
consume,
|
||
enter,
|
||
exit,
|
||
interrupt: constructFactory(onsuccessfulcheck, {
|
||
interrupt: true
|
||
})
|
||
};
|
||
const context = {
|
||
code: null,
|
||
containerState: {},
|
||
defineSkip,
|
||
events: [],
|
||
now,
|
||
parser,
|
||
previous: null,
|
||
sliceSerialize,
|
||
sliceStream,
|
||
write
|
||
};
|
||
let state = initialize.tokenize.call(context, effects);
|
||
let expectedCode;
|
||
if (initialize.resolveAll) {
|
||
resolveAllConstructs.push(initialize);
|
||
}
|
||
return context;
|
||
function write(slice) {
|
||
chunks = push(chunks, slice);
|
||
main();
|
||
if (chunks[chunks.length - 1] !== null) {
|
||
return [];
|
||
}
|
||
addResult(initialize, 0);
|
||
context.events = resolveAll(resolveAllConstructs, context.events, context);
|
||
return context.events;
|
||
}
|
||
function sliceSerialize(token, expandTabs) {
|
||
return serializeChunks(sliceStream(token), expandTabs);
|
||
}
|
||
function sliceStream(token) {
|
||
return sliceChunks(chunks, token);
|
||
}
|
||
function now() {
|
||
const {
|
||
_bufferIndex,
|
||
_index,
|
||
line,
|
||
column,
|
||
offset
|
||
} = point2;
|
||
return {
|
||
_bufferIndex,
|
||
_index,
|
||
line,
|
||
column,
|
||
offset
|
||
};
|
||
}
|
||
function defineSkip(value) {
|
||
columnStart[value.line] = value.column;
|
||
accountForPotentialSkip();
|
||
}
|
||
function main() {
|
||
let chunkIndex;
|
||
while (point2._index < chunks.length) {
|
||
const chunk = chunks[point2._index];
|
||
if (typeof chunk === "string") {
|
||
chunkIndex = point2._index;
|
||
if (point2._bufferIndex < 0) {
|
||
point2._bufferIndex = 0;
|
||
}
|
||
while (point2._index === chunkIndex && point2._bufferIndex < chunk.length) {
|
||
go(chunk.charCodeAt(point2._bufferIndex));
|
||
}
|
||
} else {
|
||
go(chunk);
|
||
}
|
||
}
|
||
}
|
||
function go(code2) {
|
||
consumed = void 0;
|
||
expectedCode = code2;
|
||
state = state(code2);
|
||
}
|
||
function consume(code2) {
|
||
if (markdownLineEnding(code2)) {
|
||
point2.line++;
|
||
point2.column = 1;
|
||
point2.offset += code2 === -3 ? 2 : 1;
|
||
accountForPotentialSkip();
|
||
} else if (code2 !== -1) {
|
||
point2.column++;
|
||
point2.offset++;
|
||
}
|
||
if (point2._bufferIndex < 0) {
|
||
point2._index++;
|
||
} else {
|
||
point2._bufferIndex++;
|
||
if (point2._bufferIndex === // Points w/ non-negative `_bufferIndex` reference
|
||
// strings.
|
||
/** @type {string} */
|
||
chunks[point2._index].length) {
|
||
point2._bufferIndex = -1;
|
||
point2._index++;
|
||
}
|
||
}
|
||
context.previous = code2;
|
||
consumed = true;
|
||
}
|
||
function enter(type, fields) {
|
||
const token = fields || {};
|
||
token.type = type;
|
||
token.start = now();
|
||
context.events.push(["enter", token, context]);
|
||
stack.push(token);
|
||
return token;
|
||
}
|
||
function exit(type) {
|
||
const token = stack.pop();
|
||
token.end = now();
|
||
context.events.push(["exit", token, context]);
|
||
return token;
|
||
}
|
||
function onsuccessfulconstruct(construct, info) {
|
||
addResult(construct, info.from);
|
||
}
|
||
function onsuccessfulcheck(_, info) {
|
||
info.restore();
|
||
}
|
||
function constructFactory(onreturn, fields) {
|
||
return hook;
|
||
function hook(constructs, returnState, bogusState) {
|
||
let listOfConstructs;
|
||
let constructIndex;
|
||
let currentConstruct;
|
||
let info;
|
||
return Array.isArray(constructs) ? (
|
||
/* c8 ignore next 1 */
|
||
handleListOfConstructs(constructs)
|
||
) : "tokenize" in constructs ? (
|
||
// Looks like a construct.
|
||
handleListOfConstructs([
|
||
/** @type {Construct} */
|
||
constructs
|
||
])
|
||
) : handleMapOfConstructs(constructs);
|
||
function handleMapOfConstructs(map) {
|
||
return start;
|
||
function start(code2) {
|
||
const left = code2 !== null && map[code2];
|
||
const all = code2 !== null && map.null;
|
||
const list3 = [
|
||
// To do: add more extension tests.
|
||
/* c8 ignore next 2 */
|
||
...Array.isArray(left) ? left : left ? [left] : [],
|
||
...Array.isArray(all) ? all : all ? [all] : []
|
||
];
|
||
return handleListOfConstructs(list3)(code2);
|
||
}
|
||
}
|
||
function handleListOfConstructs(list3) {
|
||
listOfConstructs = list3;
|
||
constructIndex = 0;
|
||
if (list3.length === 0) {
|
||
return bogusState;
|
||
}
|
||
return handleConstruct(list3[constructIndex]);
|
||
}
|
||
function handleConstruct(construct) {
|
||
return start;
|
||
function start(code2) {
|
||
info = store();
|
||
currentConstruct = construct;
|
||
if (!construct.partial) {
|
||
context.currentConstruct = construct;
|
||
}
|
||
if (construct.name && context.parser.constructs.disable.null.includes(construct.name)) {
|
||
return nok(code2);
|
||
}
|
||
return construct.tokenize.call(
|
||
// If we do have fields, create an object w/ `context` as its
|
||
// prototype.
|
||
// This allows a “live binding”, which is needed for `interrupt`.
|
||
fields ? Object.assign(Object.create(context), fields) : context,
|
||
effects,
|
||
ok2,
|
||
nok
|
||
)(code2);
|
||
}
|
||
}
|
||
function ok2(code2) {
|
||
consumed = true;
|
||
onreturn(currentConstruct, info);
|
||
return returnState;
|
||
}
|
||
function nok(code2) {
|
||
consumed = true;
|
||
info.restore();
|
||
if (++constructIndex < listOfConstructs.length) {
|
||
return handleConstruct(listOfConstructs[constructIndex]);
|
||
}
|
||
return bogusState;
|
||
}
|
||
}
|
||
}
|
||
function addResult(construct, from2) {
|
||
if (construct.resolveAll && !resolveAllConstructs.includes(construct)) {
|
||
resolveAllConstructs.push(construct);
|
||
}
|
||
if (construct.resolve) {
|
||
splice(context.events, from2, context.events.length - from2, construct.resolve(context.events.slice(from2), context));
|
||
}
|
||
if (construct.resolveTo) {
|
||
context.events = construct.resolveTo(context.events, context);
|
||
}
|
||
}
|
||
function store() {
|
||
const startPoint = now();
|
||
const startPrevious = context.previous;
|
||
const startCurrentConstruct = context.currentConstruct;
|
||
const startEventsIndex = context.events.length;
|
||
const startStack = Array.from(stack);
|
||
return {
|
||
from: startEventsIndex,
|
||
restore
|
||
};
|
||
function restore() {
|
||
point2 = startPoint;
|
||
context.previous = startPrevious;
|
||
context.currentConstruct = startCurrentConstruct;
|
||
context.events.length = startEventsIndex;
|
||
stack = startStack;
|
||
accountForPotentialSkip();
|
||
}
|
||
}
|
||
function accountForPotentialSkip() {
|
||
if (point2.line in columnStart && point2.column < 2) {
|
||
point2.column = columnStart[point2.line];
|
||
point2.offset += columnStart[point2.line] - 1;
|
||
}
|
||
}
|
||
}
|
||
function sliceChunks(chunks, token) {
|
||
const startIndex = token.start._index;
|
||
const startBufferIndex = token.start._bufferIndex;
|
||
const endIndex = token.end._index;
|
||
const endBufferIndex = token.end._bufferIndex;
|
||
let view;
|
||
if (startIndex === endIndex) {
|
||
view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)];
|
||
} else {
|
||
view = chunks.slice(startIndex, endIndex);
|
||
if (startBufferIndex > -1) {
|
||
const head = view[0];
|
||
if (typeof head === "string") {
|
||
view[0] = head.slice(startBufferIndex);
|
||
} else {
|
||
view.shift();
|
||
}
|
||
}
|
||
if (endBufferIndex > 0) {
|
||
view.push(chunks[endIndex].slice(0, endBufferIndex));
|
||
}
|
||
}
|
||
return view;
|
||
}
|
||
function serializeChunks(chunks, expandTabs) {
|
||
let index = -1;
|
||
const result = [];
|
||
let atTab;
|
||
while (++index < chunks.length) {
|
||
const chunk = chunks[index];
|
||
let value;
|
||
if (typeof chunk === "string") {
|
||
value = chunk;
|
||
} else switch (chunk) {
|
||
case -5: {
|
||
value = "\r";
|
||
break;
|
||
}
|
||
case -4: {
|
||
value = "\n";
|
||
break;
|
||
}
|
||
case -3: {
|
||
value = "\r\n";
|
||
break;
|
||
}
|
||
case -2: {
|
||
value = expandTabs ? " " : " ";
|
||
break;
|
||
}
|
||
case -1: {
|
||
if (!expandTabs && atTab) continue;
|
||
value = " ";
|
||
break;
|
||
}
|
||
default: {
|
||
value = String.fromCharCode(chunk);
|
||
}
|
||
}
|
||
atTab = chunk === -2;
|
||
result.push(value);
|
||
}
|
||
return result.join("");
|
||
}
|
||
|
||
// node_modules/micromark/lib/parse.js
|
||
function parse(options) {
|
||
const settings = options || {};
|
||
const constructs = (
|
||
/** @type {FullNormalizedExtension} */
|
||
combineExtensions([constructs_exports, ...settings.extensions || []])
|
||
);
|
||
const parser = {
|
||
constructs,
|
||
content: create(content2),
|
||
defined: [],
|
||
document: create(document),
|
||
flow: create(flow),
|
||
lazy: {},
|
||
string: create(string),
|
||
text: create(text)
|
||
};
|
||
return parser;
|
||
function create(initial) {
|
||
return creator;
|
||
function creator(from) {
|
||
return createTokenizer(parser, initial, from);
|
||
}
|
||
}
|
||
}
|
||
|
||
// node_modules/micromark/lib/postprocess.js
|
||
function postprocess(events) {
|
||
while (!subtokenize(events)) {
|
||
}
|
||
return events;
|
||
}
|
||
|
||
// node_modules/micromark/lib/preprocess.js
|
||
var search = /[\0\t\n\r]/g;
|
||
function preprocess() {
|
||
let column = 1;
|
||
let buffer = "";
|
||
let start = true;
|
||
let atCarriageReturn;
|
||
return preprocessor;
|
||
function preprocessor(value, encoding, end) {
|
||
const chunks = [];
|
||
let match;
|
||
let next;
|
||
let startPosition;
|
||
let endPosition;
|
||
let code2;
|
||
value = buffer + (typeof value === "string" ? value.toString() : new TextDecoder(encoding || void 0).decode(value));
|
||
startPosition = 0;
|
||
buffer = "";
|
||
if (start) {
|
||
if (value.charCodeAt(0) === 65279) {
|
||
startPosition++;
|
||
}
|
||
start = void 0;
|
||
}
|
||
while (startPosition < value.length) {
|
||
search.lastIndex = startPosition;
|
||
match = search.exec(value);
|
||
endPosition = match && match.index !== void 0 ? match.index : value.length;
|
||
code2 = value.charCodeAt(endPosition);
|
||
if (!match) {
|
||
buffer = value.slice(startPosition);
|
||
break;
|
||
}
|
||
if (code2 === 10 && startPosition === endPosition && atCarriageReturn) {
|
||
chunks.push(-3);
|
||
atCarriageReturn = void 0;
|
||
} else {
|
||
if (atCarriageReturn) {
|
||
chunks.push(-5);
|
||
atCarriageReturn = void 0;
|
||
}
|
||
if (startPosition < endPosition) {
|
||
chunks.push(value.slice(startPosition, endPosition));
|
||
column += endPosition - startPosition;
|
||
}
|
||
switch (code2) {
|
||
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;
|
||
}
|
||
}
|
||
|
||
// node_modules/mdast-util-from-markdown/lib/index.js
|
||
var own = {}.hasOwnProperty;
|
||
function fromMarkdown(value, encoding, options) {
|
||
if (typeof encoding !== "string") {
|
||
options = encoding;
|
||
encoding = void 0;
|
||
}
|
||
return compiler(options)(postprocess(parse(options).document().write(preprocess()(value, encoding, true))));
|
||
}
|
||
function compiler(options) {
|
||
const config = {
|
||
transforms: [],
|
||
canContainEols: ["emphasis", "fragment", "heading", "paragraph", "strong"],
|
||
enter: {
|
||
autolink: opener(link2),
|
||
autolinkProtocol: onenterdata,
|
||
autolinkEmail: onenterdata,
|
||
atxHeading: opener(heading2),
|
||
blockQuote: opener(blockQuote2),
|
||
characterEscape: onenterdata,
|
||
characterReference: onenterdata,
|
||
codeFenced: opener(codeFlow),
|
||
codeFencedFenceInfo: buffer,
|
||
codeFencedFenceMeta: buffer,
|
||
codeIndented: opener(codeFlow, buffer),
|
||
codeText: opener(codeText2, buffer),
|
||
codeTextData: onenterdata,
|
||
data: onenterdata,
|
||
codeFlowValue: onenterdata,
|
||
definition: opener(definition2),
|
||
definitionDestinationString: buffer,
|
||
definitionLabelString: buffer,
|
||
definitionTitleString: buffer,
|
||
emphasis: opener(emphasis2),
|
||
hardBreakEscape: opener(hardBreak2),
|
||
hardBreakTrailing: opener(hardBreak2),
|
||
htmlFlow: opener(html2, buffer),
|
||
htmlFlowData: onenterdata,
|
||
htmlText: opener(html2, buffer),
|
||
htmlTextData: onenterdata,
|
||
image: opener(image2),
|
||
label: buffer,
|
||
link: opener(link2),
|
||
listItem: opener(listItem2),
|
||
listItemValue: onenterlistitemvalue,
|
||
listOrdered: opener(list3, onenterlistordered),
|
||
listUnordered: opener(list3),
|
||
paragraph: opener(paragraph2),
|
||
reference: onenterreference,
|
||
referenceString: buffer,
|
||
resourceDestinationString: buffer,
|
||
resourceTitleString: buffer,
|
||
setextHeading: opener(heading2),
|
||
strong: opener(strong2),
|
||
thematicBreak: opener(thematicBreak3)
|
||
},
|
||
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 || []);
|
||
const data = {};
|
||
return compile2;
|
||
function compile2(events) {
|
||
let tree = {
|
||
type: "root",
|
||
children: []
|
||
};
|
||
const context = {
|
||
stack: [tree],
|
||
tokenStack: [],
|
||
config,
|
||
enter,
|
||
exit,
|
||
buffer,
|
||
resume,
|
||
data
|
||
};
|
||
const listStack = [];
|
||
let index = -1;
|
||
while (++index < events.length) {
|
||
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 (own.call(handler, events[index][1].type)) {
|
||
handler[events[index][1].type].call(Object.assign({
|
||
sliceSerialize: events[index][2].sliceSerialize
|
||
}, context), events[index][1]);
|
||
}
|
||
}
|
||
if (context.tokenStack.length > 0) {
|
||
const tail = context.tokenStack[context.tokenStack.length - 1];
|
||
const handler = tail[1] || defaultOnError;
|
||
handler.call(context, void 0, tail[0]);
|
||
}
|
||
tree.position = {
|
||
start: point(events.length > 0 ? events[0][1].start : {
|
||
line: 1,
|
||
column: 1,
|
||
offset: 0
|
||
}),
|
||
end: point(events.length > 0 ? events[events.length - 2][1].end : {
|
||
line: 1,
|
||
column: 1,
|
||
offset: 0
|
||
})
|
||
};
|
||
index = -1;
|
||
while (++index < config.transforms.length) {
|
||
tree = config.transforms[index](tree) || tree;
|
||
}
|
||
return tree;
|
||
}
|
||
function prepareList(events, start, length) {
|
||
let index = start - 1;
|
||
let containerBalance = -1;
|
||
let listSpread = false;
|
||
let listItem3;
|
||
let lineIndex;
|
||
let firstBlankLineIndex;
|
||
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 = void 0;
|
||
break;
|
||
}
|
||
case "lineEndingBlank": {
|
||
if (event[0] === "enter") {
|
||
if (listItem3 && !atMarker && !containerBalance && !firstBlankLineIndex) {
|
||
firstBlankLineIndex = index;
|
||
}
|
||
atMarker = void 0;
|
||
}
|
||
break;
|
||
}
|
||
case "linePrefix":
|
||
case "listItemValue":
|
||
case "listItemMarker":
|
||
case "listItemPrefix":
|
||
case "listItemPrefixWhitespace": {
|
||
break;
|
||
}
|
||
default: {
|
||
atMarker = void 0;
|
||
}
|
||
}
|
||
if (!containerBalance && event[0] === "enter" && event[1].type === "listItemPrefix" || containerBalance === -1 && event[0] === "exit" && (event[1].type === "listUnordered" || event[1].type === "listOrdered")) {
|
||
if (listItem3) {
|
||
let tailIndex = index;
|
||
lineIndex = void 0;
|
||
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") {
|
||
} else {
|
||
break;
|
||
}
|
||
}
|
||
if (firstBlankLineIndex && (!lineIndex || firstBlankLineIndex < lineIndex)) {
|
||
listItem3._spread = true;
|
||
}
|
||
listItem3.end = Object.assign({}, lineIndex ? events[lineIndex][1].start : event[1].end);
|
||
events.splice(lineIndex || index, 0, ["exit", listItem3, event[2]]);
|
||
index++;
|
||
length++;
|
||
}
|
||
if (event[1].type === "listItemPrefix") {
|
||
const item = {
|
||
type: "listItem",
|
||
_spread: false,
|
||
start: Object.assign({}, event[1].start),
|
||
// @ts-expect-error: we’ll add `end` in a second.
|
||
end: void 0
|
||
};
|
||
listItem3 = item;
|
||
events.splice(index, 0, ["enter", item, event[2]]);
|
||
index++;
|
||
length++;
|
||
firstBlankLineIndex = void 0;
|
||
atMarker = true;
|
||
}
|
||
}
|
||
}
|
||
events[start][1]._spread = listSpread;
|
||
return length;
|
||
}
|
||
function opener(create, and) {
|
||
return open;
|
||
function open(token) {
|
||
enter.call(this, create(token), token);
|
||
if (and) and.call(this, token);
|
||
}
|
||
}
|
||
function buffer() {
|
||
this.stack.push({
|
||
type: "fragment",
|
||
children: []
|
||
});
|
||
}
|
||
function enter(node, token, errorHandler) {
|
||
const parent = this.stack[this.stack.length - 1];
|
||
const siblings = parent.children;
|
||
siblings.push(node);
|
||
this.stack.push(node);
|
||
this.tokenStack.push([token, errorHandler || void 0]);
|
||
node.position = {
|
||
start: point(token.start),
|
||
// @ts-expect-error: `end` will be patched later.
|
||
end: void 0
|
||
};
|
||
}
|
||
function closer(and) {
|
||
return close;
|
||
function close(token) {
|
||
if (and) and.call(this, token);
|
||
exit.call(this, token);
|
||
}
|
||
}
|
||
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 = point(token.end);
|
||
}
|
||
function resume() {
|
||
return toString(this.stack.pop());
|
||
}
|
||
function onenterlistordered() {
|
||
this.data.expectingFirstListItemValue = true;
|
||
}
|
||
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 = void 0;
|
||
}
|
||
}
|
||
function onexitcodefencedfenceinfo() {
|
||
const data2 = this.resume();
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.lang = data2;
|
||
}
|
||
function onexitcodefencedfencemeta() {
|
||
const data2 = this.resume();
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.meta = data2;
|
||
}
|
||
function onexitcodefencedfence() {
|
||
if (this.data.flowCodeInside) return;
|
||
this.buffer();
|
||
this.data.flowCodeInside = true;
|
||
}
|
||
function onexitcodefenced() {
|
||
const data2 = this.resume();
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.value = data2.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, "");
|
||
this.data.flowCodeInside = void 0;
|
||
}
|
||
function onexitcodeindented() {
|
||
const data2 = this.resume();
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.value = data2.replace(/(\r?\n|\r)$/g, "");
|
||
}
|
||
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();
|
||
}
|
||
function onexitdefinitiontitlestring() {
|
||
const data2 = this.resume();
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.title = data2;
|
||
}
|
||
function onexitdefinitiondestinationstring() {
|
||
const data2 = this.resume();
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.url = data2;
|
||
}
|
||
function onexitatxheadingsequence(token) {
|
||
const node = this.stack[this.stack.length - 1];
|
||
if (!node.depth) {
|
||
const depth = this.sliceSerialize(token).length;
|
||
node.depth = depth;
|
||
}
|
||
}
|
||
function onexitsetextheadingtext() {
|
||
this.data.setextHeadingSlurpLineEnding = true;
|
||
}
|
||
function onexitsetextheadinglinesequence(token) {
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.depth = this.sliceSerialize(token).codePointAt(0) === 61 ? 1 : 2;
|
||
}
|
||
function onexitsetextheading() {
|
||
this.data.setextHeadingSlurpLineEnding = void 0;
|
||
}
|
||
function onenterdata(token) {
|
||
const node = this.stack[this.stack.length - 1];
|
||
const siblings = node.children;
|
||
let tail = siblings[siblings.length - 1];
|
||
if (!tail || tail.type !== "text") {
|
||
tail = text4();
|
||
tail.position = {
|
||
start: point(token.start),
|
||
// @ts-expect-error: we’ll add `end` later.
|
||
end: void 0
|
||
};
|
||
siblings.push(tail);
|
||
}
|
||
this.stack.push(tail);
|
||
}
|
||
function onexitdata(token) {
|
||
const tail = this.stack.pop();
|
||
tail.value += this.sliceSerialize(token);
|
||
tail.position.end = point(token.end);
|
||
}
|
||
function onexitlineending(token) {
|
||
const context = this.stack[this.stack.length - 1];
|
||
if (this.data.atHardBreak) {
|
||
const tail = context.children[context.children.length - 1];
|
||
tail.position.end = point(token.end);
|
||
this.data.atHardBreak = void 0;
|
||
return;
|
||
}
|
||
if (!this.data.setextHeadingSlurpLineEnding && config.canContainEols.includes(context.type)) {
|
||
onenterdata.call(this, token);
|
||
onexitdata.call(this, token);
|
||
}
|
||
}
|
||
function onexithardbreak() {
|
||
this.data.atHardBreak = true;
|
||
}
|
||
function onexithtmlflow() {
|
||
const data2 = this.resume();
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.value = data2;
|
||
}
|
||
function onexithtmltext() {
|
||
const data2 = this.resume();
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.value = data2;
|
||
}
|
||
function onexitcodetext() {
|
||
const data2 = this.resume();
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.value = data2;
|
||
}
|
||
function onexitlink() {
|
||
const node = this.stack[this.stack.length - 1];
|
||
if (this.data.inReference) {
|
||
const referenceType = this.data.referenceType || "shortcut";
|
||
node.type += "Reference";
|
||
node.referenceType = referenceType;
|
||
delete node.url;
|
||
delete node.title;
|
||
} else {
|
||
delete node.identifier;
|
||
delete node.label;
|
||
}
|
||
this.data.referenceType = void 0;
|
||
}
|
||
function onexitimage() {
|
||
const node = this.stack[this.stack.length - 1];
|
||
if (this.data.inReference) {
|
||
const referenceType = this.data.referenceType || "shortcut";
|
||
node.type += "Reference";
|
||
node.referenceType = referenceType;
|
||
delete node.url;
|
||
delete node.title;
|
||
} else {
|
||
delete node.identifier;
|
||
delete node.label;
|
||
}
|
||
this.data.referenceType = void 0;
|
||
}
|
||
function onexitlabeltext(token) {
|
||
const string3 = this.sliceSerialize(token);
|
||
const ancestor = this.stack[this.stack.length - 2];
|
||
ancestor.label = decodeString(string3);
|
||
ancestor.identifier = normalizeIdentifier(string3).toLowerCase();
|
||
}
|
||
function onexitlabel() {
|
||
const fragment = this.stack[this.stack.length - 1];
|
||
const value = this.resume();
|
||
const node = this.stack[this.stack.length - 1];
|
||
this.data.inReference = true;
|
||
if (node.type === "link") {
|
||
const children = fragment.children;
|
||
node.children = children;
|
||
} else {
|
||
node.alt = value;
|
||
}
|
||
}
|
||
function onexitresourcedestinationstring() {
|
||
const data2 = this.resume();
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.url = data2;
|
||
}
|
||
function onexitresourcetitlestring() {
|
||
const data2 = this.resume();
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.title = data2;
|
||
}
|
||
function onexitresource() {
|
||
this.data.inReference = void 0;
|
||
}
|
||
function onenterreference() {
|
||
this.data.referenceType = "collapsed";
|
||
}
|
||
function onexitreferencestring(token) {
|
||
const label = this.resume();
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.label = label;
|
||
node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
|
||
this.data.referenceType = "full";
|
||
}
|
||
function onexitcharacterreferencemarker(token) {
|
||
this.data.characterReferenceType = token.type;
|
||
}
|
||
function onexitcharacterreferencevalue(token) {
|
||
const data2 = this.sliceSerialize(token);
|
||
const type = this.data.characterReferenceType;
|
||
let value;
|
||
if (type) {
|
||
value = decodeNumericCharacterReference(data2, type === "characterReferenceMarkerNumeric" ? 10 : 16);
|
||
this.data.characterReferenceType = void 0;
|
||
} else {
|
||
const result = decodeNamedCharacterReference(data2);
|
||
value = result;
|
||
}
|
||
const tail = this.stack[this.stack.length - 1];
|
||
tail.value += value;
|
||
}
|
||
function onexitcharacterreference(token) {
|
||
const tail = this.stack.pop();
|
||
tail.position.end = point(token.end);
|
||
}
|
||
function onexitautolinkprotocol(token) {
|
||
onexitdata.call(this, token);
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.url = this.sliceSerialize(token);
|
||
}
|
||
function onexitautolinkemail(token) {
|
||
onexitdata.call(this, token);
|
||
const node = this.stack[this.stack.length - 1];
|
||
node.url = "mailto:" + this.sliceSerialize(token);
|
||
}
|
||
function blockQuote2() {
|
||
return {
|
||
type: "blockquote",
|
||
children: []
|
||
};
|
||
}
|
||
function codeFlow() {
|
||
return {
|
||
type: "code",
|
||
lang: null,
|
||
meta: null,
|
||
value: ""
|
||
};
|
||
}
|
||
function codeText2() {
|
||
return {
|
||
type: "inlineCode",
|
||
value: ""
|
||
};
|
||
}
|
||
function definition2() {
|
||
return {
|
||
type: "definition",
|
||
identifier: "",
|
||
label: null,
|
||
title: null,
|
||
url: ""
|
||
};
|
||
}
|
||
function emphasis2() {
|
||
return {
|
||
type: "emphasis",
|
||
children: []
|
||
};
|
||
}
|
||
function heading2() {
|
||
return {
|
||
type: "heading",
|
||
// @ts-expect-error `depth` will be set later.
|
||
depth: 0,
|
||
children: []
|
||
};
|
||
}
|
||
function hardBreak2() {
|
||
return {
|
||
type: "break"
|
||
};
|
||
}
|
||
function html2() {
|
||
return {
|
||
type: "html",
|
||
value: ""
|
||
};
|
||
}
|
||
function image2() {
|
||
return {
|
||
type: "image",
|
||
title: null,
|
||
url: "",
|
||
alt: null
|
||
};
|
||
}
|
||
function link2() {
|
||
return {
|
||
type: "link",
|
||
title: null,
|
||
url: "",
|
||
children: []
|
||
};
|
||
}
|
||
function list3(token) {
|
||
return {
|
||
type: "list",
|
||
ordered: token.type === "listOrdered",
|
||
start: null,
|
||
spread: token._spread,
|
||
children: []
|
||
};
|
||
}
|
||
function listItem2(token) {
|
||
return {
|
||
type: "listItem",
|
||
spread: token._spread,
|
||
checked: null,
|
||
children: []
|
||
};
|
||
}
|
||
function paragraph2() {
|
||
return {
|
||
type: "paragraph",
|
||
children: []
|
||
};
|
||
}
|
||
function strong2() {
|
||
return {
|
||
type: "strong",
|
||
children: []
|
||
};
|
||
}
|
||
function text4() {
|
||
return {
|
||
type: "text",
|
||
value: ""
|
||
};
|
||
}
|
||
function thematicBreak3() {
|
||
return {
|
||
type: "thematicBreak"
|
||
};
|
||
}
|
||
}
|
||
function point(d) {
|
||
return {
|
||
line: d.line,
|
||
column: d.column,
|
||
offset: d.offset
|
||
};
|
||
}
|
||
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);
|
||
}
|
||
}
|
||
}
|
||
function extension(combined, extension2) {
|
||
let key;
|
||
for (key in extension2) {
|
||
if (own.call(extension2, key)) {
|
||
switch (key) {
|
||
case "canContainEols": {
|
||
const right = extension2[key];
|
||
if (right) {
|
||
combined[key].push(...right);
|
||
}
|
||
break;
|
||
}
|
||
case "transforms": {
|
||
const right = extension2[key];
|
||
if (right) {
|
||
combined[key].push(...right);
|
||
}
|
||
break;
|
||
}
|
||
case "enter":
|
||
case "exit": {
|
||
const right = extension2[key];
|
||
if (right) {
|
||
Object.assign(combined[key], right);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
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");
|
||
}
|
||
}
|
||
|
||
// node_modules/remark-parse/lib/index.js
|
||
function remarkParse(options) {
|
||
const self = this;
|
||
self.parser = 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") || []
|
||
});
|
||
}
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/blockquote.js
|
||
function blockquote(state, node) {
|
||
const result = {
|
||
type: "element",
|
||
tagName: "blockquote",
|
||
properties: {},
|
||
children: state.wrap(state.all(node), true)
|
||
};
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/break.js
|
||
function hardBreak(state, node) {
|
||
const result = { type: "element", tagName: "br", properties: {}, children: [] };
|
||
state.patch(node, result);
|
||
return [state.applyData(node, result), { type: "text", value: "\n" }];
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/code.js
|
||
function code(state, node) {
|
||
const value = node.value ? node.value + "\n" : "";
|
||
const properties = {};
|
||
const language = node.lang ? node.lang.split(/\s+/) : [];
|
||
if (language.length > 0) {
|
||
properties.className = ["language-" + language[0]];
|
||
}
|
||
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);
|
||
result = { type: "element", tagName: "pre", properties: {}, children: [result] };
|
||
state.patch(node, result);
|
||
return result;
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/delete.js
|
||
function strikethrough(state, node) {
|
||
const result = {
|
||
type: "element",
|
||
tagName: "del",
|
||
properties: {},
|
||
children: state.all(node)
|
||
};
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/emphasis.js
|
||
function emphasis(state, node) {
|
||
const result = {
|
||
type: "element",
|
||
tagName: "em",
|
||
properties: {},
|
||
children: state.all(node)
|
||
};
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/footnote-reference.js
|
||
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);
|
||
let counter;
|
||
let reuseCounter = state.footnoteCounts.get(id);
|
||
if (reuseCounter === void 0) {
|
||
reuseCounter = 0;
|
||
state.footnoteOrder.push(id);
|
||
counter = state.footnoteOrder.length;
|
||
} else {
|
||
counter = index + 1;
|
||
}
|
||
reuseCounter += 1;
|
||
state.footnoteCounts.set(id, reuseCounter);
|
||
const link2 = {
|
||
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, link2);
|
||
const sup = {
|
||
type: "element",
|
||
tagName: "sup",
|
||
properties: {},
|
||
children: [link2]
|
||
};
|
||
state.patch(node, sup);
|
||
return state.applyData(node, sup);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/heading.js
|
||
function heading(state, node) {
|
||
const result = {
|
||
type: "element",
|
||
tagName: "h" + node.depth,
|
||
properties: {},
|
||
children: state.all(node)
|
||
};
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/html.js
|
||
function html(state, node) {
|
||
if (state.options.allowDangerousHtml) {
|
||
const result = { type: "raw", value: node.value };
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
return void 0;
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/revert.js
|
||
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;
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/image-reference.js
|
||
function imageReference(state, node) {
|
||
const id = String(node.identifier).toUpperCase();
|
||
const definition2 = state.definitionById.get(id);
|
||
if (!definition2) {
|
||
return revert(state, node);
|
||
}
|
||
const properties = { src: normalizeUri(definition2.url || ""), alt: node.alt };
|
||
if (definition2.title !== null && definition2.title !== void 0) {
|
||
properties.title = definition2.title;
|
||
}
|
||
const result = { type: "element", tagName: "img", properties, children: [] };
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/image.js
|
||
function image(state, node) {
|
||
const properties = { src: normalizeUri(node.url) };
|
||
if (node.alt !== null && node.alt !== void 0) {
|
||
properties.alt = node.alt;
|
||
}
|
||
if (node.title !== null && node.title !== void 0) {
|
||
properties.title = node.title;
|
||
}
|
||
const result = { type: "element", tagName: "img", properties, children: [] };
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/inline-code.js
|
||
function inlineCode(state, node) {
|
||
const text4 = { type: "text", value: node.value.replace(/\r?\n|\r/g, " ") };
|
||
state.patch(node, text4);
|
||
const result = {
|
||
type: "element",
|
||
tagName: "code",
|
||
properties: {},
|
||
children: [text4]
|
||
};
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/link-reference.js
|
||
function linkReference(state, node) {
|
||
const id = String(node.identifier).toUpperCase();
|
||
const definition2 = state.definitionById.get(id);
|
||
if (!definition2) {
|
||
return revert(state, node);
|
||
}
|
||
const properties = { href: normalizeUri(definition2.url || "") };
|
||
if (definition2.title !== null && definition2.title !== void 0) {
|
||
properties.title = definition2.title;
|
||
}
|
||
const result = {
|
||
type: "element",
|
||
tagName: "a",
|
||
properties,
|
||
children: state.all(node)
|
||
};
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/link.js
|
||
function link(state, node) {
|
||
const properties = { href: normalizeUri(node.url) };
|
||
if (node.title !== null && node.title !== void 0) {
|
||
properties.title = node.title;
|
||
}
|
||
const result = {
|
||
type: "element",
|
||
tagName: "a",
|
||
properties,
|
||
children: state.all(node)
|
||
};
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/list-item.js
|
||
function listItem(state, node, parent) {
|
||
const results = state.all(node);
|
||
const loose = parent ? listLoose(parent) : listItemLoose(node);
|
||
const properties = {};
|
||
const children = [];
|
||
if (typeof node.checked === "boolean") {
|
||
const head = results[0];
|
||
let paragraph2;
|
||
if (head && head.type === "element" && head.tagName === "p") {
|
||
paragraph2 = head;
|
||
} else {
|
||
paragraph2 = { type: "element", tagName: "p", properties: {}, children: [] };
|
||
results.unshift(paragraph2);
|
||
}
|
||
if (paragraph2.children.length > 0) {
|
||
paragraph2.children.unshift({ type: "text", value: " " });
|
||
}
|
||
paragraph2.children.unshift({
|
||
type: "element",
|
||
tagName: "input",
|
||
properties: { type: "checkbox", checked: node.checked, disabled: true },
|
||
children: []
|
||
});
|
||
properties.className = ["task-list-item"];
|
||
}
|
||
let index = -1;
|
||
while (++index < results.length) {
|
||
const child = results[index];
|
||
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];
|
||
if (tail && (loose || tail.type !== "element" || tail.tagName !== "p")) {
|
||
children.push({ type: "text", value: "\n" });
|
||
}
|
||
const result = { type: "element", tagName: "li", properties, children };
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
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;
|
||
}
|
||
function listItemLoose(node) {
|
||
const spread = node.spread;
|
||
return spread === null || spread === void 0 ? node.children.length > 1 : spread;
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/list.js
|
||
function list2(state, node) {
|
||
const properties = {};
|
||
const results = state.all(node);
|
||
let index = -1;
|
||
if (typeof node.start === "number" && node.start !== 1) {
|
||
properties.start = node.start;
|
||
}
|
||
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;
|
||
}
|
||
}
|
||
const result = {
|
||
type: "element",
|
||
tagName: node.ordered ? "ol" : "ul",
|
||
properties,
|
||
children: state.wrap(results, true)
|
||
};
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/paragraph.js
|
||
function paragraph(state, node) {
|
||
const result = {
|
||
type: "element",
|
||
tagName: "p",
|
||
properties: {},
|
||
children: state.all(node)
|
||
};
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/root.js
|
||
function root(state, node) {
|
||
const result = { type: "root", children: state.wrap(state.all(node)) };
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/strong.js
|
||
function strong(state, node) {
|
||
const result = {
|
||
type: "element",
|
||
tagName: "strong",
|
||
properties: {},
|
||
children: state.all(node)
|
||
};
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/table.js
|
||
function table(state, node) {
|
||
const rows = state.all(node);
|
||
const firstRow = rows.shift();
|
||
const tableContent = [];
|
||
if (firstRow) {
|
||
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) {
|
||
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);
|
||
}
|
||
const result = {
|
||
type: "element",
|
||
tagName: "table",
|
||
properties: {},
|
||
children: state.wrap(tableContent, true)
|
||
};
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/table-row.js
|
||
function tableRow(state, node, parent) {
|
||
const siblings = parent ? parent.children : void 0;
|
||
const rowIndex = siblings ? siblings.indexOf(node) : 1;
|
||
const tagName = rowIndex === 0 ? "th" : "td";
|
||
const align = parent && parent.type === "table" ? parent.align : void 0;
|
||
const length = align ? align.length : node.children.length;
|
||
let cellIndex = -1;
|
||
const cells = [];
|
||
while (++cellIndex < length) {
|
||
const cell = node.children[cellIndex];
|
||
const properties = {};
|
||
const alignValue = align ? align[cellIndex] : void 0;
|
||
if (alignValue) {
|
||
properties.align = alignValue;
|
||
}
|
||
let result2 = { type: "element", tagName, properties, children: [] };
|
||
if (cell) {
|
||
result2.children = state.all(cell);
|
||
state.patch(cell, result2);
|
||
result2 = state.applyData(cell, result2);
|
||
}
|
||
cells.push(result2);
|
||
}
|
||
const result = {
|
||
type: "element",
|
||
tagName: "tr",
|
||
properties: {},
|
||
children: state.wrap(cells, true)
|
||
};
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/table-cell.js
|
||
function tableCell(state, node) {
|
||
const result = {
|
||
type: "element",
|
||
tagName: "td",
|
||
// Assume body cell.
|
||
properties: {},
|
||
children: state.all(node)
|
||
};
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/trim-lines/index.js
|
||
var tab = 9;
|
||
var space = 32;
|
||
function trimLines(value) {
|
||
const source = String(value);
|
||
const search2 = /\r?\n|\r/g;
|
||
let match = search2.exec(source);
|
||
let last = 0;
|
||
const lines = [];
|
||
while (match) {
|
||
lines.push(
|
||
trimLine(source.slice(last, match.index), last > 0, true),
|
||
match[0]
|
||
);
|
||
last = match.index + match[0].length;
|
||
match = search2.exec(source);
|
||
}
|
||
lines.push(trimLine(source.slice(last), last > 0, false));
|
||
return lines.join("");
|
||
}
|
||
function trimLine(value, start, end) {
|
||
let startIndex = 0;
|
||
let endIndex = value.length;
|
||
if (start) {
|
||
let code2 = value.codePointAt(startIndex);
|
||
while (code2 === tab || code2 === space) {
|
||
startIndex++;
|
||
code2 = value.codePointAt(startIndex);
|
||
}
|
||
}
|
||
if (end) {
|
||
let code2 = value.codePointAt(endIndex - 1);
|
||
while (code2 === tab || code2 === space) {
|
||
endIndex--;
|
||
code2 = value.codePointAt(endIndex - 1);
|
||
}
|
||
}
|
||
return endIndex > startIndex ? value.slice(startIndex, endIndex) : "";
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/text.js
|
||
function text3(state, node) {
|
||
const result = { type: "text", value: trimLines(String(node.value)) };
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js
|
||
function thematicBreak2(state, node) {
|
||
const result = {
|
||
type: "element",
|
||
tagName: "hr",
|
||
properties: {},
|
||
children: []
|
||
};
|
||
state.patch(node, result);
|
||
return state.applyData(node, result);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/handlers/index.js
|
||
var handlers = {
|
||
blockquote,
|
||
break: hardBreak,
|
||
code,
|
||
delete: strikethrough,
|
||
emphasis,
|
||
footnoteReference,
|
||
heading,
|
||
html,
|
||
imageReference,
|
||
image,
|
||
inlineCode,
|
||
linkReference,
|
||
link,
|
||
listItem,
|
||
list: list2,
|
||
paragraph,
|
||
// @ts-expect-error: root is different, but hard to type.
|
||
root,
|
||
strong,
|
||
table,
|
||
tableCell,
|
||
tableRow,
|
||
text: text3,
|
||
thematicBreak: thematicBreak2,
|
||
toml: ignore,
|
||
yaml: ignore,
|
||
definition: ignore,
|
||
footnoteDefinition: ignore
|
||
};
|
||
function ignore() {
|
||
return void 0;
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/footer.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;
|
||
}
|
||
function defaultFootnoteBackLabel(referenceIndex, rereferenceIndex) {
|
||
return "Back to reference " + (referenceIndex + 1) + (rereferenceIndex > 1 ? "-" + rereferenceIndex : "");
|
||
}
|
||
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"]
|
||
};
|
||
const listItems = [];
|
||
let referenceIndex = -1;
|
||
while (++referenceIndex < state.footnoteOrder.length) {
|
||
const definition2 = state.footnoteById.get(
|
||
state.footnoteOrder[referenceIndex]
|
||
);
|
||
if (!definition2) {
|
||
continue;
|
||
}
|
||
const content3 = state.all(definition2);
|
||
const id = String(definition2.identifier).toUpperCase();
|
||
const safeId = normalizeUri(id.toLowerCase());
|
||
let rereferenceIndex = 0;
|
||
const backReferences = [];
|
||
const counts = state.footnoteCounts.get(id);
|
||
while (counts !== void 0 && ++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 = content3[content3.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 {
|
||
content3.push(...backReferences);
|
||
}
|
||
const listItem2 = {
|
||
type: "element",
|
||
tagName: "li",
|
||
properties: { id: clobberPrefix + "fn-" + safeId },
|
||
children: state.wrap(content3, true)
|
||
};
|
||
state.patch(definition2, listItem2);
|
||
listItems.push(listItem2);
|
||
}
|
||
if (listItems.length === 0) {
|
||
return;
|
||
}
|
||
return {
|
||
type: "element",
|
||
tagName: "section",
|
||
properties: { dataFootnotes: true, className: ["footnotes"] },
|
||
children: [
|
||
{
|
||
type: "element",
|
||
tagName: footnoteLabelTagName,
|
||
properties: {
|
||
...esm_default(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" }
|
||
]
|
||
};
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/state.js
|
||
var own2 = {}.hasOwnProperty;
|
||
var emptyOptions = {};
|
||
function createState(tree, options) {
|
||
const settings = options || emptyOptions;
|
||
const definitionById = /* @__PURE__ */ new Map();
|
||
const footnoteById = /* @__PURE__ */ new Map();
|
||
const footnoteCounts = /* @__PURE__ */ new Map();
|
||
const handlers2 = { ...handlers, ...settings.handlers };
|
||
const state = {
|
||
all,
|
||
applyData,
|
||
definitionById,
|
||
footnoteById,
|
||
footnoteCounts,
|
||
footnoteOrder: [],
|
||
handlers: handlers2,
|
||
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();
|
||
if (!map.has(id)) {
|
||
map.set(id, node);
|
||
}
|
||
}
|
||
});
|
||
return state;
|
||
function one(node, parent) {
|
||
const type = node.type;
|
||
const handle = state.handlers[type];
|
||
if (own2.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 = esm_default(shallow);
|
||
result.children = state.all(node);
|
||
return result;
|
||
}
|
||
return esm_default(node);
|
||
}
|
||
const unknown = state.options.unknownHandler || defaultUnknownHandler;
|
||
return unknown(state, node, parent);
|
||
}
|
||
function all(parent) {
|
||
const values = [];
|
||
if ("children" in parent) {
|
||
const nodes = parent.children;
|
||
let index = -1;
|
||
while (++index < nodes.length) {
|
||
const result = state.one(nodes[index], parent);
|
||
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;
|
||
}
|
||
}
|
||
function patch(from, to) {
|
||
if (from.position) to.position = position(from);
|
||
}
|
||
function applyData(from, to) {
|
||
let result = to;
|
||
if (from && from.data) {
|
||
const hName = from.data.hName;
|
||
const hChildren = from.data.hChildren;
|
||
const hProperties = from.data.hProperties;
|
||
if (typeof hName === "string") {
|
||
if (result.type === "element") {
|
||
result.tagName = hName;
|
||
} else {
|
||
const children = "children" in result ? result.children : [result];
|
||
result = { type: "element", tagName: hName, properties: {}, children };
|
||
}
|
||
}
|
||
if (result.type === "element" && hProperties) {
|
||
Object.assign(result.properties, esm_default(hProperties));
|
||
}
|
||
if ("children" in result && result.children && hChildren !== null && hChildren !== void 0) {
|
||
result.children = hChildren;
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
function defaultUnknownHandler(state, node) {
|
||
const data = node.data || {};
|
||
const result = "value" in node && !(own2.call(data, "hProperties") || own2.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);
|
||
}
|
||
function wrap(nodes, loose) {
|
||
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;
|
||
}
|
||
function trimMarkdownSpaceStart(value) {
|
||
let index = 0;
|
||
let code2 = value.charCodeAt(index);
|
||
while (code2 === 9 || code2 === 32) {
|
||
index++;
|
||
code2 = value.charCodeAt(index);
|
||
}
|
||
return value.slice(index);
|
||
}
|
||
|
||
// node_modules/mdast-util-to-hast/lib/index.js
|
||
function toHast(tree, options) {
|
||
const state = createState(tree, options);
|
||
const node = state.one(tree, void 0);
|
||
const foot = footer(state);
|
||
const result = Array.isArray(node) ? { type: "root", children: node } : node || { type: "root", children: [] };
|
||
if (foot) {
|
||
ok("children" in result);
|
||
result.children.push({ type: "text", value: "\n" }, foot);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
// node_modules/remark-rehype/lib/index.js
|
||
function remarkRehype(destination, options) {
|
||
if (destination && "run" in destination) {
|
||
return async function(tree, file) {
|
||
const hastTree = (
|
||
/** @type {HastRoot} */
|
||
toHast(tree, { file, ...options })
|
||
);
|
||
await destination.run(hastTree, file);
|
||
};
|
||
}
|
||
return function(tree, file) {
|
||
return (
|
||
/** @type {HastRoot} */
|
||
toHast(tree, { file, ...destination || options })
|
||
);
|
||
};
|
||
}
|
||
|
||
// node_modules/bail/index.js
|
||
function bail(error) {
|
||
if (error) {
|
||
throw error;
|
||
}
|
||
}
|
||
|
||
// node_modules/unified/lib/index.js
|
||
var import_extend = __toESM(require_extend(), 1);
|
||
|
||
// node_modules/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);
|
||
}
|
||
|
||
// node_modules/trough/lib/index.js
|
||
function trough() {
|
||
const fns = [];
|
||
const pipeline = { run, use };
|
||
return pipeline;
|
||
function run(...values) {
|
||
let middlewareIndex = -1;
|
||
const callback = values.pop();
|
||
if (typeof callback !== "function") {
|
||
throw new TypeError("Expected function as last argument, not " + callback);
|
||
}
|
||
next(null, ...values);
|
||
function next(error, ...output) {
|
||
const fn = fns[++middlewareIndex];
|
||
let index = -1;
|
||
if (error) {
|
||
callback(error);
|
||
return;
|
||
}
|
||
while (++index < values.length) {
|
||
if (output[index] === null || output[index] === void 0) {
|
||
output[index] = values[index];
|
||
}
|
||
}
|
||
values = output;
|
||
if (fn) {
|
||
wrap2(fn, next)(...output);
|
||
} else {
|
||
callback(null, ...output);
|
||
}
|
||
}
|
||
}
|
||
function use(middelware) {
|
||
if (typeof middelware !== "function") {
|
||
throw new TypeError(
|
||
"Expected `middelware` to be a function, not " + middelware
|
||
);
|
||
}
|
||
fns.push(middelware);
|
||
return pipeline;
|
||
}
|
||
}
|
||
function wrap2(middleware, callback) {
|
||
let called;
|
||
return wrapped;
|
||
function wrapped(...parameters) {
|
||
const fnExpectsCallback = middleware.length > parameters.length;
|
||
let result;
|
||
if (fnExpectsCallback) {
|
||
parameters.push(done);
|
||
}
|
||
try {
|
||
result = middleware.apply(this, parameters);
|
||
} catch (error) {
|
||
const exception = (
|
||
/** @type {Error} */
|
||
error
|
||
);
|
||
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);
|
||
}
|
||
}
|
||
}
|
||
function done(error, ...output) {
|
||
if (!called) {
|
||
called = true;
|
||
callback(error, ...output);
|
||
}
|
||
}
|
||
function then(value) {
|
||
done(null, value);
|
||
}
|
||
}
|
||
|
||
// node_modules/vfile/lib/minpath.browser.js
|
||
var minpath = { basename, dirname, extname, join, sep: "/" };
|
||
function basename(path, extname2) {
|
||
if (extname2 !== void 0 && typeof extname2 !== "string") {
|
||
throw new TypeError('"ext" argument must be a string');
|
||
}
|
||
assertPath(path);
|
||
let start = 0;
|
||
let end = -1;
|
||
let index = path.length;
|
||
let seenNonSlash;
|
||
if (extname2 === void 0 || extname2.length === 0 || extname2.length > path.length) {
|
||
while (index--) {
|
||
if (path.codePointAt(index) === 47) {
|
||
if (seenNonSlash) {
|
||
start = index + 1;
|
||
break;
|
||
}
|
||
} else if (end < 0) {
|
||
seenNonSlash = true;
|
||
end = index + 1;
|
||
}
|
||
}
|
||
return end < 0 ? "" : path.slice(start, end);
|
||
}
|
||
if (extname2 === path) {
|
||
return "";
|
||
}
|
||
let firstNonSlashEnd = -1;
|
||
let extnameIndex = extname2.length - 1;
|
||
while (index--) {
|
||
if (path.codePointAt(index) === 47) {
|
||
if (seenNonSlash) {
|
||
start = index + 1;
|
||
break;
|
||
}
|
||
} else {
|
||
if (firstNonSlashEnd < 0) {
|
||
seenNonSlash = true;
|
||
firstNonSlashEnd = index + 1;
|
||
}
|
||
if (extnameIndex > -1) {
|
||
if (path.codePointAt(index) === extname2.codePointAt(extnameIndex--)) {
|
||
if (extnameIndex < 0) {
|
||
end = index;
|
||
}
|
||
} else {
|
||
extnameIndex = -1;
|
||
end = firstNonSlashEnd;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (start === end) {
|
||
end = firstNonSlashEnd;
|
||
} else if (end < 0) {
|
||
end = path.length;
|
||
}
|
||
return path.slice(start, end);
|
||
}
|
||
function dirname(path) {
|
||
assertPath(path);
|
||
if (path.length === 0) {
|
||
return ".";
|
||
}
|
||
let end = -1;
|
||
let index = path.length;
|
||
let unmatchedSlash;
|
||
while (--index) {
|
||
if (path.codePointAt(index) === 47) {
|
||
if (unmatchedSlash) {
|
||
end = index;
|
||
break;
|
||
}
|
||
} else if (!unmatchedSlash) {
|
||
unmatchedSlash = true;
|
||
}
|
||
}
|
||
return end < 0 ? path.codePointAt(0) === 47 ? "/" : "." : end === 1 && path.codePointAt(0) === 47 ? "//" : path.slice(0, end);
|
||
}
|
||
function extname(path) {
|
||
assertPath(path);
|
||
let index = path.length;
|
||
let end = -1;
|
||
let startPart = 0;
|
||
let startDot = -1;
|
||
let preDotState = 0;
|
||
let unmatchedSlash;
|
||
while (index--) {
|
||
const code2 = path.codePointAt(index);
|
||
if (code2 === 47) {
|
||
if (unmatchedSlash) {
|
||
startPart = index + 1;
|
||
break;
|
||
}
|
||
continue;
|
||
}
|
||
if (end < 0) {
|
||
unmatchedSlash = true;
|
||
end = index + 1;
|
||
}
|
||
if (code2 === 46) {
|
||
if (startDot < 0) {
|
||
startDot = index;
|
||
} else if (preDotState !== 1) {
|
||
preDotState = 1;
|
||
}
|
||
} else if (startDot > -1) {
|
||
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);
|
||
}
|
||
function join(...segments) {
|
||
let index = -1;
|
||
let joined;
|
||
while (++index < segments.length) {
|
||
assertPath(segments[index]);
|
||
if (segments[index]) {
|
||
joined = joined === void 0 ? segments[index] : joined + "/" + segments[index];
|
||
}
|
||
}
|
||
return joined === void 0 ? "." : normalize(joined);
|
||
}
|
||
function normalize(path) {
|
||
assertPath(path);
|
||
const absolute = path.codePointAt(0) === 47;
|
||
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;
|
||
}
|
||
function normalizeString(path, allowAboveRoot) {
|
||
let result = "";
|
||
let lastSegmentLength = 0;
|
||
let lastSlash = -1;
|
||
let dots = 0;
|
||
let index = -1;
|
||
let code2;
|
||
let lastSlashIndex;
|
||
while (++index <= path.length) {
|
||
if (index < path.length) {
|
||
code2 = path.codePointAt(index);
|
||
} else if (code2 === 47) {
|
||
break;
|
||
} else {
|
||
code2 = 47;
|
||
}
|
||
if (code2 === 47) {
|
||
if (lastSlash === index - 1 || dots === 1) {
|
||
} 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 (code2 === 46 && dots > -1) {
|
||
dots++;
|
||
} else {
|
||
dots = -1;
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
function assertPath(path) {
|
||
if (typeof path !== "string") {
|
||
throw new TypeError(
|
||
"Path must be a string. Received " + JSON.stringify(path)
|
||
);
|
||
}
|
||
}
|
||
|
||
// node_modules/vfile/lib/minproc.browser.js
|
||
var minproc = { cwd };
|
||
function cwd() {
|
||
return "/";
|
||
}
|
||
|
||
// node_modules/vfile/lib/minurl.shared.js
|
||
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 === void 0
|
||
);
|
||
}
|
||
|
||
// node_modules/vfile/lib/minurl.browser.js
|
||
function urlToPath(path) {
|
||
if (typeof path === "string") {
|
||
path = new URL(path);
|
||
} else if (!isUrl(path)) {
|
||
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:") {
|
||
const error = new TypeError("The URL must be of scheme file");
|
||
error.code = "ERR_INVALID_URL_SCHEME";
|
||
throw error;
|
||
}
|
||
return getPathFromURLPosix(path);
|
||
}
|
||
function getPathFromURLPosix(url) {
|
||
if (url.hostname !== "") {
|
||
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) {
|
||
const third = pathname.codePointAt(index + 2);
|
||
if (third === 70 || third === 102) {
|
||
const error = new TypeError(
|
||
"File URL path must not include encoded / characters"
|
||
);
|
||
error.code = "ERR_INVALID_FILE_URL_PATH";
|
||
throw error;
|
||
}
|
||
}
|
||
}
|
||
return decodeURIComponent(pathname);
|
||
}
|
||
|
||
// node_modules/vfile/lib/index.js
|
||
var order = (
|
||
/** @type {const} */
|
||
[
|
||
"history",
|
||
"path",
|
||
"basename",
|
||
"stem",
|
||
"extname",
|
||
"dirname"
|
||
]
|
||
);
|
||
var VFile = class {
|
||
/**
|
||
* 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) {
|
||
let options;
|
||
if (!value) {
|
||
options = {};
|
||
} else if (isUrl(value)) {
|
||
options = { path: value };
|
||
} else if (typeof value === "string" || isUint8Array(value)) {
|
||
options = { value };
|
||
} else {
|
||
options = value;
|
||
}
|
||
this.cwd = "cwd" in options ? "" : minproc.cwd();
|
||
this.data = {};
|
||
this.history = [];
|
||
this.messages = [];
|
||
this.value;
|
||
this.map;
|
||
this.result;
|
||
this.stored;
|
||
let index = -1;
|
||
while (++index < order.length) {
|
||
const field2 = order[index];
|
||
if (field2 in options && options[field2] !== void 0 && options[field2] !== null) {
|
||
this[field2] = field2 === "history" ? [...options[field2]] : options[field2];
|
||
}
|
||
}
|
||
let field;
|
||
for (field in options) {
|
||
if (!order.includes(field)) {
|
||
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) : void 0;
|
||
}
|
||
/**
|
||
* 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(basename2) {
|
||
assertNonEmpty(basename2, "basename");
|
||
assertPart(basename2, "basename");
|
||
this.path = minpath.join(this.dirname || "", basename2);
|
||
}
|
||
/**
|
||
* Get the parent path (example: `'~'`).
|
||
*
|
||
* @returns {string | undefined}
|
||
* Dirname.
|
||
*/
|
||
get dirname() {
|
||
return typeof this.path === "string" ? minpath.dirname(this.path) : void 0;
|
||
}
|
||
/**
|
||
* Set the parent path (example: `'~'`).
|
||
*
|
||
* Cannot be set if there’s no `path` yet.
|
||
*
|
||
* @param {string | undefined} dirname
|
||
* Dirname.
|
||
* @returns {undefined}
|
||
* Nothing.
|
||
*/
|
||
set dirname(dirname2) {
|
||
assertPath2(this.basename, "dirname");
|
||
this.path = minpath.join(dirname2 || "", this.basename);
|
||
}
|
||
/**
|
||
* Get the extname (including dot) (example: `'.js'`).
|
||
*
|
||
* @returns {string | undefined}
|
||
* Extname.
|
||
*/
|
||
get extname() {
|
||
return typeof this.path === "string" ? minpath.extname(this.path) : void 0;
|
||
}
|
||
/**
|
||
* 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(extname2) {
|
||
assertPart(extname2, "extname");
|
||
assertPath2(this.dirname, "extname");
|
||
if (extname2) {
|
||
if (extname2.codePointAt(0) !== 46) {
|
||
throw new Error("`extname` must start with `.`");
|
||
}
|
||
if (extname2.includes(".", 1)) {
|
||
throw new Error("`extname` cannot contain multiple dots");
|
||
}
|
||
}
|
||
this.path = minpath.join(this.dirname, this.stem + (extname2 || ""));
|
||
}
|
||
/**
|
||
* 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) : void 0;
|
||
}
|
||
/**
|
||
* 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) {
|
||
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) {
|
||
const message = this.message(causeOrReason, optionsOrParentOrPlace, origin);
|
||
message.fatal = void 0;
|
||
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:
|
||
* > <https://nodejs.org/api/util.html#whatwg-supported-encodings>.
|
||
*
|
||
* @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 === void 0) {
|
||
return "";
|
||
}
|
||
if (typeof this.value === "string") {
|
||
return this.value;
|
||
}
|
||
const decoder = new TextDecoder(encoding || void 0);
|
||
return decoder.decode(this.value);
|
||
}
|
||
};
|
||
function assertPart(part, name) {
|
||
if (part && part.includes(minpath.sep)) {
|
||
throw new Error(
|
||
"`" + name + "` cannot be a path: did not expect `" + minpath.sep + "`"
|
||
);
|
||
}
|
||
}
|
||
function assertNonEmpty(part, name) {
|
||
if (!part) {
|
||
throw new Error("`" + name + "` cannot be empty");
|
||
}
|
||
}
|
||
function assertPath2(path, name) {
|
||
if (!path) {
|
||
throw new Error("Setting `" + name + "` requires `path` to be set too");
|
||
}
|
||
}
|
||
function isUint8Array(value) {
|
||
return Boolean(
|
||
value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
|
||
);
|
||
}
|
||
|
||
// node_modules/unified/lib/callable-instance.js
|
||
var CallableInstance = (
|
||
/**
|
||
* @type {new <Parameters extends Array<unknown>, Result>(property: string | symbol) => (...parameters: Parameters) => Result}
|
||
*/
|
||
/** @type {unknown} */
|
||
/**
|
||
* @this {Function}
|
||
* @param {string | symbol} property
|
||
* @returns {(...parameters: Array<unknown>) => unknown}
|
||
*/
|
||
(function(property) {
|
||
const self = this;
|
||
const constr = self.constructor;
|
||
const proto = (
|
||
/** @type {Record<string | symbol, Function>} */
|
||
// Prototypes do exist.
|
||
// type-coverage:ignore-next-line
|
||
constr.prototype
|
||
);
|
||
const value = proto[property];
|
||
const apply = function() {
|
||
return value.apply(apply, arguments);
|
||
};
|
||
Object.setPrototypeOf(apply, proto);
|
||
return apply;
|
||
})
|
||
);
|
||
|
||
// node_modules/unified/lib/index.js
|
||
var own3 = {}.hasOwnProperty;
|
||
var Processor = class _Processor extends CallableInstance {
|
||
/**
|
||
* Create a processor.
|
||
*/
|
||
constructor() {
|
||
super("copy");
|
||
this.Compiler = void 0;
|
||
this.Parser = void 0;
|
||
this.attachers = [];
|
||
this.compiler = void 0;
|
||
this.freezeIndex = -1;
|
||
this.frozen = void 0;
|
||
this.namespace = {};
|
||
this.parser = void 0;
|
||
this.transformers = trough();
|
||
}
|
||
/**
|
||
* Copy a processor.
|
||
*
|
||
* @deprecated
|
||
* This is a private internal method and should not be used.
|
||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
||
* New *unfrozen* processor ({@linkcode Processor}) that is
|
||
* configured to work the same as its ancestor.
|
||
* When the descendant processor is configured in the future it does not
|
||
* affect the ancestral processor.
|
||
*/
|
||
copy() {
|
||
const destination = (
|
||
/** @type {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} */
|
||
new _Processor()
|
||
);
|
||
let index = -1;
|
||
while (++index < this.attachers.length) {
|
||
const attacher = this.attachers[index];
|
||
destination.use(...attacher);
|
||
}
|
||
destination.data((0, import_extend.default)(true, {}, this.namespace));
|
||
return destination;
|
||
}
|
||
/**
|
||
* Configure the processor with info available to all plugins.
|
||
* Information is stored in an object.
|
||
*
|
||
* Typically, options can be given to a specific plugin, but sometimes it
|
||
* makes sense to have information shared with several plugins.
|
||
* For example, a list of HTML elements that are self-closing, which is
|
||
* needed during all phases.
|
||
*
|
||
* > **Note**: setting information cannot occur on *frozen* processors.
|
||
* > Call the processor first to create a new unfrozen processor.
|
||
*
|
||
* > **Note**: to register custom data in TypeScript, augment the
|
||
* > {@linkcode Data} interface.
|
||
*
|
||
* @example
|
||
* This example show how to get and set info:
|
||
*
|
||
* ```js
|
||
* import {unified} from 'unified'
|
||
*
|
||
* const processor = unified().data('alpha', 'bravo')
|
||
*
|
||
* processor.data('alpha') // => 'bravo'
|
||
*
|
||
* processor.data() // => {alpha: 'bravo'}
|
||
*
|
||
* processor.data({charlie: 'delta'})
|
||
*
|
||
* processor.data() // => {charlie: 'delta'}
|
||
* ```
|
||
*
|
||
* @template {keyof Data} Key
|
||
*
|
||
* @overload
|
||
* @returns {Data}
|
||
*
|
||
* @overload
|
||
* @param {Data} dataset
|
||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
||
*
|
||
* @overload
|
||
* @param {Key} key
|
||
* @returns {Data[Key]}
|
||
*
|
||
* @overload
|
||
* @param {Key} key
|
||
* @param {Data[Key]} value
|
||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
||
*
|
||
* @param {Data | Key} [key]
|
||
* Key to get or set, or entire dataset to set, or nothing to get the
|
||
* entire dataset (optional).
|
||
* @param {Data[Key]} [value]
|
||
* Value to set (optional).
|
||
* @returns {unknown}
|
||
* The current processor when setting, the value at `key` when getting, or
|
||
* the entire dataset when getting without key.
|
||
*/
|
||
data(key, value) {
|
||
if (typeof key === "string") {
|
||
if (arguments.length === 2) {
|
||
assertUnfrozen("data", this.frozen);
|
||
this.namespace[key] = value;
|
||
return this;
|
||
}
|
||
return own3.call(this.namespace, key) && this.namespace[key] || void 0;
|
||
}
|
||
if (key) {
|
||
assertUnfrozen("data", this.frozen);
|
||
this.namespace = key;
|
||
return this;
|
||
}
|
||
return this.namespace;
|
||
}
|
||
/**
|
||
* Freeze a processor.
|
||
*
|
||
* Frozen processors are meant to be extended and not to be configured
|
||
* directly.
|
||
*
|
||
* When a processor is frozen it cannot be unfrozen.
|
||
* New processors working the same way can be created by calling the
|
||
* processor.
|
||
*
|
||
* It’s possible to freeze processors explicitly by calling `.freeze()`.
|
||
* Processors freeze automatically when `.parse()`, `.run()`, `.runSync()`,
|
||
* `.stringify()`, `.process()`, or `.processSync()` are called.
|
||
*
|
||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
||
* The current processor.
|
||
*/
|
||
freeze() {
|
||
if (this.frozen) {
|
||
return this;
|
||
}
|
||
const self = (
|
||
/** @type {Processor} */
|
||
/** @type {unknown} */
|
||
this
|
||
);
|
||
while (++this.freezeIndex < this.attachers.length) {
|
||
const [attacher, ...options] = this.attachers[this.freezeIndex];
|
||
if (options[0] === false) {
|
||
continue;
|
||
}
|
||
if (options[0] === true) {
|
||
options[0] = void 0;
|
||
}
|
||
const transformer = attacher.call(self, ...options);
|
||
if (typeof transformer === "function") {
|
||
this.transformers.use(transformer);
|
||
}
|
||
}
|
||
this.frozen = true;
|
||
this.freezeIndex = Number.POSITIVE_INFINITY;
|
||
return this;
|
||
}
|
||
/**
|
||
* Parse text to a syntax tree.
|
||
*
|
||
* > **Note**: `parse` freezes the processor if not already *frozen*.
|
||
*
|
||
* > **Note**: `parse` performs the parse phase, not the run phase or other
|
||
* > phases.
|
||
*
|
||
* @param {Compatible | undefined} [file]
|
||
* file to parse (optional); typically `string` or `VFile`; any value
|
||
* accepted as `x` in `new VFile(x)`.
|
||
* @returns {ParseTree extends undefined ? Node : ParseTree}
|
||
* Syntax tree representing `file`.
|
||
*/
|
||
parse(file) {
|
||
this.freeze();
|
||
const realFile = vfile(file);
|
||
const parser = this.parser || this.Parser;
|
||
assertParser("parse", parser);
|
||
return parser(String(realFile), realFile);
|
||
}
|
||
/**
|
||
* Process the given file as configured on the processor.
|
||
*
|
||
* > **Note**: `process` freezes the processor if not already *frozen*.
|
||
*
|
||
* > **Note**: `process` performs the parse, run, and stringify phases.
|
||
*
|
||
* @overload
|
||
* @param {Compatible | undefined} file
|
||
* @param {ProcessCallback<VFileWithOutput<CompileResult>>} done
|
||
* @returns {undefined}
|
||
*
|
||
* @overload
|
||
* @param {Compatible | undefined} [file]
|
||
* @returns {Promise<VFileWithOutput<CompileResult>>}
|
||
*
|
||
* @param {Compatible | undefined} [file]
|
||
* File (optional); typically `string` or `VFile`]; any value accepted as
|
||
* `x` in `new VFile(x)`.
|
||
* @param {ProcessCallback<VFileWithOutput<CompileResult>> | undefined} [done]
|
||
* Callback (optional).
|
||
* @returns {Promise<VFile> | undefined}
|
||
* Nothing if `done` is given.
|
||
* Otherwise a promise, rejected with a fatal error or resolved with the
|
||
* processed file.
|
||
*
|
||
* The parsed, transformed, and compiled value is available at
|
||
* `file.value` (see note).
|
||
*
|
||
* > **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
|
||
*/
|
||
process(file, done) {
|
||
const self = this;
|
||
this.freeze();
|
||
assertParser("process", this.parser || this.Parser);
|
||
assertCompiler("process", this.compiler || this.Compiler);
|
||
return done ? executor(void 0, done) : new Promise(executor);
|
||
function executor(resolve, reject) {
|
||
const realFile = vfile(file);
|
||
const parseTree = (
|
||
/** @type {HeadTree extends undefined ? Node : HeadTree} */
|
||
/** @type {unknown} */
|
||
self.parse(realFile)
|
||
);
|
||
self.run(parseTree, realFile, function(error, tree, file2) {
|
||
if (error || !tree || !file2) {
|
||
return realDone(error);
|
||
}
|
||
const compileTree = (
|
||
/** @type {CompileTree extends undefined ? Node : CompileTree} */
|
||
/** @type {unknown} */
|
||
tree
|
||
);
|
||
const compileResult = self.stringify(compileTree, file2);
|
||
if (looksLikeAValue(compileResult)) {
|
||
file2.value = compileResult;
|
||
} else {
|
||
file2.result = compileResult;
|
||
}
|
||
realDone(
|
||
error,
|
||
/** @type {VFileWithOutput<CompileResult>} */
|
||
file2
|
||
);
|
||
});
|
||
function realDone(error, file2) {
|
||
if (error || !file2) {
|
||
reject(error);
|
||
} else if (resolve) {
|
||
resolve(file2);
|
||
} else {
|
||
ok(done, "`done` is defined if `resolve` is not");
|
||
done(void 0, file2);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Process the given file as configured on the processor.
|
||
*
|
||
* An error is thrown if asynchronous transforms are configured.
|
||
*
|
||
* > **Note**: `processSync` freezes the processor if not already *frozen*.
|
||
*
|
||
* > **Note**: `processSync` performs the parse, run, and stringify phases.
|
||
*
|
||
* @param {Compatible | undefined} [file]
|
||
* File (optional); typically `string` or `VFile`; any value accepted as
|
||
* `x` in `new VFile(x)`.
|
||
* @returns {VFileWithOutput<CompileResult>}
|
||
* The processed file.
|
||
*
|
||
* The parsed, transformed, and compiled value is available at
|
||
* `file.value` (see note).
|
||
*
|
||
* > **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
|
||
*/
|
||
processSync(file) {
|
||
let complete = false;
|
||
let result;
|
||
this.freeze();
|
||
assertParser("processSync", this.parser || this.Parser);
|
||
assertCompiler("processSync", this.compiler || this.Compiler);
|
||
this.process(file, realDone);
|
||
assertDone("processSync", "process", complete);
|
||
ok(result, "we either bailed on an error or have a tree");
|
||
return result;
|
||
function realDone(error, file2) {
|
||
complete = true;
|
||
bail(error);
|
||
result = file2;
|
||
}
|
||
}
|
||
/**
|
||
* Run *transformers* on a syntax tree.
|
||
*
|
||
* > **Note**: `run` freezes the processor if not already *frozen*.
|
||
*
|
||
* > **Note**: `run` performs the run phase, not other phases.
|
||
*
|
||
* @overload
|
||
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
||
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
||
* @returns {undefined}
|
||
*
|
||
* @overload
|
||
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
||
* @param {Compatible | undefined} file
|
||
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
||
* @returns {undefined}
|
||
*
|
||
* @overload
|
||
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
||
* @param {Compatible | undefined} [file]
|
||
* @returns {Promise<TailTree extends undefined ? Node : TailTree>}
|
||
*
|
||
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
||
* Tree to transform and inspect.
|
||
* @param {(
|
||
* RunCallback<TailTree extends undefined ? Node : TailTree> |
|
||
* Compatible
|
||
* )} [file]
|
||
* File associated with `node` (optional); any value accepted as `x` in
|
||
* `new VFile(x)`.
|
||
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} [done]
|
||
* Callback (optional).
|
||
* @returns {Promise<TailTree extends undefined ? Node : TailTree> | undefined}
|
||
* Nothing if `done` is given.
|
||
* Otherwise, a promise rejected with a fatal error or resolved with the
|
||
* transformed tree.
|
||
*/
|
||
run(tree, file, done) {
|
||
assertNode(tree);
|
||
this.freeze();
|
||
const transformers = this.transformers;
|
||
if (!done && typeof file === "function") {
|
||
done = file;
|
||
file = void 0;
|
||
}
|
||
return done ? executor(void 0, done) : new Promise(executor);
|
||
function executor(resolve, reject) {
|
||
ok(
|
||
typeof file !== "function",
|
||
"`file` can’t be a `done` anymore, we checked"
|
||
);
|
||
const realFile = vfile(file);
|
||
transformers.run(tree, realFile, realDone);
|
||
function realDone(error, outputTree, file2) {
|
||
const resultingTree = (
|
||
/** @type {TailTree extends undefined ? Node : TailTree} */
|
||
outputTree || tree
|
||
);
|
||
if (error) {
|
||
reject(error);
|
||
} else if (resolve) {
|
||
resolve(resultingTree);
|
||
} else {
|
||
ok(done, "`done` is defined if `resolve` is not");
|
||
done(void 0, resultingTree, file2);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Run *transformers* on a syntax tree.
|
||
*
|
||
* An error is thrown if asynchronous transforms are configured.
|
||
*
|
||
* > **Note**: `runSync` freezes the processor if not already *frozen*.
|
||
*
|
||
* > **Note**: `runSync` performs the run phase, not other phases.
|
||
*
|
||
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
||
* Tree to transform and inspect.
|
||
* @param {Compatible | undefined} [file]
|
||
* File associated with `node` (optional); any value accepted as `x` in
|
||
* `new VFile(x)`.
|
||
* @returns {TailTree extends undefined ? Node : TailTree}
|
||
* Transformed tree.
|
||
*/
|
||
runSync(tree, file) {
|
||
let complete = false;
|
||
let result;
|
||
this.run(tree, file, realDone);
|
||
assertDone("runSync", "run", complete);
|
||
ok(result, "we either bailed on an error or have a tree");
|
||
return result;
|
||
function realDone(error, tree2) {
|
||
bail(error);
|
||
result = tree2;
|
||
complete = true;
|
||
}
|
||
}
|
||
/**
|
||
* Compile a syntax tree.
|
||
*
|
||
* > **Note**: `stringify` freezes the processor if not already *frozen*.
|
||
*
|
||
* > **Note**: `stringify` performs the stringify phase, not the run phase
|
||
* > or other phases.
|
||
*
|
||
* @param {CompileTree extends undefined ? Node : CompileTree} tree
|
||
* Tree to compile.
|
||
* @param {Compatible | undefined} [file]
|
||
* File associated with `node` (optional); any value accepted as `x` in
|
||
* `new VFile(x)`.
|
||
* @returns {CompileResult extends undefined ? Value : CompileResult}
|
||
* Textual representation of the tree (see note).
|
||
*
|
||
* > **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
|
||
*/
|
||
stringify(tree, file) {
|
||
this.freeze();
|
||
const realFile = vfile(file);
|
||
const compiler2 = this.compiler || this.Compiler;
|
||
assertCompiler("stringify", compiler2);
|
||
assertNode(tree);
|
||
return compiler2(tree, realFile);
|
||
}
|
||
/**
|
||
* Configure the processor to use a plugin, a list of usable values, or a
|
||
* preset.
|
||
*
|
||
* If the processor is already using a plugin, the previous plugin
|
||
* configuration is changed based on the options that are passed in.
|
||
* In other words, the plugin is not added a second time.
|
||
*
|
||
* > **Note**: `use` cannot be called on *frozen* processors.
|
||
* > Call the processor first to create a new unfrozen processor.
|
||
*
|
||
* @example
|
||
* There are many ways to pass plugins to `.use()`.
|
||
* This example gives an overview:
|
||
*
|
||
* ```js
|
||
* import {unified} from 'unified'
|
||
*
|
||
* unified()
|
||
* // Plugin with options:
|
||
* .use(pluginA, {x: true, y: true})
|
||
* // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`):
|
||
* .use(pluginA, {y: false, z: true})
|
||
* // Plugins:
|
||
* .use([pluginB, pluginC])
|
||
* // Two plugins, the second with options:
|
||
* .use([pluginD, [pluginE, {}]])
|
||
* // Preset with plugins and settings:
|
||
* .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}})
|
||
* // Settings only:
|
||
* .use({settings: {position: false}})
|
||
* ```
|
||
*
|
||
* @template {Array<unknown>} [Parameters=[]]
|
||
* @template {Node | string | undefined} [Input=undefined]
|
||
* @template [Output=Input]
|
||
*
|
||
* @overload
|
||
* @param {Preset | null | undefined} [preset]
|
||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
||
*
|
||
* @overload
|
||
* @param {PluggableList} list
|
||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
||
*
|
||
* @overload
|
||
* @param {Plugin<Parameters, Input, Output>} plugin
|
||
* @param {...(Parameters | [boolean])} parameters
|
||
* @returns {UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>}
|
||
*
|
||
* @param {PluggableList | Plugin | Preset | null | undefined} value
|
||
* Usable value.
|
||
* @param {...unknown} parameters
|
||
* Parameters, when a plugin is given as a usable value.
|
||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
||
* Current processor.
|
||
*/
|
||
use(value, ...parameters) {
|
||
const attachers = this.attachers;
|
||
const namespace = this.namespace;
|
||
assertUnfrozen("use", this.frozen);
|
||
if (value === null || value === void 0) {
|
||
} else if (typeof value === "function") {
|
||
addPlugin(value, parameters);
|
||
} else if (typeof value === "object") {
|
||
if (Array.isArray(value)) {
|
||
addList(value);
|
||
} else {
|
||
addPreset(value);
|
||
}
|
||
} else {
|
||
throw new TypeError("Expected usable value, not `" + value + "`");
|
||
}
|
||
return this;
|
||
function add(value2) {
|
||
if (typeof value2 === "function") {
|
||
addPlugin(value2, []);
|
||
} else if (typeof value2 === "object") {
|
||
if (Array.isArray(value2)) {
|
||
const [plugin, ...parameters2] = (
|
||
/** @type {PluginTuple<Array<unknown>>} */
|
||
value2
|
||
);
|
||
addPlugin(plugin, parameters2);
|
||
} else {
|
||
addPreset(value2);
|
||
}
|
||
} else {
|
||
throw new TypeError("Expected usable value, not `" + value2 + "`");
|
||
}
|
||
}
|
||
function addPreset(result) {
|
||
if (!("plugins" in result) && !("settings" in result)) {
|
||
throw new Error(
|
||
"Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither"
|
||
);
|
||
}
|
||
addList(result.plugins);
|
||
if (result.settings) {
|
||
namespace.settings = (0, import_extend.default)(true, namespace.settings, result.settings);
|
||
}
|
||
}
|
||
function addList(plugins) {
|
||
let index = -1;
|
||
if (plugins === null || plugins === void 0) {
|
||
} else if (Array.isArray(plugins)) {
|
||
while (++index < plugins.length) {
|
||
const thing = plugins[index];
|
||
add(thing);
|
||
}
|
||
} else {
|
||
throw new TypeError("Expected a list of plugins, not `" + plugins + "`");
|
||
}
|
||
}
|
||
function addPlugin(plugin, parameters2) {
|
||
let index = -1;
|
||
let entryIndex = -1;
|
||
while (++index < attachers.length) {
|
||
if (attachers[index][0] === plugin) {
|
||
entryIndex = index;
|
||
break;
|
||
}
|
||
}
|
||
if (entryIndex === -1) {
|
||
attachers.push([plugin, ...parameters2]);
|
||
} else if (parameters2.length > 0) {
|
||
let [primary, ...rest] = parameters2;
|
||
const currentPrimary = attachers[entryIndex][1];
|
||
if (isPlainObject(currentPrimary) && isPlainObject(primary)) {
|
||
primary = (0, import_extend.default)(true, currentPrimary, primary);
|
||
}
|
||
attachers[entryIndex] = [plugin, primary, ...rest];
|
||
}
|
||
}
|
||
}
|
||
};
|
||
var unified = new Processor().freeze();
|
||
function assertParser(name, value) {
|
||
if (typeof value !== "function") {
|
||
throw new TypeError("Cannot `" + name + "` without `parser`");
|
||
}
|
||
}
|
||
function assertCompiler(name, value) {
|
||
if (typeof value !== "function") {
|
||
throw new TypeError("Cannot `" + name + "` without `compiler`");
|
||
}
|
||
}
|
||
function assertUnfrozen(name, frozen) {
|
||
if (frozen) {
|
||
throw new Error(
|
||
"Cannot call `" + name + "` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`."
|
||
);
|
||
}
|
||
}
|
||
function assertNode(node) {
|
||
if (!isPlainObject(node) || typeof node.type !== "string") {
|
||
throw new TypeError("Expected node, got `" + node + "`");
|
||
}
|
||
}
|
||
function assertDone(name, asyncName, complete) {
|
||
if (!complete) {
|
||
throw new Error(
|
||
"`" + name + "` finished async. Use `" + asyncName + "` instead"
|
||
);
|
||
}
|
||
}
|
||
function vfile(value) {
|
||
return looksLikeAVFile(value) ? value : new VFile(value);
|
||
}
|
||
function looksLikeAVFile(value) {
|
||
return Boolean(
|
||
value && typeof value === "object" && "message" in value && "messages" in value
|
||
);
|
||
}
|
||
function looksLikeAValue(value) {
|
||
return typeof value === "string" || isUint8Array2(value);
|
||
}
|
||
function isUint8Array2(value) {
|
||
return Boolean(
|
||
value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
|
||
);
|
||
}
|
||
|
||
// node_modules/react-markdown/lib/index.js
|
||
var changelog = "https://github.com/remarkjs/react-markdown/blob/main/changelog.md";
|
||
var emptyPlugins = [];
|
||
var emptyRemarkRehypeOptions = { allowDangerousHtml: true };
|
||
var safeProtocol = /^(https?|ircs?|mailto|xmpp)$/i;
|
||
var deprecations = [
|
||
{ from: "astPlugins", id: "remove-buggy-html-in-markdown-parser" },
|
||
{ from: "allowDangerousHtml", id: "remove-buggy-html-in-markdown-parser" },
|
||
{
|
||
from: "allowNode",
|
||
id: "replace-allownode-allowedtypes-and-disallowedtypes",
|
||
to: "allowElement"
|
||
},
|
||
{
|
||
from: "allowedTypes",
|
||
id: "replace-allownode-allowedtypes-and-disallowedtypes",
|
||
to: "allowedElements"
|
||
},
|
||
{ from: "className", id: "remove-classname" },
|
||
{
|
||
from: "disallowedTypes",
|
||
id: "replace-allownode-allowedtypes-and-disallowedtypes",
|
||
to: "disallowedElements"
|
||
},
|
||
{ from: "escapeHtml", id: "remove-buggy-html-in-markdown-parser" },
|
||
{ from: "includeElementIndex", id: "#remove-includeelementindex" },
|
||
{
|
||
from: "includeNodeIndex",
|
||
id: "change-includenodeindex-to-includeelementindex"
|
||
},
|
||
{ from: "linkTarget", id: "remove-linktarget" },
|
||
{ from: "plugins", id: "change-plugins-to-remarkplugins", to: "remarkPlugins" },
|
||
{ from: "rawSourcePos", id: "#remove-rawsourcepos" },
|
||
{ from: "renderers", id: "change-renderers-to-components", to: "components" },
|
||
{ from: "source", id: "change-source-to-children", to: "children" },
|
||
{ from: "sourcePos", id: "#remove-sourcepos" },
|
||
{ from: "transformImageUri", id: "#add-urltransform", to: "urlTransform" },
|
||
{ from: "transformLinkUri", id: "#add-urltransform", to: "urlTransform" }
|
||
];
|
||
function Markdown(options) {
|
||
const processor = createProcessor(options);
|
||
const file = createFile(options);
|
||
return post(processor.runSync(processor.parse(file), file), options);
|
||
}
|
||
async function MarkdownAsync(options) {
|
||
const processor = createProcessor(options);
|
||
const file = createFile(options);
|
||
const tree = await processor.run(processor.parse(file), file);
|
||
return post(tree, options);
|
||
}
|
||
function MarkdownHooks(options) {
|
||
const processor = createProcessor(options);
|
||
const [error, setError] = (0, import_react.useState)(
|
||
/** @type {Error | undefined} */
|
||
void 0
|
||
);
|
||
const [tree, setTree] = (0, import_react.useState)(
|
||
/** @type {Root | undefined} */
|
||
void 0
|
||
);
|
||
(0, import_react.useEffect)(
|
||
function() {
|
||
let cancelled = false;
|
||
const file = createFile(options);
|
||
processor.run(processor.parse(file), file, function(error2, tree2) {
|
||
if (!cancelled) {
|
||
setError(error2);
|
||
setTree(tree2);
|
||
}
|
||
});
|
||
return function() {
|
||
cancelled = true;
|
||
};
|
||
},
|
||
[
|
||
options.children,
|
||
options.rehypePlugins,
|
||
options.remarkPlugins,
|
||
options.remarkRehypeOptions
|
||
]
|
||
);
|
||
if (error) throw error;
|
||
return tree ? post(tree, options) : options.fallback;
|
||
}
|
||
function createProcessor(options) {
|
||
const rehypePlugins = options.rehypePlugins || emptyPlugins;
|
||
const remarkPlugins = options.remarkPlugins || emptyPlugins;
|
||
const remarkRehypeOptions = options.remarkRehypeOptions ? { ...options.remarkRehypeOptions, ...emptyRemarkRehypeOptions } : emptyRemarkRehypeOptions;
|
||
const processor = unified().use(remarkParse).use(remarkPlugins).use(remarkRehype, remarkRehypeOptions).use(rehypePlugins);
|
||
return processor;
|
||
}
|
||
function createFile(options) {
|
||
const children = options.children || "";
|
||
const file = new VFile();
|
||
if (typeof children === "string") {
|
||
file.value = children;
|
||
} else {
|
||
unreachable(
|
||
"Unexpected value `" + children + "` for `children` prop, expected `string`"
|
||
);
|
||
}
|
||
return file;
|
||
}
|
||
function post(tree, options) {
|
||
const allowedElements = options.allowedElements;
|
||
const allowElement = options.allowElement;
|
||
const components = options.components;
|
||
const disallowedElements = options.disallowedElements;
|
||
const skipHtml = options.skipHtml;
|
||
const unwrapDisallowed = options.unwrapDisallowed;
|
||
const urlTransform = options.urlTransform || defaultUrlTransform;
|
||
for (const deprecation of deprecations) {
|
||
if (Object.hasOwn(options, deprecation.from)) {
|
||
unreachable(
|
||
"Unexpected `" + deprecation.from + "` prop, " + (deprecation.to ? "use `" + deprecation.to + "` instead" : "remove it") + " (see <" + changelog + "#" + deprecation.id + "> for more info)"
|
||
);
|
||
}
|
||
}
|
||
if (allowedElements && disallowedElements) {
|
||
unreachable(
|
||
"Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"
|
||
);
|
||
}
|
||
visit(tree, transform);
|
||
return toJsxRuntime(tree, {
|
||
Fragment: import_jsx_runtime.Fragment,
|
||
components,
|
||
ignoreInvalidStyle: true,
|
||
jsx: import_jsx_runtime.jsx,
|
||
jsxs: import_jsx_runtime.jsxs,
|
||
passKeys: true,
|
||
passNode: true
|
||
});
|
||
function transform(node, index, parent) {
|
||
if (node.type === "raw" && parent && typeof index === "number") {
|
||
if (skipHtml) {
|
||
parent.children.splice(index, 1);
|
||
} else {
|
||
parent.children[index] = { type: "text", value: node.value };
|
||
}
|
||
return index;
|
||
}
|
||
if (node.type === "element") {
|
||
let key;
|
||
for (key in urlAttributes) {
|
||
if (Object.hasOwn(urlAttributes, key) && Object.hasOwn(node.properties, key)) {
|
||
const value = node.properties[key];
|
||
const test = urlAttributes[key];
|
||
if (test === null || test.includes(node.tagName)) {
|
||
node.properties[key] = urlTransform(String(value || ""), key, node);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (node.type === "element") {
|
||
let remove = allowedElements ? !allowedElements.includes(node.tagName) : disallowedElements ? disallowedElements.includes(node.tagName) : false;
|
||
if (!remove && allowElement && typeof index === "number") {
|
||
remove = !allowElement(node, index, parent);
|
||
}
|
||
if (remove && parent && typeof index === "number") {
|
||
if (unwrapDisallowed && node.children) {
|
||
parent.children.splice(index, 1, ...node.children);
|
||
} else {
|
||
parent.children.splice(index, 1);
|
||
}
|
||
return index;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function defaultUrlTransform(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 === -1 || // 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.
|
||
safeProtocol.test(value.slice(0, colon))
|
||
) {
|
||
return value;
|
||
}
|
||
return "";
|
||
}
|
||
export {
|
||
MarkdownAsync,
|
||
MarkdownHooks,
|
||
Markdown as default,
|
||
defaultUrlTransform
|
||
};
|
||
//# sourceMappingURL=react-markdown.js.map
|