Spaces:
Runtime error
Runtime error
| import { i as __toESM, n as __commonJSMin, r as __exportAll, t as require_react } from "./react-DMmEJb6B.js"; | |
| import { t as require_jsx_runtime } from "./react_jsx-runtime.js"; | |
| import { A as unreachable, C as splice, D as codes, E as constants, O as toString$1, S as push, T as types, _ as markdownSpace, a as resolveAll, b as normalizeIdentifier, c as asciiAlpha, d as asciiControl, f as asciiDigit, g as markdownLineEndingOrSpace, h as markdownLineEnding, i as blankLine, k as ok, l as asciiAlphanumeric, m as asciiPunctuation, o as classifyCharacter, p as asciiHexDigit, s as factorySpace, t as visit, u as asciiAtext, w as values, x as combineExtensions } from "./lib-D17qFPzW.js"; | |
| //#region ../node_modules/comma-separated-tokens/index.js | |
| /** | |
| * Serialize an array of strings or numbers to comma-separated tokens. | |
| * | |
| * @param {Array<string|number>} values | |
| * List of tokens. | |
| * @param {Options} [options] | |
| * Configuration for `stringify` (optional). | |
| * @returns {string} | |
| * Comma-separated tokens. | |
| */ | |
| function stringify$1(values, options) { | |
| const settings = options || {}; | |
| return (values[values.length - 1] === "" ? [...values, ""] : values).join((settings.padRight ? " " : "") + "," + (settings.padLeft === false ? "" : " ")).trim(); | |
| } | |
| //#endregion | |
| //#region ../node_modules/estree-util-is-identifier-name/lib/index.js | |
| var nameRe = /^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u; | |
| var nameReJsx = /^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u; | |
| /** @type {Options} */ | |
| var emptyOptions$1 = {}; | |
| /** | |
| * Checks if the given value is a valid identifier name. | |
| * | |
| * @param {string} name | |
| * Identifier to check. | |
| * @param {Options | null | undefined} [options] | |
| * Configuration (optional). | |
| * @returns {boolean} | |
| * Whether `name` can be an identifier. | |
| */ | |
| function name(name, options) { | |
| return ((options || emptyOptions$1).jsx ? nameReJsx : nameRe).test(name); | |
| } | |
| //#endregion | |
| //#region ../node_modules/hast-util-whitespace/lib/index.js | |
| /** | |
| * @typedef {import('hast').Nodes} Nodes | |
| */ | |
| var re = /[ \t\n\f\r]/g; | |
| /** | |
| * Check if the given value is *inter-element whitespace*. | |
| * | |
| * @param {Nodes | string} thing | |
| * Thing to check (`Node` or `string`). | |
| * @returns {boolean} | |
| * Whether the `value` is inter-element whitespace (`boolean`): consisting of | |
| * zero or more of space, tab (`\t`), line feed (`\n`), carriage return | |
| * (`\r`), or form feed (`\f`); if a node is passed it must be a `Text` node, | |
| * whose `value` field is checked. | |
| */ | |
| function whitespace(thing) { | |
| return typeof thing === "object" ? thing.type === "text" ? empty(thing.value) : false : empty(thing); | |
| } | |
| /** | |
| * @param {string} value | |
| * @returns {boolean} | |
| */ | |
| function empty(value) { | |
| return value.replace(re, "") === ""; | |
| } | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/util/schema.js | |
| /** | |
| * @import {Schema as SchemaType, Space} from 'property-information' | |
| */ | |
| /** @type {SchemaType} */ | |
| var Schema = class { | |
| /** | |
| * @param {SchemaType['property']} property | |
| * Property. | |
| * @param {SchemaType['normal']} normal | |
| * Normal. | |
| * @param {Space | undefined} [space] | |
| * Space. | |
| * @returns | |
| * Schema. | |
| */ | |
| constructor(property, normal, space) { | |
| this.normal = normal; | |
| this.property = property; | |
| if (space) this.space = space; | |
| } | |
| }; | |
| Schema.prototype.normal = {}; | |
| Schema.prototype.property = {}; | |
| Schema.prototype.space = void 0; | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/util/merge.js | |
| /** | |
| * @import {Info, Space} from 'property-information' | |
| */ | |
| /** | |
| * @param {ReadonlyArray<Schema>} definitions | |
| * Definitions. | |
| * @param {Space | undefined} [space] | |
| * Space. | |
| * @returns {Schema} | |
| * Schema. | |
| */ | |
| function merge(definitions, space) { | |
| /** @type {Record<string, Info>} */ | |
| const property = {}; | |
| /** @type {Record<string, string>} */ | |
| const normal = {}; | |
| for (const definition of definitions) { | |
| Object.assign(property, definition.property); | |
| Object.assign(normal, definition.normal); | |
| } | |
| return new Schema(property, normal, space); | |
| } | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/normalize.js | |
| /** | |
| * Get the cleaned case insensitive form of an attribute or property. | |
| * | |
| * @param {string} value | |
| * An attribute-like or property-like name. | |
| * @returns {string} | |
| * Value that can be used to look up the properly cased property on a | |
| * `Schema`. | |
| */ | |
| function normalize$1(value) { | |
| return value.toLowerCase(); | |
| } | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/util/info.js | |
| /** | |
| * @import {Info as InfoType} from 'property-information' | |
| */ | |
| /** @type {InfoType} */ | |
| var Info = class { | |
| /** | |
| * @param {string} property | |
| * Property. | |
| * @param {string} attribute | |
| * Attribute. | |
| * @returns | |
| * Info. | |
| */ | |
| constructor(property, attribute) { | |
| this.attribute = attribute; | |
| this.property = property; | |
| } | |
| }; | |
| Info.prototype.attribute = ""; | |
| Info.prototype.booleanish = false; | |
| Info.prototype.boolean = false; | |
| Info.prototype.commaOrSpaceSeparated = false; | |
| Info.prototype.commaSeparated = false; | |
| Info.prototype.defined = false; | |
| Info.prototype.mustUseProperty = false; | |
| Info.prototype.number = false; | |
| Info.prototype.overloadedBoolean = false; | |
| Info.prototype.property = ""; | |
| Info.prototype.spaceSeparated = false; | |
| Info.prototype.space = void 0; | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/util/types.js | |
| var types_exports = /* @__PURE__ */ __exportAll({ | |
| boolean: () => boolean, | |
| booleanish: () => booleanish, | |
| commaOrSpaceSeparated: () => commaOrSpaceSeparated, | |
| commaSeparated: () => commaSeparated, | |
| number: () => number, | |
| overloadedBoolean: () => overloadedBoolean, | |
| spaceSeparated: () => spaceSeparated | |
| }); | |
| var powers = 0; | |
| var boolean = increment(); | |
| var booleanish = increment(); | |
| var overloadedBoolean = increment(); | |
| var number = increment(); | |
| var spaceSeparated = increment(); | |
| var commaSeparated = increment(); | |
| var commaOrSpaceSeparated = increment(); | |
| function increment() { | |
| return 2 ** ++powers; | |
| } | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/util/defined-info.js | |
| /** | |
| * @import {Space} from 'property-information' | |
| */ | |
| var checks = Object.keys(types_exports); | |
| var DefinedInfo = class extends Info { | |
| /** | |
| * @constructor | |
| * @param {string} property | |
| * Property. | |
| * @param {string} attribute | |
| * Attribute. | |
| * @param {number | null | undefined} [mask] | |
| * Mask. | |
| * @param {Space | undefined} [space] | |
| * Space. | |
| * @returns | |
| * Info. | |
| */ | |
| constructor(property, attribute, mask, space) { | |
| let index = -1; | |
| super(property, attribute); | |
| mark(this, "space", space); | |
| if (typeof mask === "number") while (++index < checks.length) { | |
| const check = checks[index]; | |
| mark(this, checks[index], (mask & types_exports[check]) === types_exports[check]); | |
| } | |
| } | |
| }; | |
| DefinedInfo.prototype.defined = true; | |
| /** | |
| * @template {keyof DefinedInfo} Key | |
| * Key type. | |
| * @param {DefinedInfo} values | |
| * Info. | |
| * @param {Key} key | |
| * Key. | |
| * @param {DefinedInfo[Key]} value | |
| * Value. | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| function mark(values, key, value) { | |
| if (value) values[key] = value; | |
| } | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/util/create.js | |
| /** | |
| * @import {Info, Space} from 'property-information' | |
| */ | |
| /** | |
| * @typedef Definition | |
| * Definition of a schema. | |
| * @property {Record<string, string> | undefined} [attributes] | |
| * Normalzed names to special attribute case. | |
| * @property {ReadonlyArray<string> | undefined} [mustUseProperty] | |
| * Normalized names that must be set as properties. | |
| * @property {Record<string, number | null>} properties | |
| * Property names to their types. | |
| * @property {Space | undefined} [space] | |
| * Space. | |
| * @property {Transform} transform | |
| * Transform a property name. | |
| */ | |
| /** | |
| * @callback Transform | |
| * Transform. | |
| * @param {Record<string, string>} attributes | |
| * Attributes. | |
| * @param {string} property | |
| * Property. | |
| * @returns {string} | |
| * Attribute. | |
| */ | |
| /** | |
| * @param {Definition} definition | |
| * Definition. | |
| * @returns {Schema} | |
| * Schema. | |
| */ | |
| function create(definition) { | |
| /** @type {Record<string, Info>} */ | |
| const properties = {}; | |
| /** @type {Record<string, string>} */ | |
| const normals = {}; | |
| for (const [property, value] of Object.entries(definition.properties)) { | |
| const info = new DefinedInfo(property, definition.transform(definition.attributes || {}, property), value, definition.space); | |
| if (definition.mustUseProperty && definition.mustUseProperty.includes(property)) info.mustUseProperty = true; | |
| properties[property] = info; | |
| normals[normalize$1(property)] = property; | |
| normals[normalize$1(info.attribute)] = property; | |
| } | |
| return new Schema(properties, normals, definition.space); | |
| } | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/aria.js | |
| var aria = create({ | |
| properties: { | |
| ariaActiveDescendant: null, | |
| ariaAtomic: booleanish, | |
| ariaAutoComplete: null, | |
| ariaBusy: booleanish, | |
| ariaChecked: booleanish, | |
| ariaColCount: number, | |
| ariaColIndex: number, | |
| ariaColSpan: number, | |
| ariaControls: spaceSeparated, | |
| ariaCurrent: null, | |
| ariaDescribedBy: spaceSeparated, | |
| ariaDetails: null, | |
| ariaDisabled: booleanish, | |
| ariaDropEffect: spaceSeparated, | |
| ariaErrorMessage: null, | |
| ariaExpanded: booleanish, | |
| ariaFlowTo: spaceSeparated, | |
| ariaGrabbed: booleanish, | |
| ariaHasPopup: null, | |
| ariaHidden: booleanish, | |
| ariaInvalid: null, | |
| ariaKeyShortcuts: null, | |
| ariaLabel: null, | |
| ariaLabelledBy: spaceSeparated, | |
| ariaLevel: number, | |
| ariaLive: null, | |
| ariaModal: booleanish, | |
| ariaMultiLine: booleanish, | |
| ariaMultiSelectable: booleanish, | |
| ariaOrientation: null, | |
| ariaOwns: spaceSeparated, | |
| ariaPlaceholder: null, | |
| ariaPosInSet: number, | |
| ariaPressed: booleanish, | |
| ariaReadOnly: booleanish, | |
| ariaRelevant: null, | |
| ariaRequired: booleanish, | |
| ariaRoleDescription: spaceSeparated, | |
| ariaRowCount: number, | |
| ariaRowIndex: number, | |
| ariaRowSpan: number, | |
| ariaSelected: booleanish, | |
| ariaSetSize: number, | |
| ariaSort: null, | |
| ariaValueMax: number, | |
| ariaValueMin: number, | |
| ariaValueNow: number, | |
| ariaValueText: null, | |
| role: null | |
| }, | |
| transform(_, property) { | |
| return property === "role" ? property : "aria-" + property.slice(4).toLowerCase(); | |
| } | |
| }); | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/util/case-sensitive-transform.js | |
| /** | |
| * @param {Record<string, string>} attributes | |
| * Attributes. | |
| * @param {string} attribute | |
| * Attribute. | |
| * @returns {string} | |
| * Transformed attribute. | |
| */ | |
| function caseSensitiveTransform(attributes, attribute) { | |
| return attribute in attributes ? attributes[attribute] : attribute; | |
| } | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/util/case-insensitive-transform.js | |
| /** | |
| * @param {Record<string, string>} attributes | |
| * Attributes. | |
| * @param {string} property | |
| * Property. | |
| * @returns {string} | |
| * Transformed property. | |
| */ | |
| function caseInsensitiveTransform(attributes, property) { | |
| return caseSensitiveTransform(attributes, property.toLowerCase()); | |
| } | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/html.js | |
| var html$2 = create({ | |
| attributes: { | |
| acceptcharset: "accept-charset", | |
| classname: "class", | |
| htmlfor: "for", | |
| httpequiv: "http-equiv" | |
| }, | |
| mustUseProperty: [ | |
| "checked", | |
| "multiple", | |
| "muted", | |
| "selected" | |
| ], | |
| properties: { | |
| abbr: null, | |
| accept: commaSeparated, | |
| acceptCharset: spaceSeparated, | |
| accessKey: spaceSeparated, | |
| action: null, | |
| allow: null, | |
| allowFullScreen: boolean, | |
| allowPaymentRequest: boolean, | |
| allowUserMedia: boolean, | |
| alt: null, | |
| as: null, | |
| async: boolean, | |
| autoCapitalize: null, | |
| autoComplete: spaceSeparated, | |
| autoFocus: boolean, | |
| autoPlay: boolean, | |
| blocking: spaceSeparated, | |
| capture: null, | |
| charSet: null, | |
| checked: boolean, | |
| cite: null, | |
| className: spaceSeparated, | |
| cols: number, | |
| colSpan: null, | |
| content: null, | |
| contentEditable: booleanish, | |
| controls: boolean, | |
| controlsList: spaceSeparated, | |
| coords: number | commaSeparated, | |
| crossOrigin: null, | |
| data: null, | |
| dateTime: null, | |
| decoding: null, | |
| default: boolean, | |
| defer: boolean, | |
| dir: null, | |
| dirName: null, | |
| disabled: boolean, | |
| download: overloadedBoolean, | |
| draggable: booleanish, | |
| encType: null, | |
| enterKeyHint: null, | |
| fetchPriority: null, | |
| form: null, | |
| formAction: null, | |
| formEncType: null, | |
| formMethod: null, | |
| formNoValidate: boolean, | |
| formTarget: null, | |
| headers: spaceSeparated, | |
| height: number, | |
| hidden: overloadedBoolean, | |
| high: number, | |
| href: null, | |
| hrefLang: null, | |
| htmlFor: spaceSeparated, | |
| httpEquiv: spaceSeparated, | |
| id: null, | |
| imageSizes: null, | |
| imageSrcSet: null, | |
| inert: boolean, | |
| inputMode: null, | |
| integrity: null, | |
| is: null, | |
| isMap: boolean, | |
| itemId: null, | |
| itemProp: spaceSeparated, | |
| itemRef: spaceSeparated, | |
| itemScope: boolean, | |
| itemType: spaceSeparated, | |
| kind: null, | |
| label: null, | |
| lang: null, | |
| language: null, | |
| list: null, | |
| loading: null, | |
| loop: boolean, | |
| low: number, | |
| manifest: null, | |
| max: null, | |
| maxLength: number, | |
| media: null, | |
| method: null, | |
| min: null, | |
| minLength: number, | |
| multiple: boolean, | |
| muted: boolean, | |
| name: null, | |
| nonce: null, | |
| noModule: boolean, | |
| noValidate: boolean, | |
| onAbort: null, | |
| onAfterPrint: null, | |
| onAuxClick: null, | |
| onBeforeMatch: null, | |
| onBeforePrint: null, | |
| onBeforeToggle: null, | |
| onBeforeUnload: null, | |
| onBlur: null, | |
| onCancel: null, | |
| onCanPlay: null, | |
| onCanPlayThrough: null, | |
| onChange: null, | |
| onClick: null, | |
| onClose: null, | |
| onContextLost: null, | |
| onContextMenu: null, | |
| onContextRestored: null, | |
| onCopy: null, | |
| onCueChange: null, | |
| onCut: null, | |
| onDblClick: null, | |
| onDrag: null, | |
| onDragEnd: null, | |
| onDragEnter: null, | |
| onDragExit: null, | |
| onDragLeave: null, | |
| onDragOver: null, | |
| onDragStart: null, | |
| onDrop: null, | |
| onDurationChange: null, | |
| onEmptied: null, | |
| onEnded: null, | |
| onError: null, | |
| onFocus: null, | |
| onFormData: null, | |
| onHashChange: null, | |
| onInput: null, | |
| onInvalid: null, | |
| onKeyDown: null, | |
| onKeyPress: null, | |
| onKeyUp: null, | |
| onLanguageChange: null, | |
| onLoad: null, | |
| onLoadedData: null, | |
| onLoadedMetadata: null, | |
| onLoadEnd: null, | |
| onLoadStart: null, | |
| onMessage: null, | |
| onMessageError: null, | |
| onMouseDown: null, | |
| onMouseEnter: null, | |
| onMouseLeave: null, | |
| onMouseMove: null, | |
| onMouseOut: null, | |
| onMouseOver: null, | |
| onMouseUp: null, | |
| onOffline: null, | |
| onOnline: null, | |
| onPageHide: null, | |
| onPageShow: null, | |
| onPaste: null, | |
| onPause: null, | |
| onPlay: null, | |
| onPlaying: null, | |
| onPopState: null, | |
| onProgress: null, | |
| onRateChange: null, | |
| onRejectionHandled: null, | |
| onReset: null, | |
| onResize: null, | |
| onScroll: null, | |
| onScrollEnd: null, | |
| onSecurityPolicyViolation: null, | |
| onSeeked: null, | |
| onSeeking: null, | |
| onSelect: null, | |
| onSlotChange: null, | |
| onStalled: null, | |
| onStorage: null, | |
| onSubmit: null, | |
| onSuspend: null, | |
| onTimeUpdate: null, | |
| onToggle: null, | |
| onUnhandledRejection: null, | |
| onUnload: null, | |
| onVolumeChange: null, | |
| onWaiting: null, | |
| onWheel: null, | |
| open: boolean, | |
| optimum: number, | |
| pattern: null, | |
| ping: spaceSeparated, | |
| placeholder: null, | |
| playsInline: boolean, | |
| popover: null, | |
| popoverTarget: null, | |
| popoverTargetAction: null, | |
| poster: null, | |
| preload: null, | |
| readOnly: boolean, | |
| referrerPolicy: null, | |
| rel: spaceSeparated, | |
| required: boolean, | |
| reversed: boolean, | |
| rows: number, | |
| rowSpan: number, | |
| sandbox: spaceSeparated, | |
| scope: null, | |
| scoped: boolean, | |
| seamless: boolean, | |
| selected: boolean, | |
| shadowRootClonable: boolean, | |
| shadowRootDelegatesFocus: boolean, | |
| shadowRootMode: null, | |
| shape: null, | |
| size: number, | |
| sizes: null, | |
| slot: null, | |
| span: number, | |
| spellCheck: booleanish, | |
| src: null, | |
| srcDoc: null, | |
| srcLang: null, | |
| srcSet: null, | |
| start: number, | |
| step: null, | |
| style: null, | |
| tabIndex: number, | |
| target: null, | |
| title: null, | |
| translate: null, | |
| type: null, | |
| typeMustMatch: boolean, | |
| useMap: null, | |
| value: booleanish, | |
| width: number, | |
| wrap: null, | |
| writingSuggestions: null, | |
| align: null, | |
| aLink: null, | |
| archive: spaceSeparated, | |
| axis: null, | |
| background: null, | |
| bgColor: null, | |
| border: number, | |
| borderColor: null, | |
| bottomMargin: number, | |
| cellPadding: null, | |
| cellSpacing: null, | |
| char: null, | |
| charOff: null, | |
| classId: null, | |
| clear: null, | |
| code: null, | |
| codeBase: null, | |
| codeType: null, | |
| color: null, | |
| compact: boolean, | |
| declare: boolean, | |
| event: null, | |
| face: null, | |
| frame: null, | |
| frameBorder: null, | |
| hSpace: number, | |
| leftMargin: number, | |
| link: null, | |
| longDesc: null, | |
| lowSrc: null, | |
| marginHeight: number, | |
| marginWidth: number, | |
| noResize: boolean, | |
| noHref: boolean, | |
| noShade: boolean, | |
| noWrap: boolean, | |
| object: null, | |
| profile: null, | |
| prompt: null, | |
| rev: null, | |
| rightMargin: number, | |
| rules: null, | |
| scheme: null, | |
| scrolling: booleanish, | |
| standby: null, | |
| summary: null, | |
| text: null, | |
| topMargin: number, | |
| valueType: null, | |
| version: null, | |
| vAlign: null, | |
| vLink: null, | |
| vSpace: number, | |
| allowTransparency: null, | |
| autoCorrect: null, | |
| autoSave: null, | |
| disablePictureInPicture: boolean, | |
| disableRemotePlayback: boolean, | |
| prefix: null, | |
| property: null, | |
| results: number, | |
| security: null, | |
| unselectable: null | |
| }, | |
| space: "html", | |
| transform: caseInsensitiveTransform | |
| }); | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/svg.js | |
| var svg$1 = create({ | |
| attributes: { | |
| accentHeight: "accent-height", | |
| alignmentBaseline: "alignment-baseline", | |
| arabicForm: "arabic-form", | |
| baselineShift: "baseline-shift", | |
| capHeight: "cap-height", | |
| className: "class", | |
| clipPath: "clip-path", | |
| clipRule: "clip-rule", | |
| colorInterpolation: "color-interpolation", | |
| colorInterpolationFilters: "color-interpolation-filters", | |
| colorProfile: "color-profile", | |
| colorRendering: "color-rendering", | |
| crossOrigin: "crossorigin", | |
| dataType: "datatype", | |
| dominantBaseline: "dominant-baseline", | |
| enableBackground: "enable-background", | |
| fillOpacity: "fill-opacity", | |
| fillRule: "fill-rule", | |
| floodColor: "flood-color", | |
| floodOpacity: "flood-opacity", | |
| fontFamily: "font-family", | |
| fontSize: "font-size", | |
| fontSizeAdjust: "font-size-adjust", | |
| fontStretch: "font-stretch", | |
| fontStyle: "font-style", | |
| fontVariant: "font-variant", | |
| fontWeight: "font-weight", | |
| glyphName: "glyph-name", | |
| glyphOrientationHorizontal: "glyph-orientation-horizontal", | |
| glyphOrientationVertical: "glyph-orientation-vertical", | |
| hrefLang: "hreflang", | |
| horizAdvX: "horiz-adv-x", | |
| horizOriginX: "horiz-origin-x", | |
| horizOriginY: "horiz-origin-y", | |
| imageRendering: "image-rendering", | |
| letterSpacing: "letter-spacing", | |
| lightingColor: "lighting-color", | |
| markerEnd: "marker-end", | |
| markerMid: "marker-mid", | |
| markerStart: "marker-start", | |
| navDown: "nav-down", | |
| navDownLeft: "nav-down-left", | |
| navDownRight: "nav-down-right", | |
| navLeft: "nav-left", | |
| navNext: "nav-next", | |
| navPrev: "nav-prev", | |
| navRight: "nav-right", | |
| navUp: "nav-up", | |
| navUpLeft: "nav-up-left", | |
| navUpRight: "nav-up-right", | |
| onAbort: "onabort", | |
| onActivate: "onactivate", | |
| onAfterPrint: "onafterprint", | |
| onBeforePrint: "onbeforeprint", | |
| onBegin: "onbegin", | |
| onCancel: "oncancel", | |
| onCanPlay: "oncanplay", | |
| onCanPlayThrough: "oncanplaythrough", | |
| onChange: "onchange", | |
| onClick: "onclick", | |
| onClose: "onclose", | |
| onCopy: "oncopy", | |
| onCueChange: "oncuechange", | |
| onCut: "oncut", | |
| onDblClick: "ondblclick", | |
| onDrag: "ondrag", | |
| onDragEnd: "ondragend", | |
| onDragEnter: "ondragenter", | |
| onDragExit: "ondragexit", | |
| onDragLeave: "ondragleave", | |
| onDragOver: "ondragover", | |
| onDragStart: "ondragstart", | |
| onDrop: "ondrop", | |
| onDurationChange: "ondurationchange", | |
| onEmptied: "onemptied", | |
| onEnd: "onend", | |
| onEnded: "onended", | |
| onError: "onerror", | |
| onFocus: "onfocus", | |
| onFocusIn: "onfocusin", | |
| onFocusOut: "onfocusout", | |
| onHashChange: "onhashchange", | |
| onInput: "oninput", | |
| onInvalid: "oninvalid", | |
| onKeyDown: "onkeydown", | |
| onKeyPress: "onkeypress", | |
| onKeyUp: "onkeyup", | |
| onLoad: "onload", | |
| onLoadedData: "onloadeddata", | |
| onLoadedMetadata: "onloadedmetadata", | |
| onLoadStart: "onloadstart", | |
| onMessage: "onmessage", | |
| onMouseDown: "onmousedown", | |
| onMouseEnter: "onmouseenter", | |
| onMouseLeave: "onmouseleave", | |
| onMouseMove: "onmousemove", | |
| onMouseOut: "onmouseout", | |
| onMouseOver: "onmouseover", | |
| onMouseUp: "onmouseup", | |
| onMouseWheel: "onmousewheel", | |
| onOffline: "onoffline", | |
| onOnline: "ononline", | |
| onPageHide: "onpagehide", | |
| onPageShow: "onpageshow", | |
| onPaste: "onpaste", | |
| onPause: "onpause", | |
| onPlay: "onplay", | |
| onPlaying: "onplaying", | |
| onPopState: "onpopstate", | |
| onProgress: "onprogress", | |
| onRateChange: "onratechange", | |
| onRepeat: "onrepeat", | |
| onReset: "onreset", | |
| onResize: "onresize", | |
| onScroll: "onscroll", | |
| onSeeked: "onseeked", | |
| onSeeking: "onseeking", | |
| onSelect: "onselect", | |
| onShow: "onshow", | |
| onStalled: "onstalled", | |
| onStorage: "onstorage", | |
| onSubmit: "onsubmit", | |
| onSuspend: "onsuspend", | |
| onTimeUpdate: "ontimeupdate", | |
| onToggle: "ontoggle", | |
| onUnload: "onunload", | |
| onVolumeChange: "onvolumechange", | |
| onWaiting: "onwaiting", | |
| onZoom: "onzoom", | |
| overlinePosition: "overline-position", | |
| overlineThickness: "overline-thickness", | |
| paintOrder: "paint-order", | |
| panose1: "panose-1", | |
| pointerEvents: "pointer-events", | |
| referrerPolicy: "referrerpolicy", | |
| renderingIntent: "rendering-intent", | |
| shapeRendering: "shape-rendering", | |
| stopColor: "stop-color", | |
| stopOpacity: "stop-opacity", | |
| strikethroughPosition: "strikethrough-position", | |
| strikethroughThickness: "strikethrough-thickness", | |
| strokeDashArray: "stroke-dasharray", | |
| strokeDashOffset: "stroke-dashoffset", | |
| strokeLineCap: "stroke-linecap", | |
| strokeLineJoin: "stroke-linejoin", | |
| strokeMiterLimit: "stroke-miterlimit", | |
| strokeOpacity: "stroke-opacity", | |
| strokeWidth: "stroke-width", | |
| tabIndex: "tabindex", | |
| textAnchor: "text-anchor", | |
| textDecoration: "text-decoration", | |
| textRendering: "text-rendering", | |
| transformOrigin: "transform-origin", | |
| typeOf: "typeof", | |
| underlinePosition: "underline-position", | |
| underlineThickness: "underline-thickness", | |
| unicodeBidi: "unicode-bidi", | |
| unicodeRange: "unicode-range", | |
| unitsPerEm: "units-per-em", | |
| vAlphabetic: "v-alphabetic", | |
| vHanging: "v-hanging", | |
| vIdeographic: "v-ideographic", | |
| vMathematical: "v-mathematical", | |
| vectorEffect: "vector-effect", | |
| vertAdvY: "vert-adv-y", | |
| vertOriginX: "vert-origin-x", | |
| vertOriginY: "vert-origin-y", | |
| wordSpacing: "word-spacing", | |
| writingMode: "writing-mode", | |
| xHeight: "x-height", | |
| playbackOrder: "playbackorder", | |
| timelineBegin: "timelinebegin" | |
| }, | |
| properties: { | |
| about: commaOrSpaceSeparated, | |
| accentHeight: number, | |
| accumulate: null, | |
| additive: null, | |
| alignmentBaseline: null, | |
| alphabetic: number, | |
| amplitude: number, | |
| arabicForm: null, | |
| ascent: number, | |
| attributeName: null, | |
| attributeType: null, | |
| azimuth: number, | |
| bandwidth: null, | |
| baselineShift: null, | |
| baseFrequency: null, | |
| baseProfile: null, | |
| bbox: null, | |
| begin: null, | |
| bias: number, | |
| by: null, | |
| calcMode: null, | |
| capHeight: number, | |
| className: spaceSeparated, | |
| clip: null, | |
| clipPath: null, | |
| clipPathUnits: null, | |
| clipRule: null, | |
| color: null, | |
| colorInterpolation: null, | |
| colorInterpolationFilters: null, | |
| colorProfile: null, | |
| colorRendering: null, | |
| content: null, | |
| contentScriptType: null, | |
| contentStyleType: null, | |
| crossOrigin: null, | |
| cursor: null, | |
| cx: null, | |
| cy: null, | |
| d: null, | |
| dataType: null, | |
| defaultAction: null, | |
| descent: number, | |
| diffuseConstant: number, | |
| direction: null, | |
| display: null, | |
| dur: null, | |
| divisor: number, | |
| dominantBaseline: null, | |
| download: boolean, | |
| dx: null, | |
| dy: null, | |
| edgeMode: null, | |
| editable: null, | |
| elevation: number, | |
| enableBackground: null, | |
| end: null, | |
| event: null, | |
| exponent: number, | |
| externalResourcesRequired: null, | |
| fill: null, | |
| fillOpacity: number, | |
| fillRule: null, | |
| filter: null, | |
| filterRes: null, | |
| filterUnits: null, | |
| floodColor: null, | |
| floodOpacity: null, | |
| focusable: null, | |
| focusHighlight: null, | |
| fontFamily: null, | |
| fontSize: null, | |
| fontSizeAdjust: null, | |
| fontStretch: null, | |
| fontStyle: null, | |
| fontVariant: null, | |
| fontWeight: null, | |
| format: null, | |
| fr: null, | |
| from: null, | |
| fx: null, | |
| fy: null, | |
| g1: commaSeparated, | |
| g2: commaSeparated, | |
| glyphName: commaSeparated, | |
| glyphOrientationHorizontal: null, | |
| glyphOrientationVertical: null, | |
| glyphRef: null, | |
| gradientTransform: null, | |
| gradientUnits: null, | |
| handler: null, | |
| hanging: number, | |
| hatchContentUnits: null, | |
| hatchUnits: null, | |
| height: null, | |
| href: null, | |
| hrefLang: null, | |
| horizAdvX: number, | |
| horizOriginX: number, | |
| horizOriginY: number, | |
| id: null, | |
| ideographic: number, | |
| imageRendering: null, | |
| initialVisibility: null, | |
| in: null, | |
| in2: null, | |
| intercept: number, | |
| k: number, | |
| k1: number, | |
| k2: number, | |
| k3: number, | |
| k4: number, | |
| kernelMatrix: commaOrSpaceSeparated, | |
| kernelUnitLength: null, | |
| keyPoints: null, | |
| keySplines: null, | |
| keyTimes: null, | |
| kerning: null, | |
| lang: null, | |
| lengthAdjust: null, | |
| letterSpacing: null, | |
| lightingColor: null, | |
| limitingConeAngle: number, | |
| local: null, | |
| markerEnd: null, | |
| markerMid: null, | |
| markerStart: null, | |
| markerHeight: null, | |
| markerUnits: null, | |
| markerWidth: null, | |
| mask: null, | |
| maskContentUnits: null, | |
| maskUnits: null, | |
| mathematical: null, | |
| max: null, | |
| media: null, | |
| mediaCharacterEncoding: null, | |
| mediaContentEncodings: null, | |
| mediaSize: number, | |
| mediaTime: null, | |
| method: null, | |
| min: null, | |
| mode: null, | |
| name: null, | |
| navDown: null, | |
| navDownLeft: null, | |
| navDownRight: null, | |
| navLeft: null, | |
| navNext: null, | |
| navPrev: null, | |
| navRight: null, | |
| navUp: null, | |
| navUpLeft: null, | |
| navUpRight: null, | |
| numOctaves: null, | |
| observer: null, | |
| offset: null, | |
| onAbort: null, | |
| onActivate: null, | |
| onAfterPrint: null, | |
| onBeforePrint: null, | |
| onBegin: null, | |
| onCancel: null, | |
| onCanPlay: null, | |
| onCanPlayThrough: null, | |
| onChange: null, | |
| onClick: null, | |
| onClose: null, | |
| onCopy: null, | |
| onCueChange: null, | |
| onCut: null, | |
| onDblClick: null, | |
| onDrag: null, | |
| onDragEnd: null, | |
| onDragEnter: null, | |
| onDragExit: null, | |
| onDragLeave: null, | |
| onDragOver: null, | |
| onDragStart: null, | |
| onDrop: null, | |
| onDurationChange: null, | |
| onEmptied: null, | |
| onEnd: null, | |
| onEnded: null, | |
| onError: null, | |
| onFocus: null, | |
| onFocusIn: null, | |
| onFocusOut: null, | |
| onHashChange: null, | |
| onInput: null, | |
| onInvalid: null, | |
| onKeyDown: null, | |
| onKeyPress: null, | |
| onKeyUp: null, | |
| onLoad: null, | |
| onLoadedData: null, | |
| onLoadedMetadata: null, | |
| onLoadStart: null, | |
| onMessage: null, | |
| onMouseDown: null, | |
| onMouseEnter: null, | |
| onMouseLeave: null, | |
| onMouseMove: null, | |
| onMouseOut: null, | |
| onMouseOver: null, | |
| onMouseUp: null, | |
| onMouseWheel: null, | |
| onOffline: null, | |
| onOnline: null, | |
| onPageHide: null, | |
| onPageShow: null, | |
| onPaste: null, | |
| onPause: null, | |
| onPlay: null, | |
| onPlaying: null, | |
| onPopState: null, | |
| onProgress: null, | |
| onRateChange: null, | |
| onRepeat: null, | |
| onReset: null, | |
| onResize: null, | |
| onScroll: null, | |
| onSeeked: null, | |
| onSeeking: null, | |
| onSelect: null, | |
| onShow: null, | |
| onStalled: null, | |
| onStorage: null, | |
| onSubmit: null, | |
| onSuspend: null, | |
| onTimeUpdate: null, | |
| onToggle: null, | |
| onUnload: null, | |
| onVolumeChange: null, | |
| onWaiting: null, | |
| onZoom: null, | |
| opacity: null, | |
| operator: null, | |
| order: null, | |
| orient: null, | |
| orientation: null, | |
| origin: null, | |
| overflow: null, | |
| overlay: null, | |
| overlinePosition: number, | |
| overlineThickness: number, | |
| paintOrder: null, | |
| panose1: null, | |
| path: null, | |
| pathLength: number, | |
| patternContentUnits: null, | |
| patternTransform: null, | |
| patternUnits: null, | |
| phase: null, | |
| ping: spaceSeparated, | |
| pitch: null, | |
| playbackOrder: null, | |
| pointerEvents: null, | |
| points: null, | |
| pointsAtX: number, | |
| pointsAtY: number, | |
| pointsAtZ: number, | |
| preserveAlpha: null, | |
| preserveAspectRatio: null, | |
| primitiveUnits: null, | |
| propagate: null, | |
| property: commaOrSpaceSeparated, | |
| r: null, | |
| radius: null, | |
| referrerPolicy: null, | |
| refX: null, | |
| refY: null, | |
| rel: commaOrSpaceSeparated, | |
| rev: commaOrSpaceSeparated, | |
| renderingIntent: null, | |
| repeatCount: null, | |
| repeatDur: null, | |
| requiredExtensions: commaOrSpaceSeparated, | |
| requiredFeatures: commaOrSpaceSeparated, | |
| requiredFonts: commaOrSpaceSeparated, | |
| requiredFormats: commaOrSpaceSeparated, | |
| resource: null, | |
| restart: null, | |
| result: null, | |
| rotate: null, | |
| rx: null, | |
| ry: null, | |
| scale: null, | |
| seed: null, | |
| shapeRendering: null, | |
| side: null, | |
| slope: null, | |
| snapshotTime: null, | |
| specularConstant: number, | |
| specularExponent: number, | |
| spreadMethod: null, | |
| spacing: null, | |
| startOffset: null, | |
| stdDeviation: null, | |
| stemh: null, | |
| stemv: null, | |
| stitchTiles: null, | |
| stopColor: null, | |
| stopOpacity: null, | |
| strikethroughPosition: number, | |
| strikethroughThickness: number, | |
| string: null, | |
| stroke: null, | |
| strokeDashArray: commaOrSpaceSeparated, | |
| strokeDashOffset: null, | |
| strokeLineCap: null, | |
| strokeLineJoin: null, | |
| strokeMiterLimit: number, | |
| strokeOpacity: number, | |
| strokeWidth: null, | |
| style: null, | |
| surfaceScale: number, | |
| syncBehavior: null, | |
| syncBehaviorDefault: null, | |
| syncMaster: null, | |
| syncTolerance: null, | |
| syncToleranceDefault: null, | |
| systemLanguage: commaOrSpaceSeparated, | |
| tabIndex: number, | |
| tableValues: null, | |
| target: null, | |
| targetX: number, | |
| targetY: number, | |
| textAnchor: null, | |
| textDecoration: null, | |
| textRendering: null, | |
| textLength: null, | |
| timelineBegin: null, | |
| title: null, | |
| transformBehavior: null, | |
| type: null, | |
| typeOf: commaOrSpaceSeparated, | |
| to: null, | |
| transform: null, | |
| transformOrigin: null, | |
| u1: null, | |
| u2: null, | |
| underlinePosition: number, | |
| underlineThickness: number, | |
| unicode: null, | |
| unicodeBidi: null, | |
| unicodeRange: null, | |
| unitsPerEm: number, | |
| values: null, | |
| vAlphabetic: number, | |
| vMathematical: number, | |
| vectorEffect: null, | |
| vHanging: number, | |
| vIdeographic: number, | |
| version: null, | |
| vertAdvY: number, | |
| vertOriginX: number, | |
| vertOriginY: number, | |
| viewBox: null, | |
| viewTarget: null, | |
| visibility: null, | |
| width: null, | |
| widths: null, | |
| wordSpacing: null, | |
| writingMode: null, | |
| x: null, | |
| x1: null, | |
| x2: null, | |
| xChannelSelector: null, | |
| xHeight: number, | |
| y: null, | |
| y1: null, | |
| y2: null, | |
| yChannelSelector: null, | |
| z: null, | |
| zoomAndPan: null | |
| }, | |
| space: "svg", | |
| transform: caseSensitiveTransform | |
| }); | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/xlink.js | |
| var xlink = create({ | |
| properties: { | |
| xLinkActuate: null, | |
| xLinkArcRole: null, | |
| xLinkHref: null, | |
| xLinkRole: null, | |
| xLinkShow: null, | |
| xLinkTitle: null, | |
| xLinkType: null | |
| }, | |
| space: "xlink", | |
| transform(_, property) { | |
| return "xlink:" + property.slice(5).toLowerCase(); | |
| } | |
| }); | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/xmlns.js | |
| var xmlns = create({ | |
| attributes: { xmlnsxlink: "xmlns:xlink" }, | |
| properties: { | |
| xmlnsXLink: null, | |
| xmlns: null | |
| }, | |
| space: "xmlns", | |
| transform: caseInsensitiveTransform | |
| }); | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/xml.js | |
| var xml = create({ | |
| properties: { | |
| xmlBase: null, | |
| xmlLang: null, | |
| xmlSpace: null | |
| }, | |
| space: "xml", | |
| transform(_, property) { | |
| return "xml:" + property.slice(3).toLowerCase(); | |
| } | |
| }); | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/hast-to-react.js | |
| /** | |
| * Special cases for React (`Record<string, string>`). | |
| * | |
| * `hast` is close to `React` but differs in a couple of cases. | |
| * To get a React property from a hast property, | |
| * check if it is in `hastToReact`. | |
| * If it is, use the corresponding value; | |
| * otherwise, use the hast property. | |
| * | |
| * @type {Record<string, string>} | |
| */ | |
| var hastToReact = { | |
| classId: "classID", | |
| dataType: "datatype", | |
| itemId: "itemID", | |
| strokeDashArray: "strokeDasharray", | |
| strokeDashOffset: "strokeDashoffset", | |
| strokeLineCap: "strokeLinecap", | |
| strokeLineJoin: "strokeLinejoin", | |
| strokeMiterLimit: "strokeMiterlimit", | |
| typeOf: "typeof", | |
| xLinkActuate: "xlinkActuate", | |
| xLinkArcRole: "xlinkArcrole", | |
| xLinkHref: "xlinkHref", | |
| xLinkRole: "xlinkRole", | |
| xLinkShow: "xlinkShow", | |
| xLinkTitle: "xlinkTitle", | |
| xLinkType: "xlinkType", | |
| xmlnsXLink: "xmlnsXlink" | |
| }; | |
| //#endregion | |
| //#region ../node_modules/property-information/lib/find.js | |
| /** | |
| * @import {Schema} from 'property-information' | |
| */ | |
| var cap$1 = /[A-Z]/g; | |
| var dash = /-[a-z]/g; | |
| var valid = /^data[-\w.:]+$/i; | |
| /** | |
| * Look up info on a property. | |
| * | |
| * In most cases the given `schema` contains info on the property. | |
| * All standard, | |
| * most legacy, | |
| * and some non-standard properties are supported. | |
| * For these cases, | |
| * the returned `Info` has hints about the value of the property. | |
| * | |
| * `name` can also be a valid data attribute or property, | |
| * in which case an `Info` object with the correctly cased `attribute` and | |
| * `property` is returned. | |
| * | |
| * `name` can be an unknown attribute, | |
| * in which case an `Info` object with `attribute` and `property` set to the | |
| * given name is returned. | |
| * It is not recommended to provide unsupported legacy or recently specced | |
| * properties. | |
| * | |
| * | |
| * @param {Schema} schema | |
| * Schema; | |
| * either the `html` or `svg` export. | |
| * @param {string} value | |
| * An attribute-like or property-like name; | |
| * it will be passed through `normalize` to hopefully find the correct info. | |
| * @returns {Info} | |
| * Info. | |
| */ | |
| function find(schema, value) { | |
| const normal = normalize$1(value); | |
| let property = value; | |
| let Type = Info; | |
| if (normal in schema.normal) return schema.property[schema.normal[normal]]; | |
| if (normal.length > 4 && normal.slice(0, 4) === "data" && valid.test(value)) { | |
| if (value.charAt(4) === "-") { | |
| const rest = value.slice(5).replace(dash, camelcase); | |
| property = "data" + rest.charAt(0).toUpperCase() + rest.slice(1); | |
| } else { | |
| const rest = value.slice(4); | |
| if (!dash.test(rest)) { | |
| let dashes = rest.replace(cap$1, kebab); | |
| if (dashes.charAt(0) !== "-") dashes = "-" + dashes; | |
| value = "data" + dashes; | |
| } | |
| } | |
| Type = DefinedInfo; | |
| } | |
| return new Type(property, value); | |
| } | |
| /** | |
| * @param {string} $0 | |
| * Value. | |
| * @returns {string} | |
| * Kebab. | |
| */ | |
| function kebab($0) { | |
| return "-" + $0.toLowerCase(); | |
| } | |
| /** | |
| * @param {string} $0 | |
| * Value. | |
| * @returns {string} | |
| * Camel. | |
| */ | |
| function camelcase($0) { | |
| return $0.charAt(1).toUpperCase(); | |
| } | |
| //#endregion | |
| //#region ../node_modules/property-information/index.js | |
| var html$1 = merge([ | |
| aria, | |
| html$2, | |
| xlink, | |
| xmlns, | |
| xml | |
| ], "html"); | |
| var svg = merge([ | |
| aria, | |
| svg$1, | |
| xlink, | |
| xmlns, | |
| xml | |
| ], "svg"); | |
| //#endregion | |
| //#region ../node_modules/space-separated-tokens/index.js | |
| /** | |
| * Serialize an array of strings as space separated-tokens. | |
| * | |
| * @param {Array<string|number>} values | |
| * List of tokens. | |
| * @returns {string} | |
| * Space-separated tokens. | |
| */ | |
| function stringify(values) { | |
| return values.join(" ").trim(); | |
| } | |
| //#endregion | |
| //#region ../node_modules/inline-style-parser/cjs/index.js | |
| var require_cjs$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => { | |
| var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g; | |
| var NEWLINE_REGEX = /\n/g; | |
| var WHITESPACE_REGEX = /^\s*/; | |
| var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/; | |
| var COLON_REGEX = /^:\s*/; | |
| var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/; | |
| var SEMICOLON_REGEX = /^[;\s]*/; | |
| var TRIM_REGEX = /^\s+|\s+$/g; | |
| var NEWLINE = "\n"; | |
| var FORWARD_SLASH = "/"; | |
| var ASTERISK = "*"; | |
| var EMPTY_STRING = ""; | |
| var TYPE_COMMENT = "comment"; | |
| var TYPE_DECLARATION = "declaration"; | |
| /** | |
| * @param {String} style | |
| * @param {Object} [options] | |
| * @return {Object[]} | |
| * @throws {TypeError} | |
| * @throws {Error} | |
| */ | |
| function index(style, options) { | |
| if (typeof style !== "string") throw new TypeError("First argument must be a string"); | |
| if (!style) return []; | |
| options = options || {}; | |
| /** | |
| * Positional. | |
| */ | |
| var lineno = 1; | |
| var column = 1; | |
| /** | |
| * Update lineno and column based on `str`. | |
| * | |
| * @param {String} str | |
| */ | |
| function updatePosition(str) { | |
| var lines = str.match(NEWLINE_REGEX); | |
| if (lines) lineno += lines.length; | |
| var i = str.lastIndexOf(NEWLINE); | |
| column = ~i ? str.length - i : column + str.length; | |
| } | |
| /** | |
| * Mark position and patch `node.position`. | |
| * | |
| * @return {Function} | |
| */ | |
| function position() { | |
| var start = { | |
| line: lineno, | |
| column | |
| }; | |
| return function(node) { | |
| node.position = new Position(start); | |
| whitespace(); | |
| return node; | |
| }; | |
| } | |
| /** | |
| * Store position information for a node. | |
| * | |
| * @constructor | |
| * @property {Object} start | |
| * @property {Object} end | |
| * @property {undefined|String} source | |
| */ | |
| function Position(start) { | |
| this.start = start; | |
| this.end = { | |
| line: lineno, | |
| column | |
| }; | |
| this.source = options.source; | |
| } | |
| /** | |
| * Non-enumerable source string. | |
| */ | |
| Position.prototype.content = style; | |
| /** | |
| * Error `msg`. | |
| * | |
| * @param {String} msg | |
| * @throws {Error} | |
| */ | |
| function error(msg) { | |
| var err = /* @__PURE__ */ new Error(options.source + ":" + lineno + ":" + column + ": " + msg); | |
| err.reason = msg; | |
| err.filename = options.source; | |
| err.line = lineno; | |
| err.column = column; | |
| err.source = style; | |
| if (options.silent); | |
| else throw err; | |
| } | |
| /** | |
| * Match `re` and return captures. | |
| * | |
| * @param {RegExp} re | |
| * @return {undefined|Array} | |
| */ | |
| function match(re) { | |
| var m = re.exec(style); | |
| if (!m) return; | |
| var str = m[0]; | |
| updatePosition(str); | |
| style = style.slice(str.length); | |
| return m; | |
| } | |
| /** | |
| * Parse whitespace. | |
| */ | |
| function whitespace() { | |
| match(WHITESPACE_REGEX); | |
| } | |
| /** | |
| * Parse comments. | |
| * | |
| * @param {Object[]} [rules] | |
| * @return {Object[]} | |
| */ | |
| function comments(rules) { | |
| var c; | |
| rules = rules || []; | |
| while (c = comment()) if (c !== false) rules.push(c); | |
| return rules; | |
| } | |
| /** | |
| * Parse comment. | |
| * | |
| * @return {Object} | |
| * @throws {Error} | |
| */ | |
| function comment() { | |
| var pos = position(); | |
| if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return; | |
| var i = 2; | |
| while (EMPTY_STRING != style.charAt(i) && (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))) ++i; | |
| i += 2; | |
| if (EMPTY_STRING === style.charAt(i - 1)) return error("End of comment missing"); | |
| var str = style.slice(2, i - 2); | |
| column += 2; | |
| updatePosition(str); | |
| style = style.slice(i); | |
| column += 2; | |
| return pos({ | |
| type: TYPE_COMMENT, | |
| comment: str | |
| }); | |
| } | |
| /** | |
| * Parse declaration. | |
| * | |
| * @return {Object} | |
| * @throws {Error} | |
| */ | |
| function declaration() { | |
| var pos = position(); | |
| var prop = match(PROPERTY_REGEX); | |
| if (!prop) return; | |
| comment(); | |
| if (!match(COLON_REGEX)) return error("property missing ':'"); | |
| var val = match(VALUE_REGEX); | |
| var ret = pos({ | |
| type: TYPE_DECLARATION, | |
| property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)), | |
| value: val ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING)) : EMPTY_STRING | |
| }); | |
| match(SEMICOLON_REGEX); | |
| return ret; | |
| } | |
| /** | |
| * Parse declarations. | |
| * | |
| * @return {Object[]} | |
| */ | |
| function declarations() { | |
| var decls = []; | |
| comments(decls); | |
| var decl; | |
| while (decl = declaration()) if (decl !== false) { | |
| decls.push(decl); | |
| comments(decls); | |
| } | |
| return decls; | |
| } | |
| whitespace(); | |
| return declarations(); | |
| } | |
| /** | |
| * Trim `str`. | |
| * | |
| * @param {String} str | |
| * @return {String} | |
| */ | |
| function trim(str) { | |
| return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING; | |
| } | |
| module.exports = index; | |
| })); | |
| //#endregion | |
| //#region ../node_modules/style-to-object/cjs/index.js | |
| var require_cjs$1 = /* @__PURE__ */ __commonJSMin(((exports) => { | |
| var __importDefault = exports && exports.__importDefault || function(mod) { | |
| return mod && mod.__esModule ? mod : { "default": mod }; | |
| }; | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| exports.default = StyleToObject; | |
| var inline_style_parser_1 = __importDefault(require_cjs$2()); | |
| /** | |
| * Parses inline style to object. | |
| * | |
| * @param style - Inline style. | |
| * @param iterator - Iterator. | |
| * @returns - Style object or null. | |
| * | |
| * @example Parsing inline style to object: | |
| * | |
| * ```js | |
| * import parse from 'style-to-object'; | |
| * parse('line-height: 42;'); // { 'line-height': '42' } | |
| * ``` | |
| */ | |
| function StyleToObject(style, iterator) { | |
| let styleObject = null; | |
| if (!style || typeof style !== "string") return styleObject; | |
| const declarations = (0, inline_style_parser_1.default)(style); | |
| const hasIterator = typeof iterator === "function"; | |
| declarations.forEach((declaration) => { | |
| if (declaration.type !== "declaration") return; | |
| const { property, value } = declaration; | |
| if (hasIterator) iterator(property, value, declaration); | |
| else if (value) { | |
| styleObject = styleObject || {}; | |
| styleObject[property] = value; | |
| } | |
| }); | |
| return styleObject; | |
| } | |
| })); | |
| //#endregion | |
| //#region ../node_modules/style-to-js/cjs/utilities.js | |
| var require_utilities = /* @__PURE__ */ __commonJSMin(((exports) => { | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| exports.camelCase = void 0; | |
| var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9_-]+$/; | |
| var HYPHEN_REGEX = /-([a-z])/g; | |
| var NO_HYPHEN_REGEX = /^[^-]+$/; | |
| var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/; | |
| var MS_VENDOR_PREFIX_REGEX = /^-(ms)-/; | |
| /** | |
| * Checks whether to skip camelCase. | |
| */ | |
| var skipCamelCase = function(property) { | |
| return !property || NO_HYPHEN_REGEX.test(property) || CUSTOM_PROPERTY_REGEX.test(property); | |
| }; | |
| /** | |
| * Replacer that capitalizes first character. | |
| */ | |
| var capitalize = function(match, character) { | |
| return character.toUpperCase(); | |
| }; | |
| /** | |
| * Replacer that removes beginning hyphen of vendor prefix property. | |
| */ | |
| var trimHyphen = function(match, prefix) { | |
| return "".concat(prefix, "-"); | |
| }; | |
| /** | |
| * CamelCases a CSS property. | |
| */ | |
| var camelCase = function(property, options) { | |
| if (options === void 0) options = {}; | |
| if (skipCamelCase(property)) return property; | |
| property = property.toLowerCase(); | |
| if (options.reactCompat) property = property.replace(MS_VENDOR_PREFIX_REGEX, trimHyphen); | |
| else property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen); | |
| return property.replace(HYPHEN_REGEX, capitalize); | |
| }; | |
| exports.camelCase = camelCase; | |
| })); | |
| //#endregion | |
| //#region ../node_modules/style-to-js/cjs/index.js | |
| var require_cjs = /* @__PURE__ */ __commonJSMin(((exports, module) => { | |
| var style_to_object_1 = (exports && exports.__importDefault || function(mod) { | |
| return mod && mod.__esModule ? mod : { "default": mod }; | |
| })(require_cjs$1()); | |
| var utilities_1 = require_utilities(); | |
| /** | |
| * Parses CSS inline style to JavaScript object (camelCased). | |
| */ | |
| function StyleToJS(style, options) { | |
| var output = {}; | |
| if (!style || typeof style !== "string") return output; | |
| (0, style_to_object_1.default)(style, function(property, value) { | |
| if (property && value) output[(0, utilities_1.camelCase)(property, options)] = value; | |
| }); | |
| return output; | |
| } | |
| StyleToJS.default = StyleToJS; | |
| module.exports = StyleToJS; | |
| })); | |
| //#endregion | |
| //#region ../node_modules/unist-util-position/lib/index.js | |
| /** | |
| * @typedef {import('unist').Node} Node | |
| * @typedef {import('unist').Point} Point | |
| * @typedef {import('unist').Position} Position | |
| */ | |
| /** | |
| * @typedef NodeLike | |
| * @property {string} type | |
| * @property {PositionLike | null | undefined} [position] | |
| * | |
| * @typedef PositionLike | |
| * @property {PointLike | null | undefined} [start] | |
| * @property {PointLike | null | undefined} [end] | |
| * | |
| * @typedef PointLike | |
| * @property {number | null | undefined} [line] | |
| * @property {number | null | undefined} [column] | |
| * @property {number | null | undefined} [offset] | |
| */ | |
| /** | |
| * Get the ending point of `node`. | |
| * | |
| * @param node | |
| * Node. | |
| * @returns | |
| * Point. | |
| */ | |
| var pointEnd = point$2("end"); | |
| /** | |
| * Get the starting point of `node`. | |
| * | |
| * @param node | |
| * Node. | |
| * @returns | |
| * Point. | |
| */ | |
| var pointStart = point$2("start"); | |
| /** | |
| * Get the positional info of `node`. | |
| * | |
| * @param {'end' | 'start'} type | |
| * Side. | |
| * @returns | |
| * Getter. | |
| */ | |
| function point$2(type) { | |
| return point; | |
| /** | |
| * Get the point info of `node` at a bound side. | |
| * | |
| * @param {Node | NodeLike | null | undefined} [node] | |
| * @returns {Point | undefined} | |
| */ | |
| function point(node) { | |
| const point = node && node.position && node.position[type] || {}; | |
| if (typeof point.line === "number" && point.line > 0 && typeof point.column === "number" && point.column > 0) return { | |
| line: point.line, | |
| column: point.column, | |
| offset: typeof point.offset === "number" && point.offset > -1 ? point.offset : void 0 | |
| }; | |
| } | |
| } | |
| /** | |
| * Get the positional info of `node`. | |
| * | |
| * @param {Node | NodeLike | null | undefined} [node] | |
| * Node. | |
| * @returns {Position | undefined} | |
| * Position. | |
| */ | |
| function position$1(node) { | |
| const start = pointStart(node); | |
| const end = pointEnd(node); | |
| if (start && end) return { | |
| start, | |
| end | |
| }; | |
| } | |
| //#endregion | |
| //#region ../node_modules/unist-util-stringify-position/lib/index.js | |
| /** | |
| * @typedef {import('unist').Node} Node | |
| * @typedef {import('unist').Point} Point | |
| * @typedef {import('unist').Position} Position | |
| */ | |
| /** | |
| * @typedef NodeLike | |
| * @property {string} type | |
| * @property {PositionLike | null | undefined} [position] | |
| * | |
| * @typedef PointLike | |
| * @property {number | null | undefined} [line] | |
| * @property {number | null | undefined} [column] | |
| * @property {number | null | undefined} [offset] | |
| * | |
| * @typedef PositionLike | |
| * @property {PointLike | null | undefined} [start] | |
| * @property {PointLike | null | undefined} [end] | |
| */ | |
| /** | |
| * Serialize the positional info of a point, position (start and end points), | |
| * or node. | |
| * | |
| * @param {Node | NodeLike | Point | PointLike | Position | PositionLike | null | undefined} [value] | |
| * Node, position, or point. | |
| * @returns {string} | |
| * Pretty printed positional info of a node (`string`). | |
| * | |
| * In the format of a range `ls:cs-le:ce` (when given `node` or `position`) | |
| * or a point `l:c` (when given `point`), where `l` stands for line, `c` for | |
| * column, `s` for `start`, and `e` for end. | |
| * An empty string (`''`) is returned if the given value is neither `node`, | |
| * `position`, nor `point`. | |
| */ | |
| function stringifyPosition(value) { | |
| if (!value || typeof value !== "object") return ""; | |
| if ("position" in value || "type" in value) return position(value.position); | |
| if ("start" in value || "end" in value) return position(value); | |
| if ("line" in value || "column" in value) return point$1(value); | |
| return ""; | |
| } | |
| /** | |
| * @param {Point | PointLike | null | undefined} point | |
| * @returns {string} | |
| */ | |
| function point$1(point) { | |
| return index(point && point.line) + ":" + index(point && point.column); | |
| } | |
| /** | |
| * @param {Position | PositionLike | null | undefined} pos | |
| * @returns {string} | |
| */ | |
| function position(pos) { | |
| return point$1(pos && pos.start) + "-" + point$1(pos && pos.end); | |
| } | |
| /** | |
| * @param {number | null | undefined} value | |
| * @returns {number} | |
| */ | |
| function index(value) { | |
| return value && typeof value === "number" ? value : 1; | |
| } | |
| //#endregion | |
| //#region ../node_modules/vfile-message/lib/index.js | |
| /** | |
| * @import {Node, Point, Position} from 'unist' | |
| */ | |
| /** | |
| * @typedef {object & {type: string, position?: Position | undefined}} NodeLike | |
| * | |
| * @typedef Options | |
| * Configuration. | |
| * @property {Array<Node> | null | undefined} [ancestors] | |
| * Stack of (inclusive) ancestor nodes surrounding the message (optional). | |
| * @property {Error | null | undefined} [cause] | |
| * Original error cause of the message (optional). | |
| * @property {Point | Position | null | undefined} [place] | |
| * Place of message (optional). | |
| * @property {string | null | undefined} [ruleId] | |
| * Category of message (optional, example: `'my-rule'`). | |
| * @property {string | null | undefined} [source] | |
| * Namespace of who sent the message (optional, example: `'my-package'`). | |
| */ | |
| /** | |
| * Message. | |
| */ | |
| var VFileMessage = class extends Error { | |
| /** | |
| * Create a message for `reason`. | |
| * | |
| * > 🪦 **Note**: also has obsolete signatures. | |
| * | |
| * @overload | |
| * @param {string} reason | |
| * @param {Options | null | undefined} [options] | |
| * @returns | |
| * | |
| * @overload | |
| * @param {string} reason | |
| * @param {Node | NodeLike | null | undefined} parent | |
| * @param {string | null | undefined} [origin] | |
| * @returns | |
| * | |
| * @overload | |
| * @param {string} reason | |
| * @param {Point | Position | null | undefined} place | |
| * @param {string | null | undefined} [origin] | |
| * @returns | |
| * | |
| * @overload | |
| * @param {string} reason | |
| * @param {string | null | undefined} [origin] | |
| * @returns | |
| * | |
| * @overload | |
| * @param {Error | VFileMessage} cause | |
| * @param {Node | NodeLike | null | undefined} parent | |
| * @param {string | null | undefined} [origin] | |
| * @returns | |
| * | |
| * @overload | |
| * @param {Error | VFileMessage} cause | |
| * @param {Point | Position | null | undefined} place | |
| * @param {string | null | undefined} [origin] | |
| * @returns | |
| * | |
| * @overload | |
| * @param {Error | VFileMessage} cause | |
| * @param {string | null | undefined} [origin] | |
| * @returns | |
| * | |
| * @param {Error | VFileMessage | string} causeOrReason | |
| * Reason for message, should use markdown. | |
| * @param {Node | NodeLike | Options | 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 | |
| * Instance of `VFileMessage`. | |
| */ | |
| constructor(causeOrReason, optionsOrParentOrPlace, origin) { | |
| super(); | |
| if (typeof optionsOrParentOrPlace === "string") { | |
| origin = optionsOrParentOrPlace; | |
| optionsOrParentOrPlace = void 0; | |
| } | |
| /** @type {string} */ | |
| let reason = ""; | |
| /** @type {Options} */ | |
| let options = {}; | |
| let legacyCause = false; | |
| if (optionsOrParentOrPlace) if ("line" in optionsOrParentOrPlace && "column" in optionsOrParentOrPlace) options = { place: optionsOrParentOrPlace }; | |
| else if ("start" in optionsOrParentOrPlace && "end" in optionsOrParentOrPlace) options = { place: optionsOrParentOrPlace }; | |
| else if ("type" in optionsOrParentOrPlace) options = { | |
| ancestors: [optionsOrParentOrPlace], | |
| place: optionsOrParentOrPlace.position | |
| }; | |
| else options = { ...optionsOrParentOrPlace }; | |
| if (typeof causeOrReason === "string") reason = causeOrReason; | |
| else if (!options.cause && causeOrReason) { | |
| legacyCause = true; | |
| reason = causeOrReason.message; | |
| options.cause = causeOrReason; | |
| } | |
| if (!options.ruleId && !options.source && typeof origin === "string") { | |
| const index = origin.indexOf(":"); | |
| if (index === -1) options.ruleId = origin; | |
| else { | |
| options.source = origin.slice(0, index); | |
| options.ruleId = origin.slice(index + 1); | |
| } | |
| } | |
| if (!options.place && options.ancestors && options.ancestors) { | |
| const parent = options.ancestors[options.ancestors.length - 1]; | |
| if (parent) options.place = parent.position; | |
| } | |
| const start = options.place && "start" in options.place ? options.place.start : options.place; | |
| /** | |
| * Stack of ancestor nodes surrounding the message. | |
| * | |
| * @type {Array<Node> | undefined} | |
| */ | |
| this.ancestors = options.ancestors || void 0; | |
| /** | |
| * Original error cause of the message. | |
| * | |
| * @type {Error | undefined} | |
| */ | |
| this.cause = options.cause || void 0; | |
| /** | |
| * Starting column of message. | |
| * | |
| * @type {number | undefined} | |
| */ | |
| this.column = start ? start.column : void 0; | |
| /** | |
| * State of problem. | |
| * | |
| * * `true` — error, file not usable | |
| * * `false` — warning, change may be needed | |
| * * `undefined` — change likely not needed | |
| * | |
| * @type {boolean | null | undefined} | |
| */ | |
| this.fatal = void 0; | |
| /** | |
| * Path of a file (used throughout the `VFile` ecosystem). | |
| * | |
| * @type {string | undefined} | |
| */ | |
| this.file = ""; | |
| /** | |
| * Reason for message. | |
| * | |
| * @type {string} | |
| */ | |
| this.message = reason; | |
| /** | |
| * Starting line of error. | |
| * | |
| * @type {number | undefined} | |
| */ | |
| this.line = start ? start.line : void 0; | |
| /** | |
| * Serialized positional info of message. | |
| * | |
| * On normal errors, this would be something like `ParseError`, buit in | |
| * `VFile` messages we use this space to show where an error happened. | |
| */ | |
| this.name = stringifyPosition(options.place) || "1:1"; | |
| /** | |
| * Place of message. | |
| * | |
| * @type {Point | Position | undefined} | |
| */ | |
| this.place = options.place || void 0; | |
| /** | |
| * Reason for message, should use markdown. | |
| * | |
| * @type {string} | |
| */ | |
| this.reason = this.message; | |
| /** | |
| * Category of message (example: `'my-rule'`). | |
| * | |
| * @type {string | undefined} | |
| */ | |
| this.ruleId = options.ruleId || void 0; | |
| /** | |
| * Namespace of message (example: `'my-package'`). | |
| * | |
| * @type {string | undefined} | |
| */ | |
| this.source = options.source || void 0; | |
| /** | |
| * Stack of message. | |
| * | |
| * This is used by normal errors to show where something happened in | |
| * programming code, irrelevant for `VFile` messages, | |
| * | |
| * @type {string} | |
| */ | |
| this.stack = legacyCause && options.cause && typeof options.cause.stack === "string" ? options.cause.stack : ""; | |
| /** | |
| * Specify the source value that’s being reported, which is deemed | |
| * incorrect. | |
| * | |
| * @type {string | undefined} | |
| */ | |
| this.actual = void 0; | |
| /** | |
| * Suggest acceptable values that can be used instead of `actual`. | |
| * | |
| * @type {Array<string> | undefined} | |
| */ | |
| this.expected = void 0; | |
| /** | |
| * Long form description of the message (you should use markdown). | |
| * | |
| * @type {string | undefined} | |
| */ | |
| this.note = void 0; | |
| /** | |
| * Link to docs for the message. | |
| * | |
| * > 👉 **Note**: this must be an absolute URL that can be passed as `x` | |
| * > to `new URL(x)`. | |
| * | |
| * @type {string | undefined} | |
| */ | |
| this.url = void 0; | |
| } | |
| }; | |
| VFileMessage.prototype.file = ""; | |
| VFileMessage.prototype.name = ""; | |
| VFileMessage.prototype.reason = ""; | |
| VFileMessage.prototype.message = ""; | |
| VFileMessage.prototype.stack = ""; | |
| VFileMessage.prototype.column = void 0; | |
| VFileMessage.prototype.line = void 0; | |
| VFileMessage.prototype.ancestors = void 0; | |
| VFileMessage.prototype.cause = void 0; | |
| VFileMessage.prototype.fatal = void 0; | |
| VFileMessage.prototype.place = void 0; | |
| VFileMessage.prototype.ruleId = void 0; | |
| VFileMessage.prototype.source = void 0; | |
| //#endregion | |
| //#region ../node_modules/hast-util-to-jsx-runtime/lib/index.js | |
| /** | |
| * @import {Identifier, Literal, MemberExpression} from 'estree' | |
| * @import {Jsx, JsxDev, Options, Props} from 'hast-util-to-jsx-runtime' | |
| * @import {Element, Nodes, Parents, Root, Text} from 'hast' | |
| * @import {MdxFlowExpressionHast, MdxTextExpressionHast} from 'mdast-util-mdx-expression' | |
| * @import {MdxJsxFlowElementHast, MdxJsxTextElementHast} from 'mdast-util-mdx-jsx' | |
| * @import {MdxjsEsmHast} from 'mdast-util-mdxjs-esm' | |
| * @import {Position} from 'unist' | |
| * @import {Child, Create, Field, JsxElement, State, Style} from './types.js' | |
| */ | |
| var import_cjs = /* @__PURE__ */ __toESM(require_cjs(), 1); | |
| var own$3 = {}.hasOwnProperty; | |
| /** @type {Map<string, number>} */ | |
| var emptyMap = /* @__PURE__ */ new Map(); | |
| var cap = /[A-Z]/g; | |
| var tableElements = new Set([ | |
| "table", | |
| "tbody", | |
| "thead", | |
| "tfoot", | |
| "tr" | |
| ]); | |
| var tableCellElement = new Set(["td", "th"]); | |
| /** | |
| * Transform a hast tree to preact, react, solid, svelte, vue, etc., | |
| * with an automatic JSX runtime. | |
| * | |
| * @param {Nodes} tree | |
| * Tree to transform. | |
| * @param {Options} options | |
| * Configuration (required). | |
| * @returns {JsxElement} | |
| * JSX element. | |
| */ | |
| function toJsxRuntime(tree, options) { | |
| if (!options || options.Fragment === void 0) throw new TypeError("Expected `Fragment` in options"); | |
| const filePath = options.filePath || void 0; | |
| /** @type {Create} */ | |
| let create; | |
| if (options.development) { | |
| if (typeof options.jsxDEV !== "function") throw new TypeError("Expected `jsxDEV` in options when `development: true`"); | |
| create = developmentCreate(filePath, options.jsxDEV); | |
| } else { | |
| if (typeof options.jsx !== "function") throw new TypeError("Expected `jsx` in production options"); | |
| if (typeof options.jsxs !== "function") throw new TypeError("Expected `jsxs` in production options"); | |
| create = productionCreate(filePath, options.jsx, options.jsxs); | |
| } | |
| /** @type {State} */ | |
| const state = { | |
| Fragment: options.Fragment, | |
| ancestors: [], | |
| components: options.components || {}, | |
| create, | |
| elementAttributeNameCase: options.elementAttributeNameCase || "react", | |
| evaluater: options.createEvaluater ? options.createEvaluater() : void 0, | |
| filePath, | |
| ignoreInvalidStyle: options.ignoreInvalidStyle || false, | |
| passKeys: options.passKeys !== false, | |
| passNode: options.passNode || false, | |
| schema: options.space === "svg" ? svg : html$1, | |
| stylePropertyNameCase: options.stylePropertyNameCase || "dom", | |
| tableCellAlignToStyle: options.tableCellAlignToStyle !== false | |
| }; | |
| const result = one(state, tree, void 0); | |
| if (result && typeof result !== "string") return result; | |
| return state.create(tree, state.Fragment, { children: result || void 0 }, void 0); | |
| } | |
| /** | |
| * Transform a node. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Nodes} node | |
| * Current node. | |
| * @param {string | undefined} key | |
| * Key. | |
| * @returns {Child | undefined} | |
| * Child, optional. | |
| */ | |
| function one(state, node, key) { | |
| if (node.type === "element") return element$1(state, node, key); | |
| if (node.type === "mdxFlowExpression" || node.type === "mdxTextExpression") return mdxExpression(state, node); | |
| if (node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") return mdxJsxElement(state, node, key); | |
| if (node.type === "mdxjsEsm") return mdxEsm(state, node); | |
| if (node.type === "root") return root$1(state, node, key); | |
| if (node.type === "text") return text$3(state, node); | |
| } | |
| /** | |
| * Handle element. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Element} node | |
| * Current node. | |
| * @param {string | undefined} key | |
| * Key. | |
| * @returns {Child | undefined} | |
| * Child, optional. | |
| */ | |
| function element$1(state, node, key) { | |
| const parentSchema = state.schema; | |
| let schema = parentSchema; | |
| if (node.tagName.toLowerCase() === "svg" && parentSchema.space === "html") { | |
| schema = svg; | |
| state.schema = schema; | |
| } | |
| state.ancestors.push(node); | |
| const type = findComponentFromName(state, node.tagName, false); | |
| const props = createElementProps(state, node); | |
| let children = createChildren(state, node); | |
| if (tableElements.has(node.tagName)) children = children.filter(function(child) { | |
| return typeof child === "string" ? !whitespace(child) : true; | |
| }); | |
| addNode(state, props, type, node); | |
| addChildren(props, children); | |
| state.ancestors.pop(); | |
| state.schema = parentSchema; | |
| return state.create(node, type, props, key); | |
| } | |
| /** | |
| * Handle MDX expression. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {MdxFlowExpressionHast | MdxTextExpressionHast} node | |
| * Current node. | |
| * @returns {Child | undefined} | |
| * Child, optional. | |
| */ | |
| function mdxExpression(state, node) { | |
| if (node.data && node.data.estree && state.evaluater) { | |
| const expression = node.data.estree.body[0]; | |
| ok(expression.type === "ExpressionStatement"); | |
| return state.evaluater.evaluateExpression(expression.expression); | |
| } | |
| crashEstree(state, node.position); | |
| } | |
| /** | |
| * Handle MDX ESM. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {MdxjsEsmHast} node | |
| * Current node. | |
| * @returns {Child | undefined} | |
| * Child, optional. | |
| */ | |
| function mdxEsm(state, node) { | |
| if (node.data && node.data.estree && state.evaluater) return state.evaluater.evaluateProgram(node.data.estree); | |
| crashEstree(state, node.position); | |
| } | |
| /** | |
| * Handle MDX JSX. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {MdxJsxFlowElementHast | MdxJsxTextElementHast} node | |
| * Current node. | |
| * @param {string | undefined} key | |
| * Key. | |
| * @returns {Child | undefined} | |
| * Child, optional. | |
| */ | |
| function mdxJsxElement(state, node, key) { | |
| const parentSchema = state.schema; | |
| let schema = parentSchema; | |
| if (node.name === "svg" && parentSchema.space === "html") { | |
| schema = svg; | |
| state.schema = schema; | |
| } | |
| state.ancestors.push(node); | |
| const type = node.name === null ? state.Fragment : findComponentFromName(state, node.name, true); | |
| const props = createJsxElementProps(state, node); | |
| const children = createChildren(state, node); | |
| addNode(state, props, type, node); | |
| addChildren(props, children); | |
| state.ancestors.pop(); | |
| state.schema = parentSchema; | |
| return state.create(node, type, props, key); | |
| } | |
| /** | |
| * Handle root. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Root} node | |
| * Current node. | |
| * @param {string | undefined} key | |
| * Key. | |
| * @returns {Child | undefined} | |
| * Child, optional. | |
| */ | |
| function root$1(state, node, key) { | |
| /** @type {Props} */ | |
| const props = {}; | |
| addChildren(props, createChildren(state, node)); | |
| return state.create(node, state.Fragment, props, key); | |
| } | |
| /** | |
| * Handle text. | |
| * | |
| * @param {State} _ | |
| * Info passed around. | |
| * @param {Text} node | |
| * Current node. | |
| * @returns {Child | undefined} | |
| * Child, optional. | |
| */ | |
| function text$3(_, node) { | |
| return node.value; | |
| } | |
| /** | |
| * Add `node` to props. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Props} props | |
| * Props. | |
| * @param {unknown} type | |
| * Type. | |
| * @param {Element | MdxJsxFlowElementHast | MdxJsxTextElementHast} node | |
| * Node. | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| function addNode(state, props, type, node) { | |
| if (typeof type !== "string" && type !== state.Fragment && state.passNode) props.node = node; | |
| } | |
| /** | |
| * Add children to props. | |
| * | |
| * @param {Props} props | |
| * Props. | |
| * @param {Array<Child>} children | |
| * Children. | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| function addChildren(props, children) { | |
| if (children.length > 0) { | |
| const value = children.length > 1 ? children : children[0]; | |
| if (value) props.children = value; | |
| } | |
| } | |
| /** | |
| * @param {string | undefined} _ | |
| * Path to file. | |
| * @param {Jsx} jsx | |
| * Dynamic. | |
| * @param {Jsx} jsxs | |
| * Static. | |
| * @returns {Create} | |
| * Create a production element. | |
| */ | |
| function productionCreate(_, jsx, jsxs) { | |
| return create; | |
| /** @type {Create} */ | |
| function create(_, type, props, key) { | |
| const fn = Array.isArray(props.children) ? jsxs : jsx; | |
| return key ? fn(type, props, key) : fn(type, props); | |
| } | |
| } | |
| /** | |
| * @param {string | undefined} filePath | |
| * Path to file. | |
| * @param {JsxDev} jsxDEV | |
| * Development. | |
| * @returns {Create} | |
| * Create a development element. | |
| */ | |
| function developmentCreate(filePath, jsxDEV) { | |
| return create; | |
| /** @type {Create} */ | |
| function create(node, type, props, key) { | |
| const isStaticChildren = Array.isArray(props.children); | |
| const point = pointStart(node); | |
| return jsxDEV(type, props, key, isStaticChildren, { | |
| columnNumber: point ? point.column - 1 : void 0, | |
| fileName: filePath, | |
| lineNumber: point ? point.line : void 0 | |
| }, void 0); | |
| } | |
| } | |
| /** | |
| * Create props from an element. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Element} node | |
| * Current element. | |
| * @returns {Props} | |
| * Props. | |
| */ | |
| function createElementProps(state, node) { | |
| /** @type {Props} */ | |
| const props = {}; | |
| /** @type {string | undefined} */ | |
| let alignValue; | |
| /** @type {string} */ | |
| let prop; | |
| for (prop in node.properties) if (prop !== "children" && own$3.call(node.properties, prop)) { | |
| const result = createProperty(state, prop, node.properties[prop]); | |
| if (result) { | |
| const [key, value] = result; | |
| if (state.tableCellAlignToStyle && key === "align" && typeof value === "string" && tableCellElement.has(node.tagName)) alignValue = value; | |
| else props[key] = value; | |
| } | |
| } | |
| if (alignValue) { | |
| const style = props.style || (props.style = {}); | |
| style[state.stylePropertyNameCase === "css" ? "text-align" : "textAlign"] = alignValue; | |
| } | |
| return props; | |
| } | |
| /** | |
| * Create props from a JSX element. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {MdxJsxFlowElementHast | MdxJsxTextElementHast} node | |
| * Current JSX element. | |
| * @returns {Props} | |
| * Props. | |
| */ | |
| function createJsxElementProps(state, node) { | |
| /** @type {Props} */ | |
| const props = {}; | |
| for (const attribute of node.attributes) if (attribute.type === "mdxJsxExpressionAttribute") if (attribute.data && attribute.data.estree && state.evaluater) { | |
| const expression = attribute.data.estree.body[0]; | |
| ok(expression.type === "ExpressionStatement"); | |
| const objectExpression = expression.expression; | |
| ok(objectExpression.type === "ObjectExpression"); | |
| const property = objectExpression.properties[0]; | |
| ok(property.type === "SpreadElement"); | |
| Object.assign(props, state.evaluater.evaluateExpression(property.argument)); | |
| } else crashEstree(state, node.position); | |
| else { | |
| const name = attribute.name; | |
| /** @type {unknown} */ | |
| let value; | |
| if (attribute.value && typeof attribute.value === "object") if (attribute.value.data && attribute.value.data.estree && state.evaluater) { | |
| const expression = attribute.value.data.estree.body[0]; | |
| ok(expression.type === "ExpressionStatement"); | |
| value = state.evaluater.evaluateExpression(expression.expression); | |
| } else crashEstree(state, node.position); | |
| else value = attribute.value === null ? true : attribute.value; | |
| props[name] = value; | |
| } | |
| return props; | |
| } | |
| /** | |
| * Create children. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Parents} node | |
| * Current element. | |
| * @returns {Array<Child>} | |
| * Children. | |
| */ | |
| function createChildren(state, node) { | |
| /** @type {Array<Child>} */ | |
| const children = []; | |
| let index = -1; | |
| /** @type {Map<string, number>} */ | |
| /* c8 ignore next */ | |
| const countsByName = state.passKeys ? /* @__PURE__ */ new Map() : emptyMap; | |
| while (++index < node.children.length) { | |
| const child = node.children[index]; | |
| /** @type {string | undefined} */ | |
| let key; | |
| if (state.passKeys) { | |
| const name = child.type === "element" ? child.tagName : child.type === "mdxJsxFlowElement" || child.type === "mdxJsxTextElement" ? child.name : void 0; | |
| if (name) { | |
| const count = countsByName.get(name) || 0; | |
| key = name + "-" + count; | |
| countsByName.set(name, count + 1); | |
| } | |
| } | |
| const result = one(state, child, key); | |
| if (result !== void 0) children.push(result); | |
| } | |
| return children; | |
| } | |
| /** | |
| * Handle a property. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {string} prop | |
| * Key. | |
| * @param {Array<number | string> | boolean | number | string | null | undefined} value | |
| * hast property value. | |
| * @returns {Field | undefined} | |
| * Field for runtime, optional. | |
| */ | |
| function createProperty(state, prop, value) { | |
| const info = find(state.schema, prop); | |
| if (value === null || value === void 0 || typeof value === "number" && Number.isNaN(value)) return; | |
| if (Array.isArray(value)) value = info.commaSeparated ? stringify$1(value) : stringify(value); | |
| if (info.property === "style") { | |
| let styleObject = typeof value === "object" ? value : parseStyle(state, String(value)); | |
| if (state.stylePropertyNameCase === "css") styleObject = transformStylesToCssCasing(styleObject); | |
| return ["style", styleObject]; | |
| } | |
| return [state.elementAttributeNameCase === "react" && info.space ? hastToReact[info.property] || info.property : info.attribute, value]; | |
| } | |
| /** | |
| * Parse a CSS declaration to an object. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {string} value | |
| * CSS declarations. | |
| * @returns {Style} | |
| * Properties. | |
| * @throws | |
| * Throws `VFileMessage` when CSS cannot be parsed. | |
| */ | |
| function parseStyle(state, value) { | |
| try { | |
| return (0, import_cjs.default)(value, { reactCompat: true }); | |
| } catch (error) { | |
| if (state.ignoreInvalidStyle) return {}; | |
| const cause = error; | |
| const message = new VFileMessage("Cannot parse `style` attribute", { | |
| ancestors: state.ancestors, | |
| cause, | |
| ruleId: "style", | |
| source: "hast-util-to-jsx-runtime" | |
| }); | |
| message.file = state.filePath || void 0; | |
| message.url = "https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute"; | |
| throw message; | |
| } | |
| } | |
| /** | |
| * Create a JSX name from a string. | |
| * | |
| * @param {State} state | |
| * To do. | |
| * @param {string} name | |
| * Name. | |
| * @param {boolean} allowExpression | |
| * Allow member expressions and identifiers. | |
| * @returns {unknown} | |
| * To do. | |
| */ | |
| function findComponentFromName(state, name$1, allowExpression) { | |
| /** @type {Identifier | Literal | MemberExpression} */ | |
| let result; | |
| if (!allowExpression) result = { | |
| type: "Literal", | |
| value: name$1 | |
| }; | |
| else if (name$1.includes(".")) { | |
| const identifiers = name$1.split("."); | |
| let index = -1; | |
| /** @type {Identifier | Literal | MemberExpression | undefined} */ | |
| let node; | |
| while (++index < identifiers.length) { | |
| /** @type {Identifier | Literal} */ | |
| const prop = name(identifiers[index]) ? { | |
| type: "Identifier", | |
| name: identifiers[index] | |
| } : { | |
| type: "Literal", | |
| value: identifiers[index] | |
| }; | |
| node = node ? { | |
| type: "MemberExpression", | |
| object: node, | |
| property: prop, | |
| computed: Boolean(index && prop.type === "Literal"), | |
| optional: false | |
| } : prop; | |
| } | |
| ok(node, "always a result"); | |
| result = node; | |
| } else result = name(name$1) && !/^[a-z]/.test(name$1) ? { | |
| type: "Identifier", | |
| name: name$1 | |
| } : { | |
| type: "Literal", | |
| value: name$1 | |
| }; | |
| if (result.type === "Literal") { | |
| const name = result.value; | |
| return own$3.call(state.components, name) ? state.components[name] : name; | |
| } | |
| if (state.evaluater) return state.evaluater.evaluateExpression(result); | |
| crashEstree(state); | |
| } | |
| /** | |
| * @param {State} state | |
| * @param {Position | undefined} [place] | |
| * @returns {never} | |
| */ | |
| function crashEstree(state, place) { | |
| const message = new VFileMessage("Cannot handle MDX estrees without `createEvaluater`", { | |
| ancestors: state.ancestors, | |
| place, | |
| ruleId: "mdx-estree", | |
| source: "hast-util-to-jsx-runtime" | |
| }); | |
| message.file = state.filePath || void 0; | |
| message.url = "https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-handle-mdx-estrees-without-createevaluater"; | |
| throw message; | |
| } | |
| /** | |
| * Transform a DOM casing style object to a CSS casing style object. | |
| * | |
| * @param {Style} domCasing | |
| * @returns {Style} | |
| */ | |
| function transformStylesToCssCasing(domCasing) { | |
| /** @type {Style} */ | |
| const cssCasing = {}; | |
| /** @type {string} */ | |
| let from; | |
| for (from in domCasing) if (own$3.call(domCasing, from)) cssCasing[transformStyleToCssCasing(from)] = domCasing[from]; | |
| return cssCasing; | |
| } | |
| /** | |
| * Transform a DOM casing style field to a CSS casing style field. | |
| * | |
| * @param {string} from | |
| * @returns {string} | |
| */ | |
| function transformStyleToCssCasing(from) { | |
| let to = from.replace(cap, toDash); | |
| if (to.slice(0, 3) === "ms-") to = "-" + to; | |
| return to; | |
| } | |
| /** | |
| * Make `$0` dash cased. | |
| * | |
| * @param {string} $0 | |
| * Capitalized ASCII leter. | |
| * @returns {string} | |
| * Dash and lower letter. | |
| */ | |
| function toDash($0) { | |
| return "-" + $0.toLowerCase(); | |
| } | |
| //#endregion | |
| //#region ../node_modules/html-url-attributes/lib/index.js | |
| /** | |
| * HTML URL properties. | |
| * | |
| * Each key is a property name and each value is a list of tag names it applies | |
| * to or `null` if it applies to all elements. | |
| * | |
| * @type {Record<string, Array<string> | null>} | |
| */ | |
| 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" | |
| ] | |
| }; | |
| //#endregion | |
| //#region ../node_modules/decode-named-character-reference/index.dom.js | |
| var element = document.createElement("i"); | |
| /** | |
| * @param {string} value | |
| * @returns {string | false} | |
| */ | |
| function decodeNamedCharacterReference(value) { | |
| const characterReference = "&" + value + ";"; | |
| element.innerHTML = characterReference; | |
| const character = element.textContent; | |
| if (character.charCodeAt(character.length - 1) === 59 && value !== "semi") return false; | |
| return character === characterReference ? false : character; | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-util-decode-numeric-character-reference/dev/index.js | |
| /** | |
| * Turn the number (in string form as either hexa- or plain decimal) coming from | |
| * a numeric character reference into a character. | |
| * | |
| * Sort of like `String.fromCodePoint(Number.parseInt(value, base))`, but makes | |
| * non-characters and control characters safe. | |
| * | |
| * @param {string} value | |
| * Value to decode. | |
| * @param {number} base | |
| * Numeric base. | |
| * @returns {string} | |
| * Character. | |
| */ | |
| function decodeNumericCharacterReference(value, base) { | |
| const code = Number.parseInt(value, base); | |
| if (code < codes.ht || code === codes.vt || code > codes.cr && code < codes.space || code > codes.tilde && code < 160 || code > 55295 && code < 57344 || code > 64975 && code < 65008 || (code & 65535) === 65535 || (code & 65535) === 65534 || code > 1114111) return values.replacementCharacter; | |
| return String.fromCodePoint(code); | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-util-sanitize-uri/dev/index.js | |
| /** | |
| * Normalize a URL. | |
| * | |
| * Encode unsafe characters with percent-encoding, skipping already encoded | |
| * sequences. | |
| * | |
| * @param {string} value | |
| * URI to normalize. | |
| * @returns {string} | |
| * Normalized URI. | |
| */ | |
| function normalizeUri(value) { | |
| /** @type {Array<string>} */ | |
| const result = []; | |
| let index = -1; | |
| let start = 0; | |
| let skip = 0; | |
| while (++index < value.length) { | |
| const code = value.charCodeAt(index); | |
| /** @type {string} */ | |
| let replace = ""; | |
| if (code === codes.percentSign && asciiAlphanumeric(value.charCodeAt(index + 1)) && asciiAlphanumeric(value.charCodeAt(index + 2))) skip = 2; | |
| else if (code < 128) { | |
| if (!/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code))) replace = String.fromCharCode(code); | |
| } else if (code > 55295 && code < 57344) { | |
| const next = value.charCodeAt(index + 1); | |
| if (code < 56320 && next > 56319 && next < 57344) { | |
| replace = String.fromCharCode(code, next); | |
| skip = 1; | |
| } else replace = values.replacementCharacter; | |
| } else replace = String.fromCharCode(code); | |
| if (replace) { | |
| result.push(value.slice(start, index), encodeURIComponent(replace)); | |
| start = index + skip + 1; | |
| replace = ""; | |
| } | |
| if (skip) { | |
| index += skip; | |
| skip = 0; | |
| } | |
| } | |
| return result.join("") + value.slice(start); | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark/dev/lib/initialize/content.js | |
| /** | |
| * @import { | |
| * InitialConstruct, | |
| * Initializer, | |
| * State, | |
| * TokenizeContext, | |
| * Token | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {InitialConstruct} */ | |
| var content$1 = { tokenize: initializeContent }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Initializer} | |
| * Content. | |
| */ | |
| function initializeContent(effects) { | |
| const contentStart = effects.attempt(this.parser.constructs.contentInitial, afterContentStartConstruct, paragraphInitial); | |
| /** @type {Token} */ | |
| let previous; | |
| return contentStart; | |
| /** @type {State} */ | |
| function afterContentStartConstruct(code) { | |
| ok(code === codes.eof || markdownLineEnding(code), "expected eol or eof"); | |
| if (code === codes.eof) { | |
| effects.consume(code); | |
| return; | |
| } | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| return factorySpace(effects, contentStart, types.linePrefix); | |
| } | |
| /** @type {State} */ | |
| function paragraphInitial(code) { | |
| ok(code !== codes.eof && !markdownLineEnding(code), "expected anything other than a line ending or EOF"); | |
| effects.enter(types.paragraph); | |
| return lineStart(code); | |
| } | |
| /** @type {State} */ | |
| function lineStart(code) { | |
| const token = effects.enter(types.chunkText, { | |
| contentType: constants.contentTypeText, | |
| previous | |
| }); | |
| if (previous) previous.next = token; | |
| previous = token; | |
| return data(code); | |
| } | |
| /** @type {State} */ | |
| function data(code) { | |
| if (code === codes.eof) { | |
| effects.exit(types.chunkText); | |
| effects.exit(types.paragraph); | |
| effects.consume(code); | |
| return; | |
| } | |
| if (markdownLineEnding(code)) { | |
| effects.consume(code); | |
| effects.exit(types.chunkText); | |
| return lineStart; | |
| } | |
| effects.consume(code); | |
| return data; | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark/dev/lib/initialize/document.js | |
| /** | |
| * @import { | |
| * Construct, | |
| * ContainerState, | |
| * InitialConstruct, | |
| * Initializer, | |
| * Point, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer, | |
| * Token | |
| * } from 'micromark-util-types' | |
| */ | |
| /** | |
| * @typedef {[Construct, ContainerState]} StackItem | |
| * Construct and its state. | |
| */ | |
| /** @type {InitialConstruct} */ | |
| var document$2 = { tokenize: initializeDocument }; | |
| /** @type {Construct} */ | |
| var containerConstruct = { tokenize: tokenizeContainer }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Self. | |
| * @type {Initializer} | |
| * Initializer. | |
| */ | |
| function initializeDocument(effects) { | |
| const self = this; | |
| /** @type {Array<StackItem>} */ | |
| const stack = []; | |
| let continued = 0; | |
| /** @type {TokenizeContext | undefined} */ | |
| let childFlow; | |
| /** @type {Token | undefined} */ | |
| let childToken; | |
| /** @type {number} */ | |
| let lineStartOffset; | |
| return start; | |
| /** @type {State} */ | |
| function start(code) { | |
| if (continued < stack.length) { | |
| const item = stack[continued]; | |
| self.containerState = item[1]; | |
| ok(item[0].continuation, "expected `continuation` to be defined on container construct"); | |
| return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code); | |
| } | |
| return checkNewContainers(code); | |
| } | |
| /** @type {State} */ | |
| function documentContinue(code) { | |
| ok(self.containerState, "expected `containerState` to be defined after continuation"); | |
| continued++; | |
| if (self.containerState._closeFlow) { | |
| self.containerState._closeFlow = void 0; | |
| if (childFlow) closeFlow(); | |
| const indexBeforeExits = self.events.length; | |
| let indexBeforeFlow = indexBeforeExits; | |
| /** @type {Point | undefined} */ | |
| let point; | |
| while (indexBeforeFlow--) if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === types.chunkFlow) { | |
| point = self.events[indexBeforeFlow][1].end; | |
| break; | |
| } | |
| ok(point, "could not find previous flow chunk"); | |
| exitContainers(continued); | |
| let index = indexBeforeExits; | |
| while (index < self.events.length) { | |
| self.events[index][1].end = { ...point }; | |
| index++; | |
| } | |
| splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits)); | |
| self.events.length = index; | |
| return checkNewContainers(code); | |
| } | |
| return start(code); | |
| } | |
| /** @type {State} */ | |
| function checkNewContainers(code) { | |
| if (continued === stack.length) { | |
| if (!childFlow) return documentContinued(code); | |
| if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) return flowStart(code); | |
| self.interrupt = Boolean(childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack); | |
| } | |
| self.containerState = {}; | |
| return effects.check(containerConstruct, thereIsANewContainer, thereIsNoNewContainer)(code); | |
| } | |
| /** @type {State} */ | |
| function thereIsANewContainer(code) { | |
| if (childFlow) closeFlow(); | |
| exitContainers(continued); | |
| return documentContinued(code); | |
| } | |
| /** @type {State} */ | |
| function thereIsNoNewContainer(code) { | |
| self.parser.lazy[self.now().line] = continued !== stack.length; | |
| lineStartOffset = self.now().offset; | |
| return flowStart(code); | |
| } | |
| /** @type {State} */ | |
| function documentContinued(code) { | |
| self.containerState = {}; | |
| return effects.attempt(containerConstruct, containerContinue, flowStart)(code); | |
| } | |
| /** @type {State} */ | |
| function containerContinue(code) { | |
| ok(self.currentConstruct, "expected `currentConstruct` to be defined on tokenizer"); | |
| ok(self.containerState, "expected `containerState` to be defined on tokenizer"); | |
| continued++; | |
| stack.push([self.currentConstruct, self.containerState]); | |
| return documentContinued(code); | |
| } | |
| /** @type {State} */ | |
| function flowStart(code) { | |
| if (code === codes.eof) { | |
| if (childFlow) closeFlow(); | |
| exitContainers(0); | |
| effects.consume(code); | |
| return; | |
| } | |
| childFlow = childFlow || self.parser.flow(self.now()); | |
| effects.enter(types.chunkFlow, { | |
| _tokenizer: childFlow, | |
| contentType: constants.contentTypeFlow, | |
| previous: childToken | |
| }); | |
| return flowContinue(code); | |
| } | |
| /** @type {State} */ | |
| function flowContinue(code) { | |
| if (code === codes.eof) { | |
| writeToChild(effects.exit(types.chunkFlow), true); | |
| exitContainers(0); | |
| effects.consume(code); | |
| return; | |
| } | |
| if (markdownLineEnding(code)) { | |
| effects.consume(code); | |
| writeToChild(effects.exit(types.chunkFlow)); | |
| continued = 0; | |
| self.interrupt = void 0; | |
| return start; | |
| } | |
| effects.consume(code); | |
| return flowContinue; | |
| } | |
| /** | |
| * @param {Token} token | |
| * Token. | |
| * @param {boolean | undefined} [endOfFile] | |
| * Whether the token is at the end of the file (default: `false`). | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| function writeToChild(token, endOfFile) { | |
| ok(childFlow, "expected `childFlow` to be defined when continuing"); | |
| 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 (childFlow.events[index][1].start.offset < lineStartOffset && (!childFlow.events[index][1].end || childFlow.events[index][1].end.offset > lineStartOffset)) return; | |
| const indexBeforeExits = self.events.length; | |
| let indexBeforeFlow = indexBeforeExits; | |
| /** @type {boolean | undefined} */ | |
| let seen; | |
| /** @type {Point | undefined} */ | |
| let point; | |
| while (indexBeforeFlow--) if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === types.chunkFlow) { | |
| if (seen) { | |
| point = self.events[indexBeforeFlow][1].end; | |
| break; | |
| } | |
| seen = true; | |
| } | |
| ok(point, "could not find previous flow chunk"); | |
| exitContainers(continued); | |
| index = indexBeforeExits; | |
| while (index < self.events.length) { | |
| self.events[index][1].end = { ...point }; | |
| index++; | |
| } | |
| splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits)); | |
| self.events.length = index; | |
| } | |
| } | |
| /** | |
| * @param {number} size | |
| * Size. | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| function exitContainers(size) { | |
| let index = stack.length; | |
| while (index-- > size) { | |
| const entry = stack[index]; | |
| self.containerState = entry[1]; | |
| ok(entry[0].exit, "expected `exit` to be defined on container construct"); | |
| entry[0].exit.call(self, effects); | |
| } | |
| stack.length = size; | |
| } | |
| function closeFlow() { | |
| ok(self.containerState, "expected `containerState` to be defined when closing flow"); | |
| ok(childFlow, "expected `childFlow` to be defined when closing it"); | |
| childFlow.write([codes.eof]); | |
| childToken = void 0; | |
| childFlow = void 0; | |
| self.containerState._closeFlow = void 0; | |
| } | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| * Tokenizer. | |
| */ | |
| function tokenizeContainer(effects, ok$35, nok) { | |
| ok(this.parser.constructs.disable.null, "expected `disable.null` to be populated"); | |
| return factorySpace(effects, effects.attempt(this.parser.constructs.document, ok$35, nok), types.linePrefix, this.parser.constructs.disable.null.includes("codeIndented") ? void 0 : constants.tabSize); | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/attention.js | |
| /** | |
| * @import { | |
| * Code, | |
| * Construct, | |
| * Event, | |
| * Point, | |
| * Resolver, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer, | |
| * Token | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var attention = { | |
| name: "attention", | |
| resolveAll: resolveAllAttention, | |
| tokenize: tokenizeAttention | |
| }; | |
| /** | |
| * Take all events and resolve attention to emphasis or strong. | |
| * | |
| * @type {Resolver} | |
| */ | |
| function resolveAllAttention(events, context) { | |
| let index = -1; | |
| /** @type {number} */ | |
| let open; | |
| /** @type {Token} */ | |
| let group; | |
| /** @type {Token} */ | |
| let text; | |
| /** @type {Token} */ | |
| let openingSequence; | |
| /** @type {Token} */ | |
| let closingSequence; | |
| /** @type {number} */ | |
| let use; | |
| /** @type {Array<Event>} */ | |
| let nextEvents; | |
| /** @type {number} */ | |
| let offset; | |
| while (++index < events.length) if (events[index][0] === "enter" && events[index][1].type === "attentionSequence" && events[index][1]._close) { | |
| open = index; | |
| while (open--) if (events[open][0] === "exit" && events[open][1].type === "attentionSequence" && events[open][1]._open && context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index][1]).charCodeAt(0)) { | |
| if ((events[open][1]._close || events[index][1]._open) && (events[index][1].end.offset - events[index][1].start.offset) % 3 && !((events[open][1].end.offset - events[open][1].start.offset + events[index][1].end.offset - events[index][1].start.offset) % 3)) continue; | |
| use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index][1].end.offset - events[index][1].start.offset > 1 ? 2 : 1; | |
| const start = { ...events[open][1].end }; | |
| const end = { ...events[index][1].start }; | |
| movePoint(start, -use); | |
| movePoint(end, use); | |
| openingSequence = { | |
| type: use > 1 ? types.strongSequence : types.emphasisSequence, | |
| start, | |
| end: { ...events[open][1].end } | |
| }; | |
| closingSequence = { | |
| type: use > 1 ? types.strongSequence : types.emphasisSequence, | |
| start: { ...events[index][1].start }, | |
| end | |
| }; | |
| text = { | |
| type: use > 1 ? types.strongText : types.emphasisText, | |
| start: { ...events[open][1].end }, | |
| end: { ...events[index][1].start } | |
| }; | |
| group = { | |
| type: use > 1 ? types.strong : types.emphasis, | |
| start: { ...openingSequence.start }, | |
| end: { ...closingSequence.end } | |
| }; | |
| events[open][1].end = { ...openingSequence.start }; | |
| events[index][1].start = { ...closingSequence.end }; | |
| nextEvents = []; | |
| if (events[open][1].end.offset - events[open][1].start.offset) nextEvents = push(nextEvents, [[ | |
| "enter", | |
| events[open][1], | |
| context | |
| ], [ | |
| "exit", | |
| events[open][1], | |
| context | |
| ]]); | |
| nextEvents = push(nextEvents, [ | |
| [ | |
| "enter", | |
| group, | |
| context | |
| ], | |
| [ | |
| "enter", | |
| openingSequence, | |
| context | |
| ], | |
| [ | |
| "exit", | |
| openingSequence, | |
| context | |
| ], | |
| [ | |
| "enter", | |
| text, | |
| context | |
| ] | |
| ]); | |
| ok(context.parser.constructs.insideSpan.null, "expected `insideSpan` to be populated"); | |
| nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index), context)); | |
| nextEvents = push(nextEvents, [ | |
| [ | |
| "exit", | |
| text, | |
| context | |
| ], | |
| [ | |
| "enter", | |
| closingSequence, | |
| context | |
| ], | |
| [ | |
| "exit", | |
| closingSequence, | |
| context | |
| ], | |
| [ | |
| "exit", | |
| group, | |
| context | |
| ] | |
| ]); | |
| if (events[index][1].end.offset - events[index][1].start.offset) { | |
| offset = 2; | |
| nextEvents = push(nextEvents, [[ | |
| "enter", | |
| events[index][1], | |
| context | |
| ], [ | |
| "exit", | |
| events[index][1], | |
| context | |
| ]]); | |
| } else offset = 0; | |
| splice(events, open - 1, index - open + 3, nextEvents); | |
| index = open + nextEvents.length - offset - 2; | |
| break; | |
| } | |
| } | |
| index = -1; | |
| while (++index < events.length) if (events[index][1].type === "attentionSequence") events[index][1].type = "data"; | |
| return events; | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeAttention(effects, ok$34) { | |
| const attentionMarkers = this.parser.constructs.attentionMarkers.null; | |
| const previous = this.previous; | |
| const before = classifyCharacter(previous); | |
| /** @type {NonNullable<Code>} */ | |
| let marker; | |
| return start; | |
| /** | |
| * Before a sequence. | |
| * | |
| * ```markdown | |
| * > | ** | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| ok(code === codes.asterisk || code === codes.underscore, "expected asterisk or underscore"); | |
| marker = code; | |
| effects.enter("attentionSequence"); | |
| return inside(code); | |
| } | |
| /** | |
| * In a sequence. | |
| * | |
| * ```markdown | |
| * > | ** | |
| * ^^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function inside(code) { | |
| if (code === marker) { | |
| effects.consume(code); | |
| return inside; | |
| } | |
| const token = effects.exit("attentionSequence"); | |
| const after = classifyCharacter(code); | |
| ok(attentionMarkers, "expected `attentionMarkers` to be populated"); | |
| const open = !after || after === constants.characterGroupPunctuation && before || attentionMarkers.includes(code); | |
| const close = !before || before === constants.characterGroupPunctuation && after || attentionMarkers.includes(previous); | |
| token._open = Boolean(marker === codes.asterisk ? open : open && (before || !close)); | |
| token._close = Boolean(marker === codes.asterisk ? close : close && (after || !open)); | |
| return ok$34(code); | |
| } | |
| } | |
| /** | |
| * Move a point a bit. | |
| * | |
| * Note: `move` only works inside lines! It’s not possible to move past other | |
| * chunks (replacement characters, tabs, or line endings). | |
| * | |
| * @param {Point} point | |
| * Point. | |
| * @param {number} offset | |
| * Amount to move. | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| function movePoint(point, offset) { | |
| point.column += offset; | |
| point.offset += offset; | |
| point._bufferIndex += offset; | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/autolink.js | |
| /** | |
| * @import { | |
| * Construct, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var autolink = { | |
| name: "autolink", | |
| tokenize: tokenizeAutolink | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeAutolink(effects, ok$33, nok) { | |
| let size = 0; | |
| return start; | |
| /** | |
| * Start of an autolink. | |
| * | |
| * ```markdown | |
| * > | a<https://example.com>b | |
| * ^ | |
| * > | a<user@example.com>b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| ok(code === codes.lessThan, "expected `<`"); | |
| effects.enter(types.autolink); | |
| effects.enter(types.autolinkMarker); | |
| effects.consume(code); | |
| effects.exit(types.autolinkMarker); | |
| effects.enter(types.autolinkProtocol); | |
| return open; | |
| } | |
| /** | |
| * After `<`, at protocol or atext. | |
| * | |
| * ```markdown | |
| * > | a<https://example.com>b | |
| * ^ | |
| * > | a<user@example.com>b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function open(code) { | |
| if (asciiAlpha(code)) { | |
| effects.consume(code); | |
| return schemeOrEmailAtext; | |
| } | |
| if (code === codes.atSign) return nok(code); | |
| return emailAtext(code); | |
| } | |
| /** | |
| * At second byte of protocol or atext. | |
| * | |
| * ```markdown | |
| * > | a<https://example.com>b | |
| * ^ | |
| * > | a<user@example.com>b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function schemeOrEmailAtext(code) { | |
| if (code === codes.plusSign || code === codes.dash || code === codes.dot || asciiAlphanumeric(code)) { | |
| size = 1; | |
| return schemeInsideOrEmailAtext(code); | |
| } | |
| return emailAtext(code); | |
| } | |
| /** | |
| * In ambiguous protocol or atext. | |
| * | |
| * ```markdown | |
| * > | a<https://example.com>b | |
| * ^ | |
| * > | a<user@example.com>b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function schemeInsideOrEmailAtext(code) { | |
| if (code === codes.colon) { | |
| effects.consume(code); | |
| size = 0; | |
| return urlInside; | |
| } | |
| if ((code === codes.plusSign || code === codes.dash || code === codes.dot || asciiAlphanumeric(code)) && size++ < constants.autolinkSchemeSizeMax) { | |
| effects.consume(code); | |
| return schemeInsideOrEmailAtext; | |
| } | |
| size = 0; | |
| return emailAtext(code); | |
| } | |
| /** | |
| * After protocol, in URL. | |
| * | |
| * ```markdown | |
| * > | a<https://example.com>b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function urlInside(code) { | |
| if (code === codes.greaterThan) { | |
| effects.exit(types.autolinkProtocol); | |
| effects.enter(types.autolinkMarker); | |
| effects.consume(code); | |
| effects.exit(types.autolinkMarker); | |
| effects.exit(types.autolink); | |
| return ok$33; | |
| } | |
| if (code === codes.eof || code === codes.space || code === codes.lessThan || asciiControl(code)) return nok(code); | |
| effects.consume(code); | |
| return urlInside; | |
| } | |
| /** | |
| * In email atext. | |
| * | |
| * ```markdown | |
| * > | a<user.name@example.com>b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function emailAtext(code) { | |
| if (code === codes.atSign) { | |
| effects.consume(code); | |
| return emailAtSignOrDot; | |
| } | |
| if (asciiAtext(code)) { | |
| effects.consume(code); | |
| return emailAtext; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * In label, after at-sign or dot. | |
| * | |
| * ```markdown | |
| * > | a<user.name@example.com>b | |
| * ^ ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function emailAtSignOrDot(code) { | |
| return asciiAlphanumeric(code) ? emailLabel(code) : nok(code); | |
| } | |
| /** | |
| * In label, where `.` and `>` are allowed. | |
| * | |
| * ```markdown | |
| * > | a<user.name@example.com>b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function emailLabel(code) { | |
| if (code === codes.dot) { | |
| effects.consume(code); | |
| size = 0; | |
| return emailAtSignOrDot; | |
| } | |
| if (code === codes.greaterThan) { | |
| effects.exit(types.autolinkProtocol).type = types.autolinkEmail; | |
| effects.enter(types.autolinkMarker); | |
| effects.consume(code); | |
| effects.exit(types.autolinkMarker); | |
| effects.exit(types.autolink); | |
| return ok$33; | |
| } | |
| return emailValue(code); | |
| } | |
| /** | |
| * In label, where `.` and `>` are *not* allowed. | |
| * | |
| * Though, this is also used in `emailLabel` to parse other values. | |
| * | |
| * ```markdown | |
| * > | a<user.name@ex-ample.com>b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function emailValue(code) { | |
| if ((code === codes.dash || asciiAlphanumeric(code)) && size++ < constants.autolinkDomainSizeMax) { | |
| const next = code === codes.dash ? emailValue : emailLabel; | |
| effects.consume(code); | |
| return next; | |
| } | |
| return nok(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/block-quote.js | |
| /** | |
| * @import { | |
| * Construct, | |
| * Exiter, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var blockQuote = { | |
| continuation: { tokenize: tokenizeBlockQuoteContinuation }, | |
| exit, | |
| name: "blockQuote", | |
| tokenize: tokenizeBlockQuoteStart | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeBlockQuoteStart(effects, ok$31, nok) { | |
| const self = this; | |
| return start; | |
| /** | |
| * Start of block quote. | |
| * | |
| * ```markdown | |
| * > | > a | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| if (code === codes.greaterThan) { | |
| const state = self.containerState; | |
| ok(state, "expected `containerState` to be defined in container"); | |
| if (!state.open) { | |
| effects.enter(types.blockQuote, { _container: true }); | |
| state.open = true; | |
| } | |
| effects.enter(types.blockQuotePrefix); | |
| effects.enter(types.blockQuoteMarker); | |
| effects.consume(code); | |
| effects.exit(types.blockQuoteMarker); | |
| return after; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After `>`, before optional whitespace. | |
| * | |
| * ```markdown | |
| * > | > a | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function after(code) { | |
| if (markdownSpace(code)) { | |
| effects.enter(types.blockQuotePrefixWhitespace); | |
| effects.consume(code); | |
| effects.exit(types.blockQuotePrefixWhitespace); | |
| effects.exit(types.blockQuotePrefix); | |
| return ok$31; | |
| } | |
| effects.exit(types.blockQuotePrefix); | |
| return ok$31(code); | |
| } | |
| } | |
| /** | |
| * Start of block quote continuation. | |
| * | |
| * ```markdown | |
| * | > a | |
| * > | > b | |
| * ^ | |
| * ``` | |
| * | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeBlockQuoteContinuation(effects, ok$32, nok) { | |
| const self = this; | |
| return contStart; | |
| /** | |
| * Start of block quote continuation. | |
| * | |
| * Also used to parse the first block quote opening. | |
| * | |
| * ```markdown | |
| * | > a | |
| * > | > b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function contStart(code) { | |
| if (markdownSpace(code)) { | |
| ok(self.parser.constructs.disable.null, "expected `disable.null` to be populated"); | |
| return factorySpace(effects, contBefore, types.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : constants.tabSize)(code); | |
| } | |
| return contBefore(code); | |
| } | |
| /** | |
| * At `>`, after optional whitespace. | |
| * | |
| * Also used to parse the first block quote opening. | |
| * | |
| * ```markdown | |
| * | > a | |
| * > | > b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function contBefore(code) { | |
| return effects.attempt(blockQuote, ok$32, nok)(code); | |
| } | |
| } | |
| /** @type {Exiter} */ | |
| function exit(effects) { | |
| effects.exit(types.blockQuote); | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/character-escape.js | |
| /** | |
| * @import { | |
| * Construct, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var characterEscape = { | |
| name: "characterEscape", | |
| tokenize: tokenizeCharacterEscape | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeCharacterEscape(effects, ok$30, nok) { | |
| return start; | |
| /** | |
| * Start of character escape. | |
| * | |
| * ```markdown | |
| * > | a\*b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| ok(code === codes.backslash, "expected `\\`"); | |
| effects.enter(types.characterEscape); | |
| effects.enter(types.escapeMarker); | |
| effects.consume(code); | |
| effects.exit(types.escapeMarker); | |
| return inside; | |
| } | |
| /** | |
| * After `\`, at punctuation. | |
| * | |
| * ```markdown | |
| * > | a\*b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function inside(code) { | |
| if (asciiPunctuation(code)) { | |
| effects.enter(types.characterEscapeValue); | |
| effects.consume(code); | |
| effects.exit(types.characterEscapeValue); | |
| effects.exit(types.characterEscape); | |
| return ok$30; | |
| } | |
| return nok(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/character-reference.js | |
| /** | |
| * @import { | |
| * Code, | |
| * Construct, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var characterReference = { | |
| name: "characterReference", | |
| tokenize: tokenizeCharacterReference | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeCharacterReference(effects, ok$29, nok) { | |
| const self = this; | |
| let size = 0; | |
| /** @type {number} */ | |
| let max; | |
| /** @type {(code: Code) => boolean} */ | |
| let test; | |
| return start; | |
| /** | |
| * Start of character reference. | |
| * | |
| * ```markdown | |
| * > | a&b | |
| * ^ | |
| * > | a{b | |
| * ^ | |
| * > | a	b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| ok(code === codes.ampersand, "expected `&`"); | |
| effects.enter(types.characterReference); | |
| effects.enter(types.characterReferenceMarker); | |
| effects.consume(code); | |
| effects.exit(types.characterReferenceMarker); | |
| return open; | |
| } | |
| /** | |
| * After `&`, at `#` for numeric references or alphanumeric for named | |
| * references. | |
| * | |
| * ```markdown | |
| * > | a&b | |
| * ^ | |
| * > | a{b | |
| * ^ | |
| * > | a	b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function open(code) { | |
| if (code === codes.numberSign) { | |
| effects.enter(types.characterReferenceMarkerNumeric); | |
| effects.consume(code); | |
| effects.exit(types.characterReferenceMarkerNumeric); | |
| return numeric; | |
| } | |
| effects.enter(types.characterReferenceValue); | |
| max = constants.characterReferenceNamedSizeMax; | |
| test = asciiAlphanumeric; | |
| return value(code); | |
| } | |
| /** | |
| * After `#`, at `x` for hexadecimals or digit for decimals. | |
| * | |
| * ```markdown | |
| * > | a{b | |
| * ^ | |
| * > | a	b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function numeric(code) { | |
| if (code === codes.uppercaseX || code === codes.lowercaseX) { | |
| effects.enter(types.characterReferenceMarkerHexadecimal); | |
| effects.consume(code); | |
| effects.exit(types.characterReferenceMarkerHexadecimal); | |
| effects.enter(types.characterReferenceValue); | |
| max = constants.characterReferenceHexadecimalSizeMax; | |
| test = asciiHexDigit; | |
| return value; | |
| } | |
| effects.enter(types.characterReferenceValue); | |
| max = constants.characterReferenceDecimalSizeMax; | |
| test = asciiDigit; | |
| return value(code); | |
| } | |
| /** | |
| * After markers (`&#x`, `&#`, or `&`), in value, before `;`. | |
| * | |
| * The character reference kind defines what and how many characters are | |
| * allowed. | |
| * | |
| * ```markdown | |
| * > | a&b | |
| * ^^^ | |
| * > | a{b | |
| * ^^^ | |
| * > | a	b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function value(code) { | |
| if (code === codes.semicolon && size) { | |
| const token = effects.exit(types.characterReferenceValue); | |
| if (test === asciiAlphanumeric && !decodeNamedCharacterReference(self.sliceSerialize(token))) return nok(code); | |
| effects.enter(types.characterReferenceMarker); | |
| effects.consume(code); | |
| effects.exit(types.characterReferenceMarker); | |
| effects.exit(types.characterReference); | |
| return ok$29; | |
| } | |
| if (test(code) && size++ < max) { | |
| effects.consume(code); | |
| return value; | |
| } | |
| return nok(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/code-fenced.js | |
| /** | |
| * @import { | |
| * Code, | |
| * Construct, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var nonLazyContinuation = { | |
| partial: true, | |
| tokenize: tokenizeNonLazyContinuation | |
| }; | |
| /** @type {Construct} */ | |
| var codeFenced = { | |
| concrete: true, | |
| name: "codeFenced", | |
| tokenize: tokenizeCodeFenced | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeCodeFenced(effects, ok$26, nok) { | |
| const self = this; | |
| /** @type {Construct} */ | |
| const closeStart = { | |
| partial: true, | |
| tokenize: tokenizeCloseStart | |
| }; | |
| let initialPrefix = 0; | |
| let sizeOpen = 0; | |
| /** @type {NonNullable<Code>} */ | |
| let marker; | |
| return start; | |
| /** | |
| * Start of code. | |
| * | |
| * ```markdown | |
| * > | ~~~js | |
| * ^ | |
| * | alert(1) | |
| * | ~~~ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| return beforeSequenceOpen(code); | |
| } | |
| /** | |
| * In opening fence, after prefix, at sequence. | |
| * | |
| * ```markdown | |
| * > | ~~~js | |
| * ^ | |
| * | alert(1) | |
| * | ~~~ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function beforeSequenceOpen(code) { | |
| ok(code === codes.graveAccent || code === codes.tilde, "expected `` ` `` or `~`"); | |
| const tail = self.events[self.events.length - 1]; | |
| initialPrefix = tail && tail[1].type === types.linePrefix ? tail[2].sliceSerialize(tail[1], true).length : 0; | |
| marker = code; | |
| effects.enter(types.codeFenced); | |
| effects.enter(types.codeFencedFence); | |
| effects.enter(types.codeFencedFenceSequence); | |
| return sequenceOpen(code); | |
| } | |
| /** | |
| * In opening fence sequence. | |
| * | |
| * ```markdown | |
| * > | ~~~js | |
| * ^ | |
| * | alert(1) | |
| * | ~~~ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function sequenceOpen(code) { | |
| if (code === marker) { | |
| sizeOpen++; | |
| effects.consume(code); | |
| return sequenceOpen; | |
| } | |
| if (sizeOpen < constants.codeFencedSequenceSizeMin) return nok(code); | |
| effects.exit(types.codeFencedFenceSequence); | |
| return markdownSpace(code) ? factorySpace(effects, infoBefore, types.whitespace)(code) : infoBefore(code); | |
| } | |
| /** | |
| * In opening fence, after the sequence (and optional whitespace), before info. | |
| * | |
| * ```markdown | |
| * > | ~~~js | |
| * ^ | |
| * | alert(1) | |
| * | ~~~ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function infoBefore(code) { | |
| if (code === codes.eof || markdownLineEnding(code)) { | |
| effects.exit(types.codeFencedFence); | |
| return self.interrupt ? ok$26(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code); | |
| } | |
| effects.enter(types.codeFencedFenceInfo); | |
| effects.enter(types.chunkString, { contentType: constants.contentTypeString }); | |
| return info(code); | |
| } | |
| /** | |
| * In info. | |
| * | |
| * ```markdown | |
| * > | ~~~js | |
| * ^ | |
| * | alert(1) | |
| * | ~~~ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function info(code) { | |
| if (code === codes.eof || markdownLineEnding(code)) { | |
| effects.exit(types.chunkString); | |
| effects.exit(types.codeFencedFenceInfo); | |
| return infoBefore(code); | |
| } | |
| if (markdownSpace(code)) { | |
| effects.exit(types.chunkString); | |
| effects.exit(types.codeFencedFenceInfo); | |
| return factorySpace(effects, metaBefore, types.whitespace)(code); | |
| } | |
| if (code === codes.graveAccent && code === marker) return nok(code); | |
| effects.consume(code); | |
| return info; | |
| } | |
| /** | |
| * In opening fence, after info and whitespace, before meta. | |
| * | |
| * ```markdown | |
| * > | ~~~js eval | |
| * ^ | |
| * | alert(1) | |
| * | ~~~ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function metaBefore(code) { | |
| if (code === codes.eof || markdownLineEnding(code)) return infoBefore(code); | |
| effects.enter(types.codeFencedFenceMeta); | |
| effects.enter(types.chunkString, { contentType: constants.contentTypeString }); | |
| return meta(code); | |
| } | |
| /** | |
| * In meta. | |
| * | |
| * ```markdown | |
| * > | ~~~js eval | |
| * ^ | |
| * | alert(1) | |
| * | ~~~ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function meta(code) { | |
| if (code === codes.eof || markdownLineEnding(code)) { | |
| effects.exit(types.chunkString); | |
| effects.exit(types.codeFencedFenceMeta); | |
| return infoBefore(code); | |
| } | |
| if (code === codes.graveAccent && code === marker) return nok(code); | |
| effects.consume(code); | |
| return meta; | |
| } | |
| /** | |
| * At eol/eof in code, before a non-lazy closing fence or content. | |
| * | |
| * ```markdown | |
| * > | ~~~js | |
| * ^ | |
| * > | alert(1) | |
| * ^ | |
| * | ~~~ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function atNonLazyBreak(code) { | |
| ok(markdownLineEnding(code), "expected eol"); | |
| return effects.attempt(closeStart, after, contentBefore)(code); | |
| } | |
| /** | |
| * Before code content, not a closing fence, at eol. | |
| * | |
| * ```markdown | |
| * | ~~~js | |
| * > | alert(1) | |
| * ^ | |
| * | ~~~ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function contentBefore(code) { | |
| ok(markdownLineEnding(code), "expected eol"); | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| return contentStart; | |
| } | |
| /** | |
| * Before code content, not a closing fence. | |
| * | |
| * ```markdown | |
| * | ~~~js | |
| * > | alert(1) | |
| * ^ | |
| * | ~~~ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function contentStart(code) { | |
| return initialPrefix > 0 && markdownSpace(code) ? factorySpace(effects, beforeContentChunk, types.linePrefix, initialPrefix + 1)(code) : beforeContentChunk(code); | |
| } | |
| /** | |
| * Before code content, after optional prefix. | |
| * | |
| * ```markdown | |
| * | ~~~js | |
| * > | alert(1) | |
| * ^ | |
| * | ~~~ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function beforeContentChunk(code) { | |
| if (code === codes.eof || markdownLineEnding(code)) return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code); | |
| effects.enter(types.codeFlowValue); | |
| return contentChunk(code); | |
| } | |
| /** | |
| * In code content. | |
| * | |
| * ```markdown | |
| * | ~~~js | |
| * > | alert(1) | |
| * ^^^^^^^^ | |
| * | ~~~ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function contentChunk(code) { | |
| if (code === codes.eof || markdownLineEnding(code)) { | |
| effects.exit(types.codeFlowValue); | |
| return beforeContentChunk(code); | |
| } | |
| effects.consume(code); | |
| return contentChunk; | |
| } | |
| /** | |
| * After code. | |
| * | |
| * ```markdown | |
| * | ~~~js | |
| * | alert(1) | |
| * > | ~~~ | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function after(code) { | |
| effects.exit(types.codeFenced); | |
| return ok$26(code); | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeCloseStart(effects, ok$27, nok) { | |
| let size = 0; | |
| return startBefore; | |
| /** | |
| * | |
| * | |
| * @type {State} | |
| */ | |
| function startBefore(code) { | |
| ok(markdownLineEnding(code), "expected eol"); | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| return start; | |
| } | |
| /** | |
| * Before closing fence, at optional whitespace. | |
| * | |
| * ```markdown | |
| * | ~~~js | |
| * | alert(1) | |
| * > | ~~~ | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| ok(self.parser.constructs.disable.null, "expected `disable.null` to be populated"); | |
| effects.enter(types.codeFencedFence); | |
| return markdownSpace(code) ? factorySpace(effects, beforeSequenceClose, types.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : constants.tabSize)(code) : beforeSequenceClose(code); | |
| } | |
| /** | |
| * In closing fence, after optional whitespace, at sequence. | |
| * | |
| * ```markdown | |
| * | ~~~js | |
| * | alert(1) | |
| * > | ~~~ | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function beforeSequenceClose(code) { | |
| if (code === marker) { | |
| effects.enter(types.codeFencedFenceSequence); | |
| return sequenceClose(code); | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * In closing fence sequence. | |
| * | |
| * ```markdown | |
| * | ~~~js | |
| * | alert(1) | |
| * > | ~~~ | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function sequenceClose(code) { | |
| if (code === marker) { | |
| size++; | |
| effects.consume(code); | |
| return sequenceClose; | |
| } | |
| if (size >= sizeOpen) { | |
| effects.exit(types.codeFencedFenceSequence); | |
| return markdownSpace(code) ? factorySpace(effects, sequenceCloseAfter, types.whitespace)(code) : sequenceCloseAfter(code); | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After closing fence sequence, after optional whitespace. | |
| * | |
| * ```markdown | |
| * | ~~~js | |
| * | alert(1) | |
| * > | ~~~ | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function sequenceCloseAfter(code) { | |
| if (code === codes.eof || markdownLineEnding(code)) { | |
| effects.exit(types.codeFencedFence); | |
| return ok$27(code); | |
| } | |
| return nok(code); | |
| } | |
| } | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeNonLazyContinuation(effects, ok$28, nok) { | |
| const self = this; | |
| return start; | |
| /** | |
| * | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| if (code === codes.eof) return nok(code); | |
| ok(markdownLineEnding(code), "expected eol"); | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| return lineStart; | |
| } | |
| /** | |
| * | |
| * | |
| * @type {State} | |
| */ | |
| function lineStart(code) { | |
| return self.parser.lazy[self.now().line] ? nok(code) : ok$28(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/code-indented.js | |
| /** | |
| * @import { | |
| * Construct, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var codeIndented = { | |
| name: "codeIndented", | |
| tokenize: tokenizeCodeIndented | |
| }; | |
| /** @type {Construct} */ | |
| var furtherStart = { | |
| partial: true, | |
| tokenize: tokenizeFurtherStart | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeCodeIndented(effects, ok$25, nok) { | |
| const self = this; | |
| return start; | |
| /** | |
| * Start of code (indented). | |
| * | |
| * > **Parsing note**: it is not needed to check if this first line is a | |
| * > filled line (that it has a non-whitespace character), because blank lines | |
| * > are parsed already, so we never run into that. | |
| * | |
| * ```markdown | |
| * > | aaa | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| ok(markdownSpace(code)); | |
| effects.enter(types.codeIndented); | |
| return factorySpace(effects, afterPrefix, types.linePrefix, constants.tabSize + 1)(code); | |
| } | |
| /** | |
| * At start, after 1 or 4 spaces. | |
| * | |
| * ```markdown | |
| * > | aaa | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function afterPrefix(code) { | |
| const tail = self.events[self.events.length - 1]; | |
| return tail && tail[1].type === types.linePrefix && tail[2].sliceSerialize(tail[1], true).length >= constants.tabSize ? atBreak(code) : nok(code); | |
| } | |
| /** | |
| * At a break. | |
| * | |
| * ```markdown | |
| * > | aaa | |
| * ^ ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function atBreak(code) { | |
| if (code === codes.eof) return after(code); | |
| if (markdownLineEnding(code)) return effects.attempt(furtherStart, atBreak, after)(code); | |
| effects.enter(types.codeFlowValue); | |
| return inside(code); | |
| } | |
| /** | |
| * In code content. | |
| * | |
| * ```markdown | |
| * > | aaa | |
| * ^^^^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function inside(code) { | |
| if (code === codes.eof || markdownLineEnding(code)) { | |
| effects.exit(types.codeFlowValue); | |
| return atBreak(code); | |
| } | |
| effects.consume(code); | |
| return inside; | |
| } | |
| /** @type {State} */ | |
| function after(code) { | |
| effects.exit(types.codeIndented); | |
| return ok$25(code); | |
| } | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeFurtherStart(effects, ok, nok) { | |
| const self = this; | |
| return furtherStart; | |
| /** | |
| * At eol, trying to parse another indent. | |
| * | |
| * ```markdown | |
| * > | aaa | |
| * ^ | |
| * | bbb | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function furtherStart(code) { | |
| if (self.parser.lazy[self.now().line]) return nok(code); | |
| if (markdownLineEnding(code)) { | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| return furtherStart; | |
| } | |
| return factorySpace(effects, afterPrefix, types.linePrefix, constants.tabSize + 1)(code); | |
| } | |
| /** | |
| * At start, after 1 or 4 spaces. | |
| * | |
| * ```markdown | |
| * > | aaa | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function afterPrefix(code) { | |
| const tail = self.events[self.events.length - 1]; | |
| return tail && tail[1].type === types.linePrefix && tail[2].sliceSerialize(tail[1], true).length >= constants.tabSize ? ok(code) : markdownLineEnding(code) ? furtherStart(code) : nok(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/code-text.js | |
| /** | |
| * @import { | |
| * Construct, | |
| * Previous, | |
| * Resolver, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer, | |
| * Token | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var codeText = { | |
| name: "codeText", | |
| previous, | |
| resolve: resolveCodeText, | |
| tokenize: tokenizeCodeText | |
| }; | |
| /** @type {Resolver} */ | |
| function resolveCodeText(events) { | |
| let tailExitIndex = events.length - 4; | |
| let headEnterIndex = 3; | |
| /** @type {number} */ | |
| let index; | |
| /** @type {number | undefined} */ | |
| let enter; | |
| if ((events[headEnterIndex][1].type === types.lineEnding || events[headEnterIndex][1].type === "space") && (events[tailExitIndex][1].type === types.lineEnding || events[tailExitIndex][1].type === "space")) { | |
| index = headEnterIndex; | |
| while (++index < tailExitIndex) if (events[index][1].type === types.codeTextData) { | |
| events[headEnterIndex][1].type = types.codeTextPadding; | |
| events[tailExitIndex][1].type = types.codeTextPadding; | |
| headEnterIndex += 2; | |
| tailExitIndex -= 2; | |
| break; | |
| } | |
| } | |
| index = headEnterIndex - 1; | |
| tailExitIndex++; | |
| while (++index <= tailExitIndex) if (enter === void 0) { | |
| if (index !== tailExitIndex && events[index][1].type !== types.lineEnding) enter = index; | |
| } else if (index === tailExitIndex || events[index][1].type === types.lineEnding) { | |
| events[enter][1].type = types.codeTextData; | |
| if (index !== enter + 2) { | |
| events[enter][1].end = events[index - 1][1].end; | |
| events.splice(enter + 2, index - enter - 2); | |
| tailExitIndex -= index - enter - 2; | |
| index = enter + 2; | |
| } | |
| enter = void 0; | |
| } | |
| return events; | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Previous} | |
| */ | |
| function previous(code) { | |
| return code !== codes.graveAccent || this.events[this.events.length - 1][1].type === types.characterEscape; | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeCodeText(effects, ok$24, nok) { | |
| const self = this; | |
| let sizeOpen = 0; | |
| /** @type {number} */ | |
| let size; | |
| /** @type {Token} */ | |
| let token; | |
| return start; | |
| /** | |
| * Start of code (text). | |
| * | |
| * ```markdown | |
| * > | `a` | |
| * ^ | |
| * > | \`a` | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| ok(code === codes.graveAccent, "expected `` ` ``"); | |
| ok(previous.call(self, self.previous), "expected correct previous"); | |
| effects.enter(types.codeText); | |
| effects.enter(types.codeTextSequence); | |
| return sequenceOpen(code); | |
| } | |
| /** | |
| * In opening sequence. | |
| * | |
| * ```markdown | |
| * > | `a` | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function sequenceOpen(code) { | |
| if (code === codes.graveAccent) { | |
| effects.consume(code); | |
| sizeOpen++; | |
| return sequenceOpen; | |
| } | |
| effects.exit(types.codeTextSequence); | |
| return between(code); | |
| } | |
| /** | |
| * Between something and something else. | |
| * | |
| * ```markdown | |
| * > | `a` | |
| * ^^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function between(code) { | |
| if (code === codes.eof) return nok(code); | |
| if (code === codes.space) { | |
| effects.enter("space"); | |
| effects.consume(code); | |
| effects.exit("space"); | |
| return between; | |
| } | |
| if (code === codes.graveAccent) { | |
| token = effects.enter(types.codeTextSequence); | |
| size = 0; | |
| return sequenceClose(code); | |
| } | |
| if (markdownLineEnding(code)) { | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| return between; | |
| } | |
| effects.enter(types.codeTextData); | |
| return data(code); | |
| } | |
| /** | |
| * In data. | |
| * | |
| * ```markdown | |
| * > | `a` | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function data(code) { | |
| if (code === codes.eof || code === codes.space || code === codes.graveAccent || markdownLineEnding(code)) { | |
| effects.exit(types.codeTextData); | |
| return between(code); | |
| } | |
| effects.consume(code); | |
| return data; | |
| } | |
| /** | |
| * In closing sequence. | |
| * | |
| * ```markdown | |
| * > | `a` | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function sequenceClose(code) { | |
| if (code === codes.graveAccent) { | |
| effects.consume(code); | |
| size++; | |
| return sequenceClose; | |
| } | |
| if (size === sizeOpen) { | |
| effects.exit(types.codeTextSequence); | |
| effects.exit(types.codeText); | |
| return ok$24(code); | |
| } | |
| token.type = types.codeTextData; | |
| return data(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-util-subtokenize/dev/lib/splice-buffer.js | |
| /** | |
| * Some of the internal operations of micromark do lots of editing | |
| * operations on very large arrays. This runs into problems with two | |
| * properties of most circa-2020 JavaScript interpreters: | |
| * | |
| * - Array-length modifications at the high end of an array (push/pop) are | |
| * expected to be common and are implemented in (amortized) time | |
| * proportional to the number of elements added or removed, whereas | |
| * other operations (shift/unshift and splice) are much less efficient. | |
| * - Function arguments are passed on the stack, so adding tens of thousands | |
| * of elements to an array with `arr.push(...newElements)` will frequently | |
| * cause stack overflows. (see <https://stackoverflow.com/questions/22123769/rangeerror-maximum-call-stack-size-exceeded-why>) | |
| * | |
| * SpliceBuffers are an implementation of gap buffers, which are a | |
| * generalization of the "queue made of two stacks" idea. The splice buffer | |
| * maintains a cursor, and moving the cursor has cost proportional to the | |
| * distance the cursor moves, but inserting, deleting, or splicing in | |
| * new information at the cursor is as efficient as the push/pop operation. | |
| * This allows for an efficient sequence of splices (or pushes, pops, shifts, | |
| * or unshifts) as long such edits happen at the same part of the array or | |
| * generally sweep through the array from the beginning to the end. | |
| * | |
| * The interface for splice buffers also supports large numbers of inputs by | |
| * passing a single array argument rather passing multiple arguments on the | |
| * function call stack. | |
| * | |
| * @template T | |
| * Item type. | |
| */ | |
| var SpliceBuffer = class { | |
| /** | |
| * @param {ReadonlyArray<T> | null | undefined} [initial] | |
| * Initial items (optional). | |
| * @returns | |
| * Splice buffer. | |
| */ | |
| constructor(initial) { | |
| /** @type {Array<T>} */ | |
| this.left = initial ? [...initial] : []; | |
| /** @type {Array<T>} */ | |
| this.right = []; | |
| } | |
| /** | |
| * Array access; | |
| * does not move the cursor. | |
| * | |
| * @param {number} index | |
| * Index. | |
| * @return {T} | |
| * Item. | |
| */ | |
| get(index) { | |
| if (index < 0 || index >= this.left.length + this.right.length) throw new RangeError("Cannot access index `" + index + "` in a splice buffer of size `" + (this.left.length + this.right.length) + "`"); | |
| if (index < this.left.length) return this.left[index]; | |
| return this.right[this.right.length - index + this.left.length - 1]; | |
| } | |
| /** | |
| * The length of the splice buffer, one greater than the largest index in the | |
| * array. | |
| */ | |
| get length() { | |
| return this.left.length + this.right.length; | |
| } | |
| /** | |
| * Remove and return `list[0]`; | |
| * moves the cursor to `0`. | |
| * | |
| * @returns {T | undefined} | |
| * Item, optional. | |
| */ | |
| shift() { | |
| this.setCursor(0); | |
| return this.right.pop(); | |
| } | |
| /** | |
| * Slice the buffer to get an array; | |
| * does not move the cursor. | |
| * | |
| * @param {number} start | |
| * Start. | |
| * @param {number | null | undefined} [end] | |
| * End (optional). | |
| * @returns {Array<T>} | |
| * Array of items. | |
| */ | |
| slice(start, end) { | |
| /** @type {number} */ | |
| const stop = end === null || end === void 0 ? Number.POSITIVE_INFINITY : end; | |
| if (stop < this.left.length) return this.left.slice(start, stop); | |
| if (start > this.left.length) return this.right.slice(this.right.length - stop + this.left.length, this.right.length - start + this.left.length).reverse(); | |
| return this.left.slice(start).concat(this.right.slice(this.right.length - stop + this.left.length).reverse()); | |
| } | |
| /** | |
| * Mimics the behavior of Array.prototype.splice() except for the change of | |
| * interface necessary to avoid segfaults when patching in very large arrays. | |
| * | |
| * This operation moves cursor is moved to `start` and results in the cursor | |
| * placed after any inserted items. | |
| * | |
| * @param {number} start | |
| * Start; | |
| * zero-based index at which to start changing the array; | |
| * negative numbers count backwards from the end of the array and values | |
| * that are out-of bounds are clamped to the appropriate end of the array. | |
| * @param {number | null | undefined} [deleteCount=0] | |
| * Delete count (default: `0`); | |
| * maximum number of elements to delete, starting from start. | |
| * @param {Array<T> | null | undefined} [items=[]] | |
| * Items to include in place of the deleted items (default: `[]`). | |
| * @return {Array<T>} | |
| * Any removed items. | |
| */ | |
| splice(start, deleteCount, items) { | |
| /** @type {number} */ | |
| const count = deleteCount || 0; | |
| this.setCursor(Math.trunc(start)); | |
| const removed = this.right.splice(this.right.length - count, Number.POSITIVE_INFINITY); | |
| if (items) chunkedPush(this.left, items); | |
| return removed.reverse(); | |
| } | |
| /** | |
| * Remove and return the highest-numbered item in the array, so | |
| * `list[list.length - 1]`; | |
| * Moves the cursor to `length`. | |
| * | |
| * @returns {T | undefined} | |
| * Item, optional. | |
| */ | |
| pop() { | |
| this.setCursor(Number.POSITIVE_INFINITY); | |
| return this.left.pop(); | |
| } | |
| /** | |
| * Inserts a single item to the high-numbered side of the array; | |
| * moves the cursor to `length`. | |
| * | |
| * @param {T} item | |
| * Item. | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| push(item) { | |
| this.setCursor(Number.POSITIVE_INFINITY); | |
| this.left.push(item); | |
| } | |
| /** | |
| * Inserts many items to the high-numbered side of the array. | |
| * Moves the cursor to `length`. | |
| * | |
| * @param {Array<T>} items | |
| * Items. | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| pushMany(items) { | |
| this.setCursor(Number.POSITIVE_INFINITY); | |
| chunkedPush(this.left, items); | |
| } | |
| /** | |
| * Inserts a single item to the low-numbered side of the array; | |
| * Moves the cursor to `0`. | |
| * | |
| * @param {T} item | |
| * Item. | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| unshift(item) { | |
| this.setCursor(0); | |
| this.right.push(item); | |
| } | |
| /** | |
| * Inserts many items to the low-numbered side of the array; | |
| * moves the cursor to `0`. | |
| * | |
| * @param {Array<T>} items | |
| * Items. | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| unshiftMany(items) { | |
| this.setCursor(0); | |
| chunkedPush(this.right, items.reverse()); | |
| } | |
| /** | |
| * Move the cursor to a specific position in the array. Requires | |
| * time proportional to the distance moved. | |
| * | |
| * If `n < 0`, the cursor will end up at the beginning. | |
| * If `n > length`, the cursor will end up at the end. | |
| * | |
| * @param {number} n | |
| * Position. | |
| * @return {undefined} | |
| * Nothing. | |
| */ | |
| setCursor(n) { | |
| if (n === this.left.length || n > this.left.length && this.right.length === 0 || n < 0 && this.left.length === 0) return; | |
| if (n < this.left.length) { | |
| const removed = this.left.splice(n, Number.POSITIVE_INFINITY); | |
| chunkedPush(this.right, removed.reverse()); | |
| } else { | |
| const removed = this.right.splice(this.left.length + this.right.length - n, Number.POSITIVE_INFINITY); | |
| chunkedPush(this.left, removed.reverse()); | |
| } | |
| } | |
| }; | |
| /** | |
| * Avoid stack overflow by pushing items onto the stack in segments | |
| * | |
| * @template T | |
| * Item type. | |
| * @param {Array<T>} list | |
| * List to inject into. | |
| * @param {ReadonlyArray<T>} right | |
| * Items to inject. | |
| * @return {undefined} | |
| * Nothing. | |
| */ | |
| function chunkedPush(list, right) { | |
| /** @type {number} */ | |
| let chunkStart = 0; | |
| if (right.length < constants.v8MaxSafeChunkSize) list.push(...right); | |
| else while (chunkStart < right.length) { | |
| list.push(...right.slice(chunkStart, chunkStart + constants.v8MaxSafeChunkSize)); | |
| chunkStart += constants.v8MaxSafeChunkSize; | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-util-subtokenize/dev/index.js | |
| /** | |
| * @import {Chunk, Event, Token} from 'micromark-util-types' | |
| */ | |
| /** | |
| * Tokenize subcontent. | |
| * | |
| * @param {Array<Event>} eventsArray | |
| * List of events. | |
| * @returns {boolean} | |
| * Whether subtokens were found. | |
| */ | |
| function subtokenize(eventsArray) { | |
| /** @type {Record<string, number>} */ | |
| const jumps = {}; | |
| let index = -1; | |
| /** @type {Event} */ | |
| let event; | |
| /** @type {number | undefined} */ | |
| let lineIndex; | |
| /** @type {number} */ | |
| let otherIndex; | |
| /** @type {Event} */ | |
| let otherEvent; | |
| /** @type {Array<Event>} */ | |
| let parameters; | |
| /** @type {Array<Event>} */ | |
| let subevents; | |
| /** @type {boolean | undefined} */ | |
| let more; | |
| const events = new SpliceBuffer(eventsArray); | |
| while (++index < events.length) { | |
| while (index in jumps) index = jumps[index]; | |
| event = events.get(index); | |
| if (index && event[1].type === types.chunkFlow && events.get(index - 1)[1].type === types.listItemPrefix) { | |
| ok(event[1]._tokenizer, "expected `_tokenizer` on subtokens"); | |
| subevents = event[1]._tokenizer.events; | |
| otherIndex = 0; | |
| if (otherIndex < subevents.length && subevents[otherIndex][1].type === types.lineEndingBlank) otherIndex += 2; | |
| if (otherIndex < subevents.length && subevents[otherIndex][1].type === types.content) while (++otherIndex < subevents.length) { | |
| if (subevents[otherIndex][1].type === types.content) break; | |
| if (subevents[otherIndex][1].type === types.chunkText) { | |
| subevents[otherIndex][1]._isInFirstContentOfListItem = true; | |
| otherIndex++; | |
| } | |
| } | |
| } | |
| if (event[0] === "enter") { | |
| if (event[1].contentType) { | |
| Object.assign(jumps, subcontent(events, index)); | |
| index = jumps[index]; | |
| more = true; | |
| } | |
| } else if (event[1]._container) { | |
| otherIndex = index; | |
| lineIndex = void 0; | |
| while (otherIndex--) { | |
| otherEvent = events.get(otherIndex); | |
| if (otherEvent[1].type === types.lineEnding || otherEvent[1].type === types.lineEndingBlank) { | |
| if (otherEvent[0] === "enter") { | |
| if (lineIndex) events.get(lineIndex)[1].type = types.lineEndingBlank; | |
| otherEvent[1].type = types.lineEnding; | |
| lineIndex = otherIndex; | |
| } | |
| } else if (otherEvent[1].type === types.linePrefix || otherEvent[1].type === types.listItemIndent) {} else break; | |
| } | |
| if (lineIndex) { | |
| event[1].end = { ...events.get(lineIndex)[1].start }; | |
| parameters = events.slice(lineIndex, index); | |
| parameters.unshift(event); | |
| events.splice(lineIndex, index - lineIndex + 1, parameters); | |
| } | |
| } | |
| } | |
| splice(eventsArray, 0, Number.POSITIVE_INFINITY, events.slice(0)); | |
| return !more; | |
| } | |
| /** | |
| * Tokenize embedded tokens. | |
| * | |
| * @param {SpliceBuffer<Event>} events | |
| * Events. | |
| * @param {number} eventIndex | |
| * Index. | |
| * @returns {Record<string, number>} | |
| * Gaps. | |
| */ | |
| function subcontent(events, eventIndex) { | |
| const token = events.get(eventIndex)[1]; | |
| const context = events.get(eventIndex)[2]; | |
| let startPosition = eventIndex - 1; | |
| /** @type {Array<number>} */ | |
| const startPositions = []; | |
| ok(token.contentType, "expected `contentType` on subtokens"); | |
| let tokenizer = token._tokenizer; | |
| if (!tokenizer) { | |
| tokenizer = context.parser[token.contentType](token.start); | |
| if (token._contentTypeTextTrailing) tokenizer._contentTypeTextTrailing = true; | |
| } | |
| const childEvents = tokenizer.events; | |
| /** @type {Array<[number, number]>} */ | |
| const jumps = []; | |
| /** @type {Record<string, number>} */ | |
| const gaps = {}; | |
| /** @type {Array<Chunk>} */ | |
| let stream; | |
| /** @type {Token | undefined} */ | |
| let previous; | |
| let index = -1; | |
| /** @type {Token | undefined} */ | |
| let current = token; | |
| let adjust = 0; | |
| let start = 0; | |
| const breaks = [start]; | |
| while (current) { | |
| while (events.get(++startPosition)[1] !== current); | |
| ok(!previous || current.previous === previous, "expected previous to match"); | |
| ok(!previous || previous.next === current, "expected next to match"); | |
| startPositions.push(startPosition); | |
| if (!current._tokenizer) { | |
| stream = context.sliceStream(current); | |
| if (!current.next) stream.push(codes.eof); | |
| if (previous) tokenizer.defineSkip(current.start); | |
| if (current._isInFirstContentOfListItem) tokenizer._gfmTasklistFirstContentOfListItem = true; | |
| tokenizer.write(stream); | |
| if (current._isInFirstContentOfListItem) tokenizer._gfmTasklistFirstContentOfListItem = void 0; | |
| } | |
| previous = current; | |
| current = current.next; | |
| } | |
| current = token; | |
| while (++index < childEvents.length) if (childEvents[index][0] === "exit" && childEvents[index - 1][0] === "enter" && childEvents[index][1].type === childEvents[index - 1][1].type && childEvents[index][1].start.line !== childEvents[index][1].end.line) { | |
| ok(current, "expected a current token"); | |
| start = index + 1; | |
| breaks.push(start); | |
| current._tokenizer = void 0; | |
| current.previous = void 0; | |
| current = current.next; | |
| } | |
| tokenizer.events = []; | |
| if (current) { | |
| current._tokenizer = void 0; | |
| current.previous = void 0; | |
| ok(!current.next, "expected no next token"); | |
| } else breaks.pop(); | |
| index = breaks.length; | |
| while (index--) { | |
| const slice = childEvents.slice(breaks[index], breaks[index + 1]); | |
| const start = startPositions.pop(); | |
| ok(start !== void 0, "expected a start position when splicing"); | |
| jumps.push([start, start + slice.length - 1]); | |
| events.splice(start, 2, slice); | |
| } | |
| jumps.reverse(); | |
| index = -1; | |
| while (++index < jumps.length) { | |
| gaps[adjust + jumps[index][0]] = adjust + jumps[index][1]; | |
| adjust += jumps[index][1] - jumps[index][0] - 1; | |
| } | |
| return gaps; | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/content.js | |
| /** | |
| * @import { | |
| * Construct, | |
| * Resolver, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer, | |
| * Token | |
| * } from 'micromark-util-types' | |
| */ | |
| /** | |
| * No name because it must not be turned off. | |
| * @type {Construct} | |
| */ | |
| var content = { | |
| resolve: resolveContent, | |
| tokenize: tokenizeContent | |
| }; | |
| /** @type {Construct} */ | |
| var continuationConstruct = { | |
| partial: true, | |
| tokenize: tokenizeContinuation | |
| }; | |
| /** | |
| * Content is transparent: it’s parsed right now. That way, definitions are also | |
| * parsed right now: before text in paragraphs (specifically, media) are parsed. | |
| * | |
| * @type {Resolver} | |
| */ | |
| function resolveContent(events) { | |
| subtokenize(events); | |
| return events; | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeContent(effects, ok$22) { | |
| /** @type {Token | undefined} */ | |
| let previous; | |
| return chunkStart; | |
| /** | |
| * Before a content chunk. | |
| * | |
| * ```markdown | |
| * > | abc | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function chunkStart(code) { | |
| ok(code !== codes.eof && !markdownLineEnding(code), "expected no eof or eol"); | |
| effects.enter(types.content); | |
| previous = effects.enter(types.chunkContent, { contentType: constants.contentTypeContent }); | |
| return chunkInside(code); | |
| } | |
| /** | |
| * In a content chunk. | |
| * | |
| * ```markdown | |
| * > | abc | |
| * ^^^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function chunkInside(code) { | |
| if (code === codes.eof) return contentEnd(code); | |
| if (markdownLineEnding(code)) return effects.check(continuationConstruct, contentContinue, contentEnd)(code); | |
| effects.consume(code); | |
| return chunkInside; | |
| } | |
| /** | |
| * | |
| * | |
| * @type {State} | |
| */ | |
| function contentEnd(code) { | |
| effects.exit(types.chunkContent); | |
| effects.exit(types.content); | |
| return ok$22(code); | |
| } | |
| /** | |
| * | |
| * | |
| * @type {State} | |
| */ | |
| function contentContinue(code) { | |
| ok(markdownLineEnding(code), "expected eol"); | |
| effects.consume(code); | |
| effects.exit(types.chunkContent); | |
| ok(previous, "expected previous token"); | |
| previous.next = effects.enter(types.chunkContent, { | |
| contentType: constants.contentTypeContent, | |
| previous | |
| }); | |
| previous = previous.next; | |
| return chunkInside; | |
| } | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeContinuation(effects, ok$23, nok) { | |
| const self = this; | |
| return startLookahead; | |
| /** | |
| * | |
| * | |
| * @type {State} | |
| */ | |
| function startLookahead(code) { | |
| ok(markdownLineEnding(code), "expected a line ending"); | |
| effects.exit(types.chunkContent); | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| return factorySpace(effects, prefixed, types.linePrefix); | |
| } | |
| /** | |
| * | |
| * | |
| * @type {State} | |
| */ | |
| function prefixed(code) { | |
| if (code === codes.eof || markdownLineEnding(code)) return nok(code); | |
| ok(self.parser.constructs.disable.null, "expected `disable.null` to be populated"); | |
| const tail = self.events[self.events.length - 1]; | |
| if (!self.parser.constructs.disable.null.includes("codeIndented") && tail && tail[1].type === types.linePrefix && tail[2].sliceSerialize(tail[1], true).length >= constants.tabSize) return ok$23(code); | |
| return effects.interrupt(self.parser.constructs.flow, nok, ok$23)(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-factory-destination/dev/index.js | |
| /** | |
| * @import {Effects, State, TokenType} from 'micromark-util-types' | |
| */ | |
| /** | |
| * Parse destinations. | |
| * | |
| * ###### Examples | |
| * | |
| * ```markdown | |
| * <a> | |
| * <a\>b> | |
| * <a b> | |
| * <a)> | |
| * a | |
| * a\)b | |
| * a(b)c | |
| * a(b) | |
| * ``` | |
| * | |
| * @param {Effects} effects | |
| * Context. | |
| * @param {State} ok | |
| * State switched to when successful. | |
| * @param {State} nok | |
| * State switched to when unsuccessful. | |
| * @param {TokenType} type | |
| * Type for whole (`<a>` or `b`). | |
| * @param {TokenType} literalType | |
| * Type when enclosed (`<a>`). | |
| * @param {TokenType} literalMarkerType | |
| * Type for enclosing (`<` and `>`). | |
| * @param {TokenType} rawType | |
| * Type when not enclosed (`b`). | |
| * @param {TokenType} stringType | |
| * Type for the value (`a` or `b`). | |
| * @param {number | undefined} [max=Infinity] | |
| * Depth of nested parens (inclusive). | |
| * @returns {State} | |
| * Start state. | |
| */ | |
| function factoryDestination(effects, ok, nok, type, literalType, literalMarkerType, rawType, stringType, max) { | |
| const limit = max || Number.POSITIVE_INFINITY; | |
| let balance = 0; | |
| return start; | |
| /** | |
| * Start of destination. | |
| * | |
| * ```markdown | |
| * > | <aa> | |
| * ^ | |
| * > | aa | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| if (code === codes.lessThan) { | |
| effects.enter(type); | |
| effects.enter(literalType); | |
| effects.enter(literalMarkerType); | |
| effects.consume(code); | |
| effects.exit(literalMarkerType); | |
| return enclosedBefore; | |
| } | |
| if (code === codes.eof || code === codes.space || code === codes.rightParenthesis || asciiControl(code)) return nok(code); | |
| effects.enter(type); | |
| effects.enter(rawType); | |
| effects.enter(stringType); | |
| effects.enter(types.chunkString, { contentType: constants.contentTypeString }); | |
| return raw(code); | |
| } | |
| /** | |
| * After `<`, at an enclosed destination. | |
| * | |
| * ```markdown | |
| * > | <aa> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function enclosedBefore(code) { | |
| if (code === codes.greaterThan) { | |
| effects.enter(literalMarkerType); | |
| effects.consume(code); | |
| effects.exit(literalMarkerType); | |
| effects.exit(literalType); | |
| effects.exit(type); | |
| return ok; | |
| } | |
| effects.enter(stringType); | |
| effects.enter(types.chunkString, { contentType: constants.contentTypeString }); | |
| return enclosed(code); | |
| } | |
| /** | |
| * In enclosed destination. | |
| * | |
| * ```markdown | |
| * > | <aa> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function enclosed(code) { | |
| if (code === codes.greaterThan) { | |
| effects.exit(types.chunkString); | |
| effects.exit(stringType); | |
| return enclosedBefore(code); | |
| } | |
| if (code === codes.eof || code === codes.lessThan || markdownLineEnding(code)) return nok(code); | |
| effects.consume(code); | |
| return code === codes.backslash ? enclosedEscape : enclosed; | |
| } | |
| /** | |
| * After `\`, at a special character. | |
| * | |
| * ```markdown | |
| * > | <a\*a> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function enclosedEscape(code) { | |
| if (code === codes.lessThan || code === codes.greaterThan || code === codes.backslash) { | |
| effects.consume(code); | |
| return enclosed; | |
| } | |
| return enclosed(code); | |
| } | |
| /** | |
| * In raw destination. | |
| * | |
| * ```markdown | |
| * > | aa | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function raw(code) { | |
| if (!balance && (code === codes.eof || code === codes.rightParenthesis || markdownLineEndingOrSpace(code))) { | |
| effects.exit(types.chunkString); | |
| effects.exit(stringType); | |
| effects.exit(rawType); | |
| effects.exit(type); | |
| return ok(code); | |
| } | |
| if (balance < limit && code === codes.leftParenthesis) { | |
| effects.consume(code); | |
| balance++; | |
| return raw; | |
| } | |
| if (code === codes.rightParenthesis) { | |
| effects.consume(code); | |
| balance--; | |
| return raw; | |
| } | |
| if (code === codes.eof || code === codes.space || code === codes.leftParenthesis || asciiControl(code)) return nok(code); | |
| effects.consume(code); | |
| return code === codes.backslash ? rawEscape : raw; | |
| } | |
| /** | |
| * After `\`, at special character. | |
| * | |
| * ```markdown | |
| * > | a\*a | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function rawEscape(code) { | |
| if (code === codes.leftParenthesis || code === codes.rightParenthesis || code === codes.backslash) { | |
| effects.consume(code); | |
| return raw; | |
| } | |
| return raw(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-factory-label/dev/index.js | |
| /** | |
| * @import { | |
| * Effects, | |
| * State, | |
| * TokenizeContext, | |
| * TokenType | |
| * } from 'micromark-util-types' | |
| */ | |
| /** | |
| * Parse labels. | |
| * | |
| * > 👉 **Note**: labels in markdown are capped at 999 characters in the string. | |
| * | |
| * ###### Examples | |
| * | |
| * ```markdown | |
| * [a] | |
| * [a | |
| * b] | |
| * [a\]b] | |
| * ``` | |
| * | |
| * @this {TokenizeContext} | |
| * Tokenize context. | |
| * @param {Effects} effects | |
| * Context. | |
| * @param {State} ok | |
| * State switched to when successful. | |
| * @param {State} nok | |
| * State switched to when unsuccessful. | |
| * @param {TokenType} type | |
| * Type of the whole label (`[a]`). | |
| * @param {TokenType} markerType | |
| * Type for the markers (`[` and `]`). | |
| * @param {TokenType} stringType | |
| * Type for the identifier (`a`). | |
| * @returns {State} | |
| * Start state. | |
| */ | |
| function factoryLabel(effects, ok$21, nok, type, markerType, stringType) { | |
| const self = this; | |
| let size = 0; | |
| /** @type {boolean} */ | |
| let seen; | |
| return start; | |
| /** | |
| * Start of label. | |
| * | |
| * ```markdown | |
| * > | [a] | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| ok(code === codes.leftSquareBracket, "expected `[`"); | |
| effects.enter(type); | |
| effects.enter(markerType); | |
| effects.consume(code); | |
| effects.exit(markerType); | |
| effects.enter(stringType); | |
| return atBreak; | |
| } | |
| /** | |
| * In label, at something, before something else. | |
| * | |
| * ```markdown | |
| * > | [a] | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function atBreak(code) { | |
| if (size > constants.linkReferenceSizeMax || code === codes.eof || code === codes.leftSquareBracket || code === codes.rightSquareBracket && !seen || code === codes.caret && !size && "_hiddenFootnoteSupport" in self.parser.constructs) return nok(code); | |
| if (code === codes.rightSquareBracket) { | |
| effects.exit(stringType); | |
| effects.enter(markerType); | |
| effects.consume(code); | |
| effects.exit(markerType); | |
| effects.exit(type); | |
| return ok$21; | |
| } | |
| if (markdownLineEnding(code)) { | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| return atBreak; | |
| } | |
| effects.enter(types.chunkString, { contentType: constants.contentTypeString }); | |
| return labelInside(code); | |
| } | |
| /** | |
| * In label, in text. | |
| * | |
| * ```markdown | |
| * > | [a] | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function labelInside(code) { | |
| if (code === codes.eof || code === codes.leftSquareBracket || code === codes.rightSquareBracket || markdownLineEnding(code) || size++ > constants.linkReferenceSizeMax) { | |
| effects.exit(types.chunkString); | |
| return atBreak(code); | |
| } | |
| effects.consume(code); | |
| if (!seen) seen = !markdownSpace(code); | |
| return code === codes.backslash ? labelEscape : labelInside; | |
| } | |
| /** | |
| * After `\`, at a special character. | |
| * | |
| * ```markdown | |
| * > | [a\*a] | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function labelEscape(code) { | |
| if (code === codes.leftSquareBracket || code === codes.backslash || code === codes.rightSquareBracket) { | |
| effects.consume(code); | |
| size++; | |
| return labelInside; | |
| } | |
| return labelInside(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-factory-title/dev/index.js | |
| /** | |
| * @import { | |
| * Code, | |
| * Effects, | |
| * State, | |
| * TokenType | |
| * } from 'micromark-util-types' | |
| */ | |
| /** | |
| * Parse titles. | |
| * | |
| * ###### Examples | |
| * | |
| * ```markdown | |
| * "a" | |
| * 'b' | |
| * (c) | |
| * "a | |
| * b" | |
| * 'a | |
| * b' | |
| * (a\)b) | |
| * ``` | |
| * | |
| * @param {Effects} effects | |
| * Context. | |
| * @param {State} ok | |
| * State switched to when successful. | |
| * @param {State} nok | |
| * State switched to when unsuccessful. | |
| * @param {TokenType} type | |
| * Type of the whole title (`"a"`, `'b'`, `(c)`). | |
| * @param {TokenType} markerType | |
| * Type for the markers (`"`, `'`, `(`, and `)`). | |
| * @param {TokenType} stringType | |
| * Type for the value (`a`). | |
| * @returns {State} | |
| * Start state. | |
| */ | |
| function factoryTitle(effects, ok, nok, type, markerType, stringType) { | |
| /** @type {NonNullable<Code>} */ | |
| let marker; | |
| return start; | |
| /** | |
| * Start of title. | |
| * | |
| * ```markdown | |
| * > | "a" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| if (code === codes.quotationMark || code === codes.apostrophe || code === codes.leftParenthesis) { | |
| effects.enter(type); | |
| effects.enter(markerType); | |
| effects.consume(code); | |
| effects.exit(markerType); | |
| marker = code === codes.leftParenthesis ? codes.rightParenthesis : code; | |
| return begin; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After opening marker. | |
| * | |
| * This is also used at the closing marker. | |
| * | |
| * ```markdown | |
| * > | "a" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function begin(code) { | |
| if (code === marker) { | |
| effects.enter(markerType); | |
| effects.consume(code); | |
| effects.exit(markerType); | |
| effects.exit(type); | |
| return ok; | |
| } | |
| effects.enter(stringType); | |
| return atBreak(code); | |
| } | |
| /** | |
| * At something, before something else. | |
| * | |
| * ```markdown | |
| * > | "a" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function atBreak(code) { | |
| if (code === marker) { | |
| effects.exit(stringType); | |
| return begin(marker); | |
| } | |
| if (code === codes.eof) return nok(code); | |
| if (markdownLineEnding(code)) { | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| return factorySpace(effects, atBreak, types.linePrefix); | |
| } | |
| effects.enter(types.chunkString, { contentType: constants.contentTypeString }); | |
| return inside(code); | |
| } | |
| /** | |
| * | |
| * | |
| * @type {State} | |
| */ | |
| function inside(code) { | |
| if (code === marker || code === codes.eof || markdownLineEnding(code)) { | |
| effects.exit(types.chunkString); | |
| return atBreak(code); | |
| } | |
| effects.consume(code); | |
| return code === codes.backslash ? escape : inside; | |
| } | |
| /** | |
| * After `\`, at a special character. | |
| * | |
| * ```markdown | |
| * > | "a\*b" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function escape(code) { | |
| if (code === marker || code === codes.backslash) { | |
| effects.consume(code); | |
| return inside; | |
| } | |
| return inside(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-factory-whitespace/dev/index.js | |
| /** | |
| * @import {Effects, State} from 'micromark-util-types' | |
| */ | |
| /** | |
| * Parse spaces and tabs. | |
| * | |
| * There is no `nok` parameter: | |
| * | |
| * * line endings or spaces in markdown are often optional, in which case this | |
| * factory can be used and `ok` will be switched to whether spaces were found | |
| * or not | |
| * * one line ending or space can be detected with | |
| * `markdownLineEndingOrSpace(code)` right before using `factoryWhitespace` | |
| * | |
| * @param {Effects} effects | |
| * Context. | |
| * @param {State} ok | |
| * State switched to when successful. | |
| * @returns {State} | |
| * Start state. | |
| */ | |
| function factoryWhitespace(effects, ok) { | |
| /** @type {boolean} */ | |
| let seen; | |
| return start; | |
| /** @type {State} */ | |
| function start(code) { | |
| if (markdownLineEnding(code)) { | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| seen = true; | |
| return start; | |
| } | |
| if (markdownSpace(code)) return factorySpace(effects, start, seen ? types.linePrefix : types.lineSuffix)(code); | |
| return ok(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/definition.js | |
| /** | |
| * @import { | |
| * Construct, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var definition = { | |
| name: "definition", | |
| tokenize: tokenizeDefinition | |
| }; | |
| /** @type {Construct} */ | |
| var titleBefore = { | |
| partial: true, | |
| tokenize: tokenizeTitleBefore | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeDefinition(effects, ok$20, nok) { | |
| const self = this; | |
| /** @type {string} */ | |
| let identifier; | |
| return start; | |
| /** | |
| * At start of a definition. | |
| * | |
| * ```markdown | |
| * > | [a]: b "c" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| effects.enter(types.definition); | |
| return before(code); | |
| } | |
| /** | |
| * After optional whitespace, at `[`. | |
| * | |
| * ```markdown | |
| * > | [a]: b "c" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function before(code) { | |
| ok(code === codes.leftSquareBracket, "expected `[`"); | |
| return factoryLabel.call(self, effects, labelAfter, nok, types.definitionLabel, types.definitionLabelMarker, types.definitionLabelString)(code); | |
| } | |
| /** | |
| * After label. | |
| * | |
| * ```markdown | |
| * > | [a]: b "c" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function labelAfter(code) { | |
| identifier = normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1)); | |
| if (code === codes.colon) { | |
| effects.enter(types.definitionMarker); | |
| effects.consume(code); | |
| effects.exit(types.definitionMarker); | |
| return markerAfter; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After marker. | |
| * | |
| * ```markdown | |
| * > | [a]: b "c" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function markerAfter(code) { | |
| return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, destinationBefore)(code) : destinationBefore(code); | |
| } | |
| /** | |
| * Before destination. | |
| * | |
| * ```markdown | |
| * > | [a]: b "c" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function destinationBefore(code) { | |
| return factoryDestination(effects, destinationAfter, nok, types.definitionDestination, types.definitionDestinationLiteral, types.definitionDestinationLiteralMarker, types.definitionDestinationRaw, types.definitionDestinationString)(code); | |
| } | |
| /** | |
| * After destination. | |
| * | |
| * ```markdown | |
| * > | [a]: b "c" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function destinationAfter(code) { | |
| return effects.attempt(titleBefore, after, after)(code); | |
| } | |
| /** | |
| * After definition. | |
| * | |
| * ```markdown | |
| * > | [a]: b | |
| * ^ | |
| * > | [a]: b "c" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function after(code) { | |
| return markdownSpace(code) ? factorySpace(effects, afterWhitespace, types.whitespace)(code) : afterWhitespace(code); | |
| } | |
| /** | |
| * After definition, after optional whitespace. | |
| * | |
| * ```markdown | |
| * > | [a]: b | |
| * ^ | |
| * > | [a]: b "c" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function afterWhitespace(code) { | |
| if (code === codes.eof || markdownLineEnding(code)) { | |
| effects.exit(types.definition); | |
| self.parser.defined.push(identifier); | |
| return ok$20(code); | |
| } | |
| return nok(code); | |
| } | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeTitleBefore(effects, ok, nok) { | |
| return titleBefore; | |
| /** | |
| * After destination, at whitespace. | |
| * | |
| * ```markdown | |
| * > | [a]: b | |
| * ^ | |
| * > | [a]: b "c" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function titleBefore(code) { | |
| return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, beforeMarker)(code) : nok(code); | |
| } | |
| /** | |
| * At title. | |
| * | |
| * ```markdown | |
| * | [a]: b | |
| * > | "c" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function beforeMarker(code) { | |
| return factoryTitle(effects, titleAfter, nok, types.definitionTitle, types.definitionTitleMarker, types.definitionTitleString)(code); | |
| } | |
| /** | |
| * After title. | |
| * | |
| * ```markdown | |
| * > | [a]: b "c" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function titleAfter(code) { | |
| return markdownSpace(code) ? factorySpace(effects, titleAfterOptionalWhitespace, types.whitespace)(code) : titleAfterOptionalWhitespace(code); | |
| } | |
| /** | |
| * After title, after optional whitespace. | |
| * | |
| * ```markdown | |
| * > | [a]: b "c" | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function titleAfterOptionalWhitespace(code) { | |
| return code === codes.eof || markdownLineEnding(code) ? ok(code) : nok(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/hard-break-escape.js | |
| /** | |
| * @import { | |
| * Construct, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var hardBreakEscape = { | |
| name: "hardBreakEscape", | |
| tokenize: tokenizeHardBreakEscape | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeHardBreakEscape(effects, ok$19, nok) { | |
| return start; | |
| /** | |
| * Start of a hard break (escape). | |
| * | |
| * ```markdown | |
| * > | a\ | |
| * ^ | |
| * | b | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| ok(code === codes.backslash, "expected `\\`"); | |
| effects.enter(types.hardBreakEscape); | |
| effects.consume(code); | |
| return after; | |
| } | |
| /** | |
| * After `\`, at eol. | |
| * | |
| * ```markdown | |
| * > | a\ | |
| * ^ | |
| * | b | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function after(code) { | |
| if (markdownLineEnding(code)) { | |
| effects.exit(types.hardBreakEscape); | |
| return ok$19(code); | |
| } | |
| return nok(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/heading-atx.js | |
| /** | |
| * @import { | |
| * Construct, | |
| * Resolver, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer, | |
| * Token | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var headingAtx = { | |
| name: "headingAtx", | |
| resolve: resolveHeadingAtx, | |
| tokenize: tokenizeHeadingAtx | |
| }; | |
| /** @type {Resolver} */ | |
| function resolveHeadingAtx(events, context) { | |
| let contentEnd = events.length - 2; | |
| let contentStart = 3; | |
| /** @type {Token} */ | |
| let content; | |
| /** @type {Token} */ | |
| let text; | |
| if (events[contentStart][1].type === types.whitespace) contentStart += 2; | |
| if (contentEnd - 2 > contentStart && events[contentEnd][1].type === types.whitespace) contentEnd -= 2; | |
| if (events[contentEnd][1].type === types.atxHeadingSequence && (contentStart === contentEnd - 1 || contentEnd - 4 > contentStart && events[contentEnd - 2][1].type === types.whitespace)) contentEnd -= contentStart + 1 === contentEnd ? 2 : 4; | |
| if (contentEnd > contentStart) { | |
| content = { | |
| type: types.atxHeadingText, | |
| start: events[contentStart][1].start, | |
| end: events[contentEnd][1].end | |
| }; | |
| text = { | |
| type: types.chunkText, | |
| start: events[contentStart][1].start, | |
| end: events[contentEnd][1].end, | |
| contentType: constants.contentTypeText | |
| }; | |
| splice(events, contentStart, contentEnd - contentStart + 1, [ | |
| [ | |
| "enter", | |
| content, | |
| context | |
| ], | |
| [ | |
| "enter", | |
| text, | |
| context | |
| ], | |
| [ | |
| "exit", | |
| text, | |
| context | |
| ], | |
| [ | |
| "exit", | |
| content, | |
| context | |
| ] | |
| ]); | |
| } | |
| return events; | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeHeadingAtx(effects, ok$18, nok) { | |
| let size = 0; | |
| return start; | |
| /** | |
| * Start of a heading (atx). | |
| * | |
| * ```markdown | |
| * > | ## aa | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| effects.enter(types.atxHeading); | |
| return before(code); | |
| } | |
| /** | |
| * After optional whitespace, at `#`. | |
| * | |
| * ```markdown | |
| * > | ## aa | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function before(code) { | |
| ok(code === codes.numberSign, "expected `#`"); | |
| effects.enter(types.atxHeadingSequence); | |
| return sequenceOpen(code); | |
| } | |
| /** | |
| * In opening sequence. | |
| * | |
| * ```markdown | |
| * > | ## aa | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function sequenceOpen(code) { | |
| if (code === codes.numberSign && size++ < constants.atxHeadingOpeningFenceSizeMax) { | |
| effects.consume(code); | |
| return sequenceOpen; | |
| } | |
| if (code === codes.eof || markdownLineEndingOrSpace(code)) { | |
| effects.exit(types.atxHeadingSequence); | |
| return atBreak(code); | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After something, before something else. | |
| * | |
| * ```markdown | |
| * > | ## aa | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function atBreak(code) { | |
| if (code === codes.numberSign) { | |
| effects.enter(types.atxHeadingSequence); | |
| return sequenceFurther(code); | |
| } | |
| if (code === codes.eof || markdownLineEnding(code)) { | |
| effects.exit(types.atxHeading); | |
| return ok$18(code); | |
| } | |
| if (markdownSpace(code)) return factorySpace(effects, atBreak, types.whitespace)(code); | |
| effects.enter(types.atxHeadingText); | |
| return data(code); | |
| } | |
| /** | |
| * In further sequence (after whitespace). | |
| * | |
| * Could be normal “visible” hashes in the heading or a final sequence. | |
| * | |
| * ```markdown | |
| * > | ## aa ## | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function sequenceFurther(code) { | |
| if (code === codes.numberSign) { | |
| effects.consume(code); | |
| return sequenceFurther; | |
| } | |
| effects.exit(types.atxHeadingSequence); | |
| return atBreak(code); | |
| } | |
| /** | |
| * In text. | |
| * | |
| * ```markdown | |
| * > | ## aa | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function data(code) { | |
| if (code === codes.eof || code === codes.numberSign || markdownLineEndingOrSpace(code)) { | |
| effects.exit(types.atxHeadingText); | |
| return atBreak(code); | |
| } | |
| effects.consume(code); | |
| return data; | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-util-html-tag-name/index.js | |
| /** | |
| * List of lowercase HTML “block” tag names. | |
| * | |
| * The list, when parsing HTML (flow), results in more relaxed rules (condition | |
| * 6). | |
| * Because they are known blocks, the HTML-like syntax doesn’t have to be | |
| * strictly parsed. | |
| * For tag names not in this list, a more strict algorithm (condition 7) is used | |
| * to detect whether the HTML-like syntax is seen as HTML (flow) or not. | |
| * | |
| * This is copied from: | |
| * <https://spec.commonmark.org/0.30/#html-blocks>. | |
| * | |
| * > 👉 **Note**: `search` was added in `CommonMark@0.31`. | |
| */ | |
| var htmlBlockNames = [ | |
| "address", | |
| "article", | |
| "aside", | |
| "base", | |
| "basefont", | |
| "blockquote", | |
| "body", | |
| "caption", | |
| "center", | |
| "col", | |
| "colgroup", | |
| "dd", | |
| "details", | |
| "dialog", | |
| "dir", | |
| "div", | |
| "dl", | |
| "dt", | |
| "fieldset", | |
| "figcaption", | |
| "figure", | |
| "footer", | |
| "form", | |
| "frame", | |
| "frameset", | |
| "h1", | |
| "h2", | |
| "h3", | |
| "h4", | |
| "h5", | |
| "h6", | |
| "head", | |
| "header", | |
| "hr", | |
| "html", | |
| "iframe", | |
| "legend", | |
| "li", | |
| "link", | |
| "main", | |
| "menu", | |
| "menuitem", | |
| "nav", | |
| "noframes", | |
| "ol", | |
| "optgroup", | |
| "option", | |
| "p", | |
| "param", | |
| "search", | |
| "section", | |
| "summary", | |
| "table", | |
| "tbody", | |
| "td", | |
| "tfoot", | |
| "th", | |
| "thead", | |
| "title", | |
| "tr", | |
| "track", | |
| "ul" | |
| ]; | |
| /** | |
| * List of lowercase HTML “raw” tag names. | |
| * | |
| * The list, when parsing HTML (flow), results in HTML that can include lines | |
| * without exiting, until a closing tag also in this list is found (condition | |
| * 1). | |
| * | |
| * This module is copied from: | |
| * <https://spec.commonmark.org/0.30/#html-blocks>. | |
| * | |
| * > 👉 **Note**: `textarea` was added in `CommonMark@0.30`. | |
| */ | |
| var htmlRawNames = [ | |
| "pre", | |
| "script", | |
| "style", | |
| "textarea" | |
| ]; | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/html-flow.js | |
| /** | |
| * @import { | |
| * Code, | |
| * Construct, | |
| * Resolver, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var htmlFlow = { | |
| concrete: true, | |
| name: "htmlFlow", | |
| resolveTo: resolveToHtmlFlow, | |
| tokenize: tokenizeHtmlFlow | |
| }; | |
| /** @type {Construct} */ | |
| var blankLineBefore = { | |
| partial: true, | |
| tokenize: tokenizeBlankLineBefore | |
| }; | |
| var nonLazyContinuationStart = { | |
| partial: true, | |
| tokenize: tokenizeNonLazyContinuationStart | |
| }; | |
| /** @type {Resolver} */ | |
| function resolveToHtmlFlow(events) { | |
| let index = events.length; | |
| while (index--) if (events[index][0] === "enter" && events[index][1].type === types.htmlFlow) break; | |
| if (index > 1 && events[index - 2][1].type === types.linePrefix) { | |
| events[index][1].start = events[index - 2][1].start; | |
| events[index + 1][1].start = events[index - 2][1].start; | |
| events.splice(index - 2, 2); | |
| } | |
| return events; | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeHtmlFlow(effects, ok$16, nok) { | |
| const self = this; | |
| /** @type {number} */ | |
| let marker; | |
| /** @type {boolean} */ | |
| let closingTag; | |
| /** @type {string} */ | |
| let buffer; | |
| /** @type {number} */ | |
| let index; | |
| /** @type {Code} */ | |
| let markerB; | |
| return start; | |
| /** | |
| * Start of HTML (flow). | |
| * | |
| * ```markdown | |
| * > | <x /> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| return before(code); | |
| } | |
| /** | |
| * At `<`, after optional whitespace. | |
| * | |
| * ```markdown | |
| * > | <x /> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function before(code) { | |
| ok(code === codes.lessThan, "expected `<`"); | |
| effects.enter(types.htmlFlow); | |
| effects.enter(types.htmlFlowData); | |
| effects.consume(code); | |
| return open; | |
| } | |
| /** | |
| * After `<`, at tag name or other stuff. | |
| * | |
| * ```markdown | |
| * > | <x /> | |
| * ^ | |
| * > | <!doctype> | |
| * ^ | |
| * > | <!--xxx--> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function open(code) { | |
| if (code === codes.exclamationMark) { | |
| effects.consume(code); | |
| return declarationOpen; | |
| } | |
| if (code === codes.slash) { | |
| effects.consume(code); | |
| closingTag = true; | |
| return tagCloseStart; | |
| } | |
| if (code === codes.questionMark) { | |
| effects.consume(code); | |
| marker = constants.htmlInstruction; | |
| return self.interrupt ? ok$16 : continuationDeclarationInside; | |
| } | |
| if (asciiAlpha(code)) { | |
| ok(code !== null); | |
| effects.consume(code); | |
| buffer = String.fromCharCode(code); | |
| return tagName; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After `<!`, at declaration, comment, or CDATA. | |
| * | |
| * ```markdown | |
| * > | <!doctype> | |
| * ^ | |
| * > | <!--xxx--> | |
| * ^ | |
| * > | <![CDATA[>&<]]> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function declarationOpen(code) { | |
| if (code === codes.dash) { | |
| effects.consume(code); | |
| marker = constants.htmlComment; | |
| return commentOpenInside; | |
| } | |
| if (code === codes.leftSquareBracket) { | |
| effects.consume(code); | |
| marker = constants.htmlCdata; | |
| index = 0; | |
| return cdataOpenInside; | |
| } | |
| if (asciiAlpha(code)) { | |
| effects.consume(code); | |
| marker = constants.htmlDeclaration; | |
| return self.interrupt ? ok$16 : continuationDeclarationInside; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After `<!-`, inside a comment, at another `-`. | |
| * | |
| * ```markdown | |
| * > | <!--xxx--> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function commentOpenInside(code) { | |
| if (code === codes.dash) { | |
| effects.consume(code); | |
| return self.interrupt ? ok$16 : continuationDeclarationInside; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After `<![`, inside CDATA, expecting `CDATA[`. | |
| * | |
| * ```markdown | |
| * > | <![CDATA[>&<]]> | |
| * ^^^^^^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function cdataOpenInside(code) { | |
| const value = constants.cdataOpeningString; | |
| if (code === value.charCodeAt(index++)) { | |
| effects.consume(code); | |
| if (index === value.length) return self.interrupt ? ok$16 : continuation; | |
| return cdataOpenInside; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After `</`, in closing tag, at tag name. | |
| * | |
| * ```markdown | |
| * > | </x> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function tagCloseStart(code) { | |
| if (asciiAlpha(code)) { | |
| ok(code !== null); | |
| effects.consume(code); | |
| buffer = String.fromCharCode(code); | |
| return tagName; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * In tag name. | |
| * | |
| * ```markdown | |
| * > | <ab> | |
| * ^^ | |
| * > | </ab> | |
| * ^^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function tagName(code) { | |
| if (code === codes.eof || code === codes.slash || code === codes.greaterThan || markdownLineEndingOrSpace(code)) { | |
| const slash = code === codes.slash; | |
| const name = buffer.toLowerCase(); | |
| if (!slash && !closingTag && htmlRawNames.includes(name)) { | |
| marker = constants.htmlRaw; | |
| return self.interrupt ? ok$16(code) : continuation(code); | |
| } | |
| if (htmlBlockNames.includes(buffer.toLowerCase())) { | |
| marker = constants.htmlBasic; | |
| if (slash) { | |
| effects.consume(code); | |
| return basicSelfClosing; | |
| } | |
| return self.interrupt ? ok$16(code) : continuation(code); | |
| } | |
| marker = constants.htmlComplete; | |
| return self.interrupt && !self.parser.lazy[self.now().line] ? nok(code) : closingTag ? completeClosingTagAfter(code) : completeAttributeNameBefore(code); | |
| } | |
| if (code === codes.dash || asciiAlphanumeric(code)) { | |
| effects.consume(code); | |
| buffer += String.fromCharCode(code); | |
| return tagName; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After closing slash of a basic tag name. | |
| * | |
| * ```markdown | |
| * > | <div/> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function basicSelfClosing(code) { | |
| if (code === codes.greaterThan) { | |
| effects.consume(code); | |
| return self.interrupt ? ok$16 : continuation; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After closing slash of a complete tag name. | |
| * | |
| * ```markdown | |
| * > | <x/> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function completeClosingTagAfter(code) { | |
| if (markdownSpace(code)) { | |
| effects.consume(code); | |
| return completeClosingTagAfter; | |
| } | |
| return completeEnd(code); | |
| } | |
| /** | |
| * At an attribute name. | |
| * | |
| * At first, this state is used after a complete tag name, after whitespace, | |
| * where it expects optional attributes or the end of the tag. | |
| * It is also reused after attributes, when expecting more optional | |
| * attributes. | |
| * | |
| * ```markdown | |
| * > | <a /> | |
| * ^ | |
| * > | <a :b> | |
| * ^ | |
| * > | <a _b> | |
| * ^ | |
| * > | <a b> | |
| * ^ | |
| * > | <a > | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function completeAttributeNameBefore(code) { | |
| if (code === codes.slash) { | |
| effects.consume(code); | |
| return completeEnd; | |
| } | |
| if (code === codes.colon || code === codes.underscore || asciiAlpha(code)) { | |
| effects.consume(code); | |
| return completeAttributeName; | |
| } | |
| if (markdownSpace(code)) { | |
| effects.consume(code); | |
| return completeAttributeNameBefore; | |
| } | |
| return completeEnd(code); | |
| } | |
| /** | |
| * In attribute name. | |
| * | |
| * ```markdown | |
| * > | <a :b> | |
| * ^ | |
| * > | <a _b> | |
| * ^ | |
| * > | <a b> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function completeAttributeName(code) { | |
| if (code === codes.dash || code === codes.dot || code === codes.colon || code === codes.underscore || asciiAlphanumeric(code)) { | |
| effects.consume(code); | |
| return completeAttributeName; | |
| } | |
| return completeAttributeNameAfter(code); | |
| } | |
| /** | |
| * After attribute name, at an optional initializer, the end of the tag, or | |
| * whitespace. | |
| * | |
| * ```markdown | |
| * > | <a b> | |
| * ^ | |
| * > | <a b=c> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function completeAttributeNameAfter(code) { | |
| if (code === codes.equalsTo) { | |
| effects.consume(code); | |
| return completeAttributeValueBefore; | |
| } | |
| if (markdownSpace(code)) { | |
| effects.consume(code); | |
| return completeAttributeNameAfter; | |
| } | |
| return completeAttributeNameBefore(code); | |
| } | |
| /** | |
| * Before unquoted, double quoted, or single quoted attribute value, allowing | |
| * whitespace. | |
| * | |
| * ```markdown | |
| * > | <a b=c> | |
| * ^ | |
| * > | <a b="c"> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function completeAttributeValueBefore(code) { | |
| if (code === codes.eof || code === codes.lessThan || code === codes.equalsTo || code === codes.greaterThan || code === codes.graveAccent) return nok(code); | |
| if (code === codes.quotationMark || code === codes.apostrophe) { | |
| effects.consume(code); | |
| markerB = code; | |
| return completeAttributeValueQuoted; | |
| } | |
| if (markdownSpace(code)) { | |
| effects.consume(code); | |
| return completeAttributeValueBefore; | |
| } | |
| return completeAttributeValueUnquoted(code); | |
| } | |
| /** | |
| * In double or single quoted attribute value. | |
| * | |
| * ```markdown | |
| * > | <a b="c"> | |
| * ^ | |
| * > | <a b='c'> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function completeAttributeValueQuoted(code) { | |
| if (code === markerB) { | |
| effects.consume(code); | |
| markerB = null; | |
| return completeAttributeValueQuotedAfter; | |
| } | |
| if (code === codes.eof || markdownLineEnding(code)) return nok(code); | |
| effects.consume(code); | |
| return completeAttributeValueQuoted; | |
| } | |
| /** | |
| * In unquoted attribute value. | |
| * | |
| * ```markdown | |
| * > | <a b=c> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function completeAttributeValueUnquoted(code) { | |
| if (code === codes.eof || code === codes.quotationMark || code === codes.apostrophe || code === codes.slash || code === codes.lessThan || code === codes.equalsTo || code === codes.greaterThan || code === codes.graveAccent || markdownLineEndingOrSpace(code)) return completeAttributeNameAfter(code); | |
| effects.consume(code); | |
| return completeAttributeValueUnquoted; | |
| } | |
| /** | |
| * After double or single quoted attribute value, before whitespace or the | |
| * end of the tag. | |
| * | |
| * ```markdown | |
| * > | <a b="c"> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function completeAttributeValueQuotedAfter(code) { | |
| if (code === codes.slash || code === codes.greaterThan || markdownSpace(code)) return completeAttributeNameBefore(code); | |
| return nok(code); | |
| } | |
| /** | |
| * In certain circumstances of a complete tag where only an `>` is allowed. | |
| * | |
| * ```markdown | |
| * > | <a b="c"> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function completeEnd(code) { | |
| if (code === codes.greaterThan) { | |
| effects.consume(code); | |
| return completeAfter; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After `>` in a complete tag. | |
| * | |
| * ```markdown | |
| * > | <x> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function completeAfter(code) { | |
| if (code === codes.eof || markdownLineEnding(code)) return continuation(code); | |
| if (markdownSpace(code)) { | |
| effects.consume(code); | |
| return completeAfter; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * In continuation of any HTML kind. | |
| * | |
| * ```markdown | |
| * > | <!--xxx--> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function continuation(code) { | |
| if (code === codes.dash && marker === constants.htmlComment) { | |
| effects.consume(code); | |
| return continuationCommentInside; | |
| } | |
| if (code === codes.lessThan && marker === constants.htmlRaw) { | |
| effects.consume(code); | |
| return continuationRawTagOpen; | |
| } | |
| if (code === codes.greaterThan && marker === constants.htmlDeclaration) { | |
| effects.consume(code); | |
| return continuationClose; | |
| } | |
| if (code === codes.questionMark && marker === constants.htmlInstruction) { | |
| effects.consume(code); | |
| return continuationDeclarationInside; | |
| } | |
| if (code === codes.rightSquareBracket && marker === constants.htmlCdata) { | |
| effects.consume(code); | |
| return continuationCdataInside; | |
| } | |
| if (markdownLineEnding(code) && (marker === constants.htmlBasic || marker === constants.htmlComplete)) { | |
| effects.exit(types.htmlFlowData); | |
| return effects.check(blankLineBefore, continuationAfter, continuationStart)(code); | |
| } | |
| if (code === codes.eof || markdownLineEnding(code)) { | |
| effects.exit(types.htmlFlowData); | |
| return continuationStart(code); | |
| } | |
| effects.consume(code); | |
| return continuation; | |
| } | |
| /** | |
| * In continuation, at eol. | |
| * | |
| * ```markdown | |
| * > | <x> | |
| * ^ | |
| * | asd | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function continuationStart(code) { | |
| return effects.check(nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code); | |
| } | |
| /** | |
| * In continuation, at eol, before non-lazy content. | |
| * | |
| * ```markdown | |
| * > | <x> | |
| * ^ | |
| * | asd | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function continuationStartNonLazy(code) { | |
| ok(markdownLineEnding(code)); | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| return continuationBefore; | |
| } | |
| /** | |
| * In continuation, before non-lazy content. | |
| * | |
| * ```markdown | |
| * | <x> | |
| * > | asd | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function continuationBefore(code) { | |
| if (code === codes.eof || markdownLineEnding(code)) return continuationStart(code); | |
| effects.enter(types.htmlFlowData); | |
| return continuation(code); | |
| } | |
| /** | |
| * In comment continuation, after one `-`, expecting another. | |
| * | |
| * ```markdown | |
| * > | <!--xxx--> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function continuationCommentInside(code) { | |
| if (code === codes.dash) { | |
| effects.consume(code); | |
| return continuationDeclarationInside; | |
| } | |
| return continuation(code); | |
| } | |
| /** | |
| * In raw continuation, after `<`, at `/`. | |
| * | |
| * ```markdown | |
| * > | <script>console.log(1)<\/script> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function continuationRawTagOpen(code) { | |
| if (code === codes.slash) { | |
| effects.consume(code); | |
| buffer = ""; | |
| return continuationRawEndTag; | |
| } | |
| return continuation(code); | |
| } | |
| /** | |
| * In raw continuation, after `</`, in a raw tag name. | |
| * | |
| * ```markdown | |
| * > | <script>console.log(1)<\/script> | |
| * ^^^^^^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function continuationRawEndTag(code) { | |
| if (code === codes.greaterThan) { | |
| const name = buffer.toLowerCase(); | |
| if (htmlRawNames.includes(name)) { | |
| effects.consume(code); | |
| return continuationClose; | |
| } | |
| return continuation(code); | |
| } | |
| if (asciiAlpha(code) && buffer.length < constants.htmlRawSizeMax) { | |
| ok(code !== null); | |
| effects.consume(code); | |
| buffer += String.fromCharCode(code); | |
| return continuationRawEndTag; | |
| } | |
| return continuation(code); | |
| } | |
| /** | |
| * In cdata continuation, after `]`, expecting `]>`. | |
| * | |
| * ```markdown | |
| * > | <![CDATA[>&<]]> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function continuationCdataInside(code) { | |
| if (code === codes.rightSquareBracket) { | |
| effects.consume(code); | |
| return continuationDeclarationInside; | |
| } | |
| return continuation(code); | |
| } | |
| /** | |
| * In declaration or instruction continuation, at `>`. | |
| * | |
| * ```markdown | |
| * > | <!--> | |
| * ^ | |
| * > | <?> | |
| * ^ | |
| * > | <!q> | |
| * ^ | |
| * > | <!--ab--> | |
| * ^ | |
| * > | <![CDATA[>&<]]> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function continuationDeclarationInside(code) { | |
| if (code === codes.greaterThan) { | |
| effects.consume(code); | |
| return continuationClose; | |
| } | |
| if (code === codes.dash && marker === constants.htmlComment) { | |
| effects.consume(code); | |
| return continuationDeclarationInside; | |
| } | |
| return continuation(code); | |
| } | |
| /** | |
| * In closed continuation: everything we get until the eol/eof is part of it. | |
| * | |
| * ```markdown | |
| * > | <!doctype> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function continuationClose(code) { | |
| if (code === codes.eof || markdownLineEnding(code)) { | |
| effects.exit(types.htmlFlowData); | |
| return continuationAfter(code); | |
| } | |
| effects.consume(code); | |
| return continuationClose; | |
| } | |
| /** | |
| * Done. | |
| * | |
| * ```markdown | |
| * > | <!doctype> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function continuationAfter(code) { | |
| effects.exit(types.htmlFlow); | |
| return ok$16(code); | |
| } | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeNonLazyContinuationStart(effects, ok, nok) { | |
| const self = this; | |
| return start; | |
| /** | |
| * At eol, before continuation. | |
| * | |
| * ```markdown | |
| * > | * ```js | |
| * ^ | |
| * | b | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| if (markdownLineEnding(code)) { | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| return after; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * A continuation. | |
| * | |
| * ```markdown | |
| * | * ```js | |
| * > | b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function after(code) { | |
| return self.parser.lazy[self.now().line] ? nok(code) : ok(code); | |
| } | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeBlankLineBefore(effects, ok$17, nok) { | |
| return start; | |
| /** | |
| * Before eol, expecting blank line. | |
| * | |
| * ```markdown | |
| * > | <div> | |
| * ^ | |
| * | | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| ok(markdownLineEnding(code), "expected a line ending"); | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| return effects.attempt(blankLine, ok$17, nok); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/html-text.js | |
| /** | |
| * @import { | |
| * Code, | |
| * Construct, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var htmlText = { | |
| name: "htmlText", | |
| tokenize: tokenizeHtmlText | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeHtmlText(effects, ok$15, nok) { | |
| const self = this; | |
| /** @type {NonNullable<Code> | undefined} */ | |
| let marker; | |
| /** @type {number} */ | |
| let index; | |
| /** @type {State} */ | |
| let returnState; | |
| return start; | |
| /** | |
| * Start of HTML (text). | |
| * | |
| * ```markdown | |
| * > | a <b> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| ok(code === codes.lessThan, "expected `<`"); | |
| effects.enter(types.htmlText); | |
| effects.enter(types.htmlTextData); | |
| effects.consume(code); | |
| return open; | |
| } | |
| /** | |
| * After `<`, at tag name or other stuff. | |
| * | |
| * ```markdown | |
| * > | a <b> c | |
| * ^ | |
| * > | a <!doctype> c | |
| * ^ | |
| * > | a <!--b--> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function open(code) { | |
| if (code === codes.exclamationMark) { | |
| effects.consume(code); | |
| return declarationOpen; | |
| } | |
| if (code === codes.slash) { | |
| effects.consume(code); | |
| return tagCloseStart; | |
| } | |
| if (code === codes.questionMark) { | |
| effects.consume(code); | |
| return instruction; | |
| } | |
| if (asciiAlpha(code)) { | |
| effects.consume(code); | |
| return tagOpen; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After `<!`, at declaration, comment, or CDATA. | |
| * | |
| * ```markdown | |
| * > | a <!doctype> c | |
| * ^ | |
| * > | a <!--b--> c | |
| * ^ | |
| * > | a <![CDATA[>&<]]> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function declarationOpen(code) { | |
| if (code === codes.dash) { | |
| effects.consume(code); | |
| return commentOpenInside; | |
| } | |
| if (code === codes.leftSquareBracket) { | |
| effects.consume(code); | |
| index = 0; | |
| return cdataOpenInside; | |
| } | |
| if (asciiAlpha(code)) { | |
| effects.consume(code); | |
| return declaration; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * In a comment, after `<!-`, at another `-`. | |
| * | |
| * ```markdown | |
| * > | a <!--b--> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function commentOpenInside(code) { | |
| if (code === codes.dash) { | |
| effects.consume(code); | |
| return commentEnd; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * In comment. | |
| * | |
| * ```markdown | |
| * > | a <!--b--> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function comment(code) { | |
| if (code === codes.eof) return nok(code); | |
| if (code === codes.dash) { | |
| effects.consume(code); | |
| return commentClose; | |
| } | |
| if (markdownLineEnding(code)) { | |
| returnState = comment; | |
| return lineEndingBefore(code); | |
| } | |
| effects.consume(code); | |
| return comment; | |
| } | |
| /** | |
| * In comment, after `-`. | |
| * | |
| * ```markdown | |
| * > | a <!--b--> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function commentClose(code) { | |
| if (code === codes.dash) { | |
| effects.consume(code); | |
| return commentEnd; | |
| } | |
| return comment(code); | |
| } | |
| /** | |
| * In comment, after `--`. | |
| * | |
| * ```markdown | |
| * > | a <!--b--> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function commentEnd(code) { | |
| return code === codes.greaterThan ? end(code) : code === codes.dash ? commentClose(code) : comment(code); | |
| } | |
| /** | |
| * After `<![`, in CDATA, expecting `CDATA[`. | |
| * | |
| * ```markdown | |
| * > | a <![CDATA[>&<]]> b | |
| * ^^^^^^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function cdataOpenInside(code) { | |
| const value = constants.cdataOpeningString; | |
| if (code === value.charCodeAt(index++)) { | |
| effects.consume(code); | |
| return index === value.length ? cdata : cdataOpenInside; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * In CDATA. | |
| * | |
| * ```markdown | |
| * > | a <![CDATA[>&<]]> b | |
| * ^^^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function cdata(code) { | |
| if (code === codes.eof) return nok(code); | |
| if (code === codes.rightSquareBracket) { | |
| effects.consume(code); | |
| return cdataClose; | |
| } | |
| if (markdownLineEnding(code)) { | |
| returnState = cdata; | |
| return lineEndingBefore(code); | |
| } | |
| effects.consume(code); | |
| return cdata; | |
| } | |
| /** | |
| * In CDATA, after `]`, at another `]`. | |
| * | |
| * ```markdown | |
| * > | a <![CDATA[>&<]]> b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function cdataClose(code) { | |
| if (code === codes.rightSquareBracket) { | |
| effects.consume(code); | |
| return cdataEnd; | |
| } | |
| return cdata(code); | |
| } | |
| /** | |
| * In CDATA, after `]]`, at `>`. | |
| * | |
| * ```markdown | |
| * > | a <![CDATA[>&<]]> b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function cdataEnd(code) { | |
| if (code === codes.greaterThan) return end(code); | |
| if (code === codes.rightSquareBracket) { | |
| effects.consume(code); | |
| return cdataEnd; | |
| } | |
| return cdata(code); | |
| } | |
| /** | |
| * In declaration. | |
| * | |
| * ```markdown | |
| * > | a <!b> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function declaration(code) { | |
| if (code === codes.eof || code === codes.greaterThan) return end(code); | |
| if (markdownLineEnding(code)) { | |
| returnState = declaration; | |
| return lineEndingBefore(code); | |
| } | |
| effects.consume(code); | |
| return declaration; | |
| } | |
| /** | |
| * In instruction. | |
| * | |
| * ```markdown | |
| * > | a <?b?> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function instruction(code) { | |
| if (code === codes.eof) return nok(code); | |
| if (code === codes.questionMark) { | |
| effects.consume(code); | |
| return instructionClose; | |
| } | |
| if (markdownLineEnding(code)) { | |
| returnState = instruction; | |
| return lineEndingBefore(code); | |
| } | |
| effects.consume(code); | |
| return instruction; | |
| } | |
| /** | |
| * In instruction, after `?`, at `>`. | |
| * | |
| * ```markdown | |
| * > | a <?b?> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function instructionClose(code) { | |
| return code === codes.greaterThan ? end(code) : instruction(code); | |
| } | |
| /** | |
| * After `</`, in closing tag, at tag name. | |
| * | |
| * ```markdown | |
| * > | a </b> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function tagCloseStart(code) { | |
| if (asciiAlpha(code)) { | |
| effects.consume(code); | |
| return tagClose; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After `</x`, in a tag name. | |
| * | |
| * ```markdown | |
| * > | a </b> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function tagClose(code) { | |
| if (code === codes.dash || asciiAlphanumeric(code)) { | |
| effects.consume(code); | |
| return tagClose; | |
| } | |
| return tagCloseBetween(code); | |
| } | |
| /** | |
| * In closing tag, after tag name. | |
| * | |
| * ```markdown | |
| * > | a </b> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function tagCloseBetween(code) { | |
| if (markdownLineEnding(code)) { | |
| returnState = tagCloseBetween; | |
| return lineEndingBefore(code); | |
| } | |
| if (markdownSpace(code)) { | |
| effects.consume(code); | |
| return tagCloseBetween; | |
| } | |
| return end(code); | |
| } | |
| /** | |
| * After `<x`, in opening tag name. | |
| * | |
| * ```markdown | |
| * > | a <b> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function tagOpen(code) { | |
| if (code === codes.dash || asciiAlphanumeric(code)) { | |
| effects.consume(code); | |
| return tagOpen; | |
| } | |
| if (code === codes.slash || code === codes.greaterThan || markdownLineEndingOrSpace(code)) return tagOpenBetween(code); | |
| return nok(code); | |
| } | |
| /** | |
| * In opening tag, after tag name. | |
| * | |
| * ```markdown | |
| * > | a <b> c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function tagOpenBetween(code) { | |
| if (code === codes.slash) { | |
| effects.consume(code); | |
| return end; | |
| } | |
| if (code === codes.colon || code === codes.underscore || asciiAlpha(code)) { | |
| effects.consume(code); | |
| return tagOpenAttributeName; | |
| } | |
| if (markdownLineEnding(code)) { | |
| returnState = tagOpenBetween; | |
| return lineEndingBefore(code); | |
| } | |
| if (markdownSpace(code)) { | |
| effects.consume(code); | |
| return tagOpenBetween; | |
| } | |
| return end(code); | |
| } | |
| /** | |
| * In attribute name. | |
| * | |
| * ```markdown | |
| * > | a <b c> d | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function tagOpenAttributeName(code) { | |
| if (code === codes.dash || code === codes.dot || code === codes.colon || code === codes.underscore || asciiAlphanumeric(code)) { | |
| effects.consume(code); | |
| return tagOpenAttributeName; | |
| } | |
| return tagOpenAttributeNameAfter(code); | |
| } | |
| /** | |
| * After attribute name, before initializer, the end of the tag, or | |
| * whitespace. | |
| * | |
| * ```markdown | |
| * > | a <b c> d | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function tagOpenAttributeNameAfter(code) { | |
| if (code === codes.equalsTo) { | |
| effects.consume(code); | |
| return tagOpenAttributeValueBefore; | |
| } | |
| if (markdownLineEnding(code)) { | |
| returnState = tagOpenAttributeNameAfter; | |
| return lineEndingBefore(code); | |
| } | |
| if (markdownSpace(code)) { | |
| effects.consume(code); | |
| return tagOpenAttributeNameAfter; | |
| } | |
| return tagOpenBetween(code); | |
| } | |
| /** | |
| * Before unquoted, double quoted, or single quoted attribute value, allowing | |
| * whitespace. | |
| * | |
| * ```markdown | |
| * > | a <b c=d> e | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function tagOpenAttributeValueBefore(code) { | |
| if (code === codes.eof || code === codes.lessThan || code === codes.equalsTo || code === codes.greaterThan || code === codes.graveAccent) return nok(code); | |
| if (code === codes.quotationMark || code === codes.apostrophe) { | |
| effects.consume(code); | |
| marker = code; | |
| return tagOpenAttributeValueQuoted; | |
| } | |
| if (markdownLineEnding(code)) { | |
| returnState = tagOpenAttributeValueBefore; | |
| return lineEndingBefore(code); | |
| } | |
| if (markdownSpace(code)) { | |
| effects.consume(code); | |
| return tagOpenAttributeValueBefore; | |
| } | |
| effects.consume(code); | |
| return tagOpenAttributeValueUnquoted; | |
| } | |
| /** | |
| * In double or single quoted attribute value. | |
| * | |
| * ```markdown | |
| * > | a <b c="d"> e | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function tagOpenAttributeValueQuoted(code) { | |
| if (code === marker) { | |
| effects.consume(code); | |
| marker = void 0; | |
| return tagOpenAttributeValueQuotedAfter; | |
| } | |
| if (code === codes.eof) return nok(code); | |
| if (markdownLineEnding(code)) { | |
| returnState = tagOpenAttributeValueQuoted; | |
| return lineEndingBefore(code); | |
| } | |
| effects.consume(code); | |
| return tagOpenAttributeValueQuoted; | |
| } | |
| /** | |
| * In unquoted attribute value. | |
| * | |
| * ```markdown | |
| * > | a <b c=d> e | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function tagOpenAttributeValueUnquoted(code) { | |
| if (code === codes.eof || code === codes.quotationMark || code === codes.apostrophe || code === codes.lessThan || code === codes.equalsTo || code === codes.graveAccent) return nok(code); | |
| if (code === codes.slash || code === codes.greaterThan || markdownLineEndingOrSpace(code)) return tagOpenBetween(code); | |
| effects.consume(code); | |
| return tagOpenAttributeValueUnquoted; | |
| } | |
| /** | |
| * After double or single quoted attribute value, before whitespace or the end | |
| * of the tag. | |
| * | |
| * ```markdown | |
| * > | a <b c="d"> e | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function tagOpenAttributeValueQuotedAfter(code) { | |
| if (code === codes.slash || code === codes.greaterThan || markdownLineEndingOrSpace(code)) return tagOpenBetween(code); | |
| return nok(code); | |
| } | |
| /** | |
| * In certain circumstances of a tag where only an `>` is allowed. | |
| * | |
| * ```markdown | |
| * > | a <b c="d"> e | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function end(code) { | |
| if (code === codes.greaterThan) { | |
| effects.consume(code); | |
| effects.exit(types.htmlTextData); | |
| effects.exit(types.htmlText); | |
| return ok$15; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * At eol. | |
| * | |
| * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about | |
| * > empty tokens. | |
| * | |
| * ```markdown | |
| * > | a <!--a | |
| * ^ | |
| * | b--> | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function lineEndingBefore(code) { | |
| ok(returnState, "expected return state"); | |
| ok(markdownLineEnding(code), "expected eol"); | |
| effects.exit(types.htmlTextData); | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| return lineEndingAfter; | |
| } | |
| /** | |
| * After eol, at optional whitespace. | |
| * | |
| * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about | |
| * > empty tokens. | |
| * | |
| * ```markdown | |
| * | a <!--a | |
| * > | b--> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function lineEndingAfter(code) { | |
| ok(self.parser.constructs.disable.null, "expected `disable.null` to be populated"); | |
| return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, types.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : constants.tabSize)(code) : lineEndingAfterPrefix(code); | |
| } | |
| /** | |
| * After eol, after optional whitespace. | |
| * | |
| * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about | |
| * > empty tokens. | |
| * | |
| * ```markdown | |
| * | a <!--a | |
| * > | b--> | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function lineEndingAfterPrefix(code) { | |
| effects.enter(types.htmlTextData); | |
| return returnState(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/label-end.js | |
| /** | |
| * @import { | |
| * Construct, | |
| * Event, | |
| * Resolver, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer, | |
| * Token | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var labelEnd = { | |
| name: "labelEnd", | |
| resolveAll: resolveAllLabelEnd, | |
| resolveTo: resolveToLabelEnd, | |
| tokenize: tokenizeLabelEnd | |
| }; | |
| /** @type {Construct} */ | |
| var resourceConstruct = { tokenize: tokenizeResource }; | |
| /** @type {Construct} */ | |
| var referenceFullConstruct = { tokenize: tokenizeReferenceFull }; | |
| /** @type {Construct} */ | |
| var referenceCollapsedConstruct = { tokenize: tokenizeReferenceCollapsed }; | |
| /** @type {Resolver} */ | |
| function resolveAllLabelEnd(events) { | |
| let index = -1; | |
| /** @type {Array<Event>} */ | |
| const newEvents = []; | |
| while (++index < events.length) { | |
| const token = events[index][1]; | |
| newEvents.push(events[index]); | |
| if (token.type === types.labelImage || token.type === types.labelLink || token.type === types.labelEnd) { | |
| const offset = token.type === types.labelImage ? 4 : 2; | |
| token.type = types.data; | |
| index += offset; | |
| } | |
| } | |
| if (events.length !== newEvents.length) splice(events, 0, events.length, newEvents); | |
| return events; | |
| } | |
| /** @type {Resolver} */ | |
| function resolveToLabelEnd(events, context) { | |
| let index = events.length; | |
| let offset = 0; | |
| /** @type {Token} */ | |
| let token; | |
| /** @type {number | undefined} */ | |
| let open; | |
| /** @type {number | undefined} */ | |
| let close; | |
| /** @type {Array<Event>} */ | |
| let media; | |
| while (index--) { | |
| token = events[index][1]; | |
| if (open) { | |
| if (token.type === types.link || token.type === types.labelLink && token._inactive) break; | |
| if (events[index][0] === "enter" && token.type === types.labelLink) token._inactive = true; | |
| } else if (close) { | |
| if (events[index][0] === "enter" && (token.type === types.labelImage || token.type === types.labelLink) && !token._balanced) { | |
| open = index; | |
| if (token.type !== types.labelLink) { | |
| offset = 2; | |
| break; | |
| } | |
| } | |
| } else if (token.type === types.labelEnd) close = index; | |
| } | |
| ok(open !== void 0, "`open` is supposed to be found"); | |
| ok(close !== void 0, "`close` is supposed to be found"); | |
| const group = { | |
| type: events[open][1].type === types.labelLink ? types.link : types.image, | |
| start: { ...events[open][1].start }, | |
| end: { ...events[events.length - 1][1].end } | |
| }; | |
| const label = { | |
| type: types.label, | |
| start: { ...events[open][1].start }, | |
| end: { ...events[close][1].end } | |
| }; | |
| const text = { | |
| type: types.labelText, | |
| start: { ...events[open + offset + 2][1].end }, | |
| end: { ...events[close - 2][1].start } | |
| }; | |
| media = [[ | |
| "enter", | |
| group, | |
| context | |
| ], [ | |
| "enter", | |
| label, | |
| context | |
| ]]; | |
| media = push(media, events.slice(open + 1, open + offset + 3)); | |
| media = push(media, [[ | |
| "enter", | |
| text, | |
| context | |
| ]]); | |
| ok(context.parser.constructs.insideSpan.null, "expected `insideSpan.null` to be populated"); | |
| media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + offset + 4, close - 3), context)); | |
| media = push(media, [ | |
| [ | |
| "exit", | |
| text, | |
| context | |
| ], | |
| events[close - 2], | |
| events[close - 1], | |
| [ | |
| "exit", | |
| label, | |
| context | |
| ] | |
| ]); | |
| media = push(media, events.slice(close + 1)); | |
| media = push(media, [[ | |
| "exit", | |
| group, | |
| context | |
| ]]); | |
| splice(events, open, events.length, media); | |
| return events; | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeLabelEnd(effects, ok$11, nok) { | |
| const self = this; | |
| let index = self.events.length; | |
| /** @type {Token} */ | |
| let labelStart; | |
| /** @type {boolean} */ | |
| let defined; | |
| while (index--) if ((self.events[index][1].type === types.labelImage || self.events[index][1].type === types.labelLink) && !self.events[index][1]._balanced) { | |
| labelStart = self.events[index][1]; | |
| break; | |
| } | |
| return start; | |
| /** | |
| * Start of label end. | |
| * | |
| * ```markdown | |
| * > | [a](b) c | |
| * ^ | |
| * > | [a][b] c | |
| * ^ | |
| * > | [a][] b | |
| * ^ | |
| * > | [a] b | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| ok(code === codes.rightSquareBracket, "expected `]`"); | |
| if (!labelStart) return nok(code); | |
| if (labelStart._inactive) return labelEndNok(code); | |
| defined = self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize({ | |
| start: labelStart.end, | |
| end: self.now() | |
| }))); | |
| effects.enter(types.labelEnd); | |
| effects.enter(types.labelMarker); | |
| effects.consume(code); | |
| effects.exit(types.labelMarker); | |
| effects.exit(types.labelEnd); | |
| return after; | |
| } | |
| /** | |
| * After `]`. | |
| * | |
| * ```markdown | |
| * > | [a](b) c | |
| * ^ | |
| * > | [a][b] c | |
| * ^ | |
| * > | [a][] b | |
| * ^ | |
| * > | [a] b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function after(code) { | |
| if (code === codes.leftParenthesis) return effects.attempt(resourceConstruct, labelEndOk, defined ? labelEndOk : labelEndNok)(code); | |
| if (code === codes.leftSquareBracket) return effects.attempt(referenceFullConstruct, labelEndOk, defined ? referenceNotFull : labelEndNok)(code); | |
| return defined ? labelEndOk(code) : labelEndNok(code); | |
| } | |
| /** | |
| * After `]`, at `[`, but not at a full reference. | |
| * | |
| * > 👉 **Note**: we only get here if the label is defined. | |
| * | |
| * ```markdown | |
| * > | [a][] b | |
| * ^ | |
| * > | [a] b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function referenceNotFull(code) { | |
| return effects.attempt(referenceCollapsedConstruct, labelEndOk, labelEndNok)(code); | |
| } | |
| /** | |
| * Done, we found something. | |
| * | |
| * ```markdown | |
| * > | [a](b) c | |
| * ^ | |
| * > | [a][b] c | |
| * ^ | |
| * > | [a][] b | |
| * ^ | |
| * > | [a] b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function labelEndOk(code) { | |
| return ok$11(code); | |
| } | |
| /** | |
| * Done, it’s nothing. | |
| * | |
| * There was an okay opening, but we didn’t match anything. | |
| * | |
| * ```markdown | |
| * > | [a](b c | |
| * ^ | |
| * > | [a][b c | |
| * ^ | |
| * > | [a] b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function labelEndNok(code) { | |
| labelStart._balanced = true; | |
| return nok(code); | |
| } | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeResource(effects, ok$12, nok) { | |
| return resourceStart; | |
| /** | |
| * At a resource. | |
| * | |
| * ```markdown | |
| * > | [a](b) c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function resourceStart(code) { | |
| ok(code === codes.leftParenthesis, "expected left paren"); | |
| effects.enter(types.resource); | |
| effects.enter(types.resourceMarker); | |
| effects.consume(code); | |
| effects.exit(types.resourceMarker); | |
| return resourceBefore; | |
| } | |
| /** | |
| * In resource, after `(`, at optional whitespace. | |
| * | |
| * ```markdown | |
| * > | [a](b) c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function resourceBefore(code) { | |
| return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceOpen)(code) : resourceOpen(code); | |
| } | |
| /** | |
| * In resource, after optional whitespace, at `)` or a destination. | |
| * | |
| * ```markdown | |
| * > | [a](b) c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function resourceOpen(code) { | |
| if (code === codes.rightParenthesis) return resourceEnd(code); | |
| return factoryDestination(effects, resourceDestinationAfter, resourceDestinationMissing, types.resourceDestination, types.resourceDestinationLiteral, types.resourceDestinationLiteralMarker, types.resourceDestinationRaw, types.resourceDestinationString, constants.linkResourceDestinationBalanceMax)(code); | |
| } | |
| /** | |
| * In resource, after destination, at optional whitespace. | |
| * | |
| * ```markdown | |
| * > | [a](b) c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function resourceDestinationAfter(code) { | |
| return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceBetween)(code) : resourceEnd(code); | |
| } | |
| /** | |
| * At invalid destination. | |
| * | |
| * ```markdown | |
| * > | [a](<<) b | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function resourceDestinationMissing(code) { | |
| return nok(code); | |
| } | |
| /** | |
| * In resource, after destination and whitespace, at `(` or title. | |
| * | |
| * ```markdown | |
| * > | [a](b ) c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function resourceBetween(code) { | |
| if (code === codes.quotationMark || code === codes.apostrophe || code === codes.leftParenthesis) return factoryTitle(effects, resourceTitleAfter, nok, types.resourceTitle, types.resourceTitleMarker, types.resourceTitleString)(code); | |
| return resourceEnd(code); | |
| } | |
| /** | |
| * In resource, after title, at optional whitespace. | |
| * | |
| * ```markdown | |
| * > | [a](b "c") d | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function resourceTitleAfter(code) { | |
| return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceEnd)(code) : resourceEnd(code); | |
| } | |
| /** | |
| * In resource, at `)`. | |
| * | |
| * ```markdown | |
| * > | [a](b) d | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function resourceEnd(code) { | |
| if (code === codes.rightParenthesis) { | |
| effects.enter(types.resourceMarker); | |
| effects.consume(code); | |
| effects.exit(types.resourceMarker); | |
| effects.exit(types.resource); | |
| return ok$12; | |
| } | |
| return nok(code); | |
| } | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeReferenceFull(effects, ok$13, nok) { | |
| const self = this; | |
| return referenceFull; | |
| /** | |
| * In a reference (full), at the `[`. | |
| * | |
| * ```markdown | |
| * > | [a][b] d | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function referenceFull(code) { | |
| ok(code === codes.leftSquareBracket, "expected left bracket"); | |
| return factoryLabel.call(self, effects, referenceFullAfter, referenceFullMissing, types.reference, types.referenceMarker, types.referenceString)(code); | |
| } | |
| /** | |
| * In a reference (full), after `]`. | |
| * | |
| * ```markdown | |
| * > | [a][b] d | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function referenceFullAfter(code) { | |
| return self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1))) ? ok$13(code) : nok(code); | |
| } | |
| /** | |
| * In reference (full) that was missing. | |
| * | |
| * ```markdown | |
| * > | [a][b d | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function referenceFullMissing(code) { | |
| return nok(code); | |
| } | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeReferenceCollapsed(effects, ok$14, nok) { | |
| return referenceCollapsedStart; | |
| /** | |
| * In reference (collapsed), at `[`. | |
| * | |
| * > 👉 **Note**: we only get here if the label is defined. | |
| * | |
| * ```markdown | |
| * > | [a][] d | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function referenceCollapsedStart(code) { | |
| ok(code === codes.leftSquareBracket, "expected left bracket"); | |
| effects.enter(types.reference); | |
| effects.enter(types.referenceMarker); | |
| effects.consume(code); | |
| effects.exit(types.referenceMarker); | |
| return referenceCollapsedOpen; | |
| } | |
| /** | |
| * In reference (collapsed), at `]`. | |
| * | |
| * > 👉 **Note**: we only get here if the label is defined. | |
| * | |
| * ```markdown | |
| * > | [a][] d | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function referenceCollapsedOpen(code) { | |
| if (code === codes.rightSquareBracket) { | |
| effects.enter(types.referenceMarker); | |
| effects.consume(code); | |
| effects.exit(types.referenceMarker); | |
| effects.exit(types.reference); | |
| return ok$14; | |
| } | |
| return nok(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/label-start-image.js | |
| /** | |
| * @import { | |
| * Construct, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var labelStartImage = { | |
| name: "labelStartImage", | |
| resolveAll: labelEnd.resolveAll, | |
| tokenize: tokenizeLabelStartImage | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeLabelStartImage(effects, ok$10, nok) { | |
| const self = this; | |
| return start; | |
| /** | |
| * Start of label (image) start. | |
| * | |
| * ```markdown | |
| * > | a ![b] c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| ok(code === codes.exclamationMark, "expected `!`"); | |
| effects.enter(types.labelImage); | |
| effects.enter(types.labelImageMarker); | |
| effects.consume(code); | |
| effects.exit(types.labelImageMarker); | |
| return open; | |
| } | |
| /** | |
| * After `!`, at `[`. | |
| * | |
| * ```markdown | |
| * > | a ![b] c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function open(code) { | |
| if (code === codes.leftSquareBracket) { | |
| effects.enter(types.labelMarker); | |
| effects.consume(code); | |
| effects.exit(types.labelMarker); | |
| effects.exit(types.labelImage); | |
| return after; | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After `![`. | |
| * | |
| * ```markdown | |
| * > | a ![b] c | |
| * ^ | |
| * ``` | |
| * | |
| * This is needed in because, when GFM footnotes are enabled, images never | |
| * form when started with a `^`. | |
| * Instead, links form: | |
| * | |
| * ```markdown | |
| *  | |
| * | |
| * ![^a][b] | |
| * | |
| * [b]: c | |
| * ``` | |
| * | |
| * ```html | |
| * <p>!<a href=\"b\">^a</a></p> | |
| * <p>!<a href=\"c\">^a</a></p> | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function after(code) { | |
| /* c8 ignore next 3 */ | |
| return code === codes.caret && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code) : ok$10(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/label-start-link.js | |
| /** | |
| * @import { | |
| * Construct, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var labelStartLink = { | |
| name: "labelStartLink", | |
| resolveAll: labelEnd.resolveAll, | |
| tokenize: tokenizeLabelStartLink | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeLabelStartLink(effects, ok$9, nok) { | |
| const self = this; | |
| return start; | |
| /** | |
| * Start of label (link) start. | |
| * | |
| * ```markdown | |
| * > | a [b] c | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| ok(code === codes.leftSquareBracket, "expected `[`"); | |
| effects.enter(types.labelLink); | |
| effects.enter(types.labelMarker); | |
| effects.consume(code); | |
| effects.exit(types.labelMarker); | |
| effects.exit(types.labelLink); | |
| return after; | |
| } | |
| /** @type {State} */ | |
| function after(code) { | |
| /* c8 ignore next 3 */ | |
| return code === codes.caret && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code) : ok$9(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/line-ending.js | |
| /** | |
| * @import { | |
| * Construct, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var lineEnding = { | |
| name: "lineEnding", | |
| tokenize: tokenizeLineEnding | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeLineEnding(effects, ok$8) { | |
| return start; | |
| /** @type {State} */ | |
| function start(code) { | |
| ok(markdownLineEnding(code), "expected eol"); | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| return factorySpace(effects, ok$8, types.linePrefix); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/thematic-break.js | |
| /** | |
| * @import { | |
| * Code, | |
| * Construct, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var thematicBreak$1 = { | |
| name: "thematicBreak", | |
| tokenize: tokenizeThematicBreak | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeThematicBreak(effects, ok$7, nok) { | |
| let size = 0; | |
| /** @type {NonNullable<Code>} */ | |
| let marker; | |
| return start; | |
| /** | |
| * Start of thematic break. | |
| * | |
| * ```markdown | |
| * > | *** | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| effects.enter(types.thematicBreak); | |
| return before(code); | |
| } | |
| /** | |
| * After optional whitespace, at marker. | |
| * | |
| * ```markdown | |
| * > | *** | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function before(code) { | |
| ok(code === codes.asterisk || code === codes.dash || code === codes.underscore, "expected `*`, `-`, or `_`"); | |
| marker = code; | |
| return atBreak(code); | |
| } | |
| /** | |
| * After something, before something else. | |
| * | |
| * ```markdown | |
| * > | *** | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function atBreak(code) { | |
| if (code === marker) { | |
| effects.enter(types.thematicBreakSequence); | |
| return sequence(code); | |
| } | |
| if (size >= constants.thematicBreakMarkerCountMin && (code === codes.eof || markdownLineEnding(code))) { | |
| effects.exit(types.thematicBreak); | |
| return ok$7(code); | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * In sequence. | |
| * | |
| * ```markdown | |
| * > | *** | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function sequence(code) { | |
| if (code === marker) { | |
| effects.consume(code); | |
| size++; | |
| return sequence; | |
| } | |
| effects.exit(types.thematicBreakSequence); | |
| return markdownSpace(code) ? factorySpace(effects, atBreak, types.whitespace)(code) : atBreak(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/list.js | |
| /** | |
| * @import { | |
| * Code, | |
| * Construct, | |
| * Exiter, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var list$1 = { | |
| continuation: { tokenize: tokenizeListContinuation }, | |
| exit: tokenizeListEnd, | |
| name: "list", | |
| tokenize: tokenizeListStart | |
| }; | |
| /** @type {Construct} */ | |
| var listItemPrefixWhitespaceConstruct = { | |
| partial: true, | |
| tokenize: tokenizeListItemPrefixWhitespace | |
| }; | |
| /** @type {Construct} */ | |
| var indentConstruct = { | |
| partial: true, | |
| tokenize: tokenizeIndent | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeListStart(effects, ok$3, nok) { | |
| const self = this; | |
| const tail = self.events[self.events.length - 1]; | |
| let initialSize = tail && tail[1].type === types.linePrefix ? tail[2].sliceSerialize(tail[1], true).length : 0; | |
| let size = 0; | |
| return start; | |
| /** @type {State} */ | |
| function start(code) { | |
| ok(self.containerState, "expected state"); | |
| const kind = self.containerState.type || (code === codes.asterisk || code === codes.plusSign || code === codes.dash ? types.listUnordered : types.listOrdered); | |
| if (kind === types.listUnordered ? !self.containerState.marker || code === self.containerState.marker : asciiDigit(code)) { | |
| if (!self.containerState.type) { | |
| self.containerState.type = kind; | |
| effects.enter(kind, { _container: true }); | |
| } | |
| if (kind === types.listUnordered) { | |
| effects.enter(types.listItemPrefix); | |
| return code === codes.asterisk || code === codes.dash ? effects.check(thematicBreak$1, nok, atMarker)(code) : atMarker(code); | |
| } | |
| if (!self.interrupt || code === codes.digit1) { | |
| effects.enter(types.listItemPrefix); | |
| effects.enter(types.listItemValue); | |
| return inside(code); | |
| } | |
| } | |
| return nok(code); | |
| } | |
| /** @type {State} */ | |
| function inside(code) { | |
| ok(self.containerState, "expected state"); | |
| if (asciiDigit(code) && ++size < constants.listItemValueSizeMax) { | |
| effects.consume(code); | |
| return inside; | |
| } | |
| if ((!self.interrupt || size < 2) && (self.containerState.marker ? code === self.containerState.marker : code === codes.rightParenthesis || code === codes.dot)) { | |
| effects.exit(types.listItemValue); | |
| return atMarker(code); | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * @type {State} | |
| **/ | |
| function atMarker(code) { | |
| ok(self.containerState, "expected state"); | |
| ok(code !== codes.eof, "eof (`null`) is not a marker"); | |
| effects.enter(types.listItemMarker); | |
| effects.consume(code); | |
| effects.exit(types.listItemMarker); | |
| self.containerState.marker = self.containerState.marker || code; | |
| return effects.check(blankLine, self.interrupt ? nok : onBlank, effects.attempt(listItemPrefixWhitespaceConstruct, endOfPrefix, otherPrefix)); | |
| } | |
| /** @type {State} */ | |
| function onBlank(code) { | |
| ok(self.containerState, "expected state"); | |
| self.containerState.initialBlankLine = true; | |
| initialSize++; | |
| return endOfPrefix(code); | |
| } | |
| /** @type {State} */ | |
| function otherPrefix(code) { | |
| if (markdownSpace(code)) { | |
| effects.enter(types.listItemPrefixWhitespace); | |
| effects.consume(code); | |
| effects.exit(types.listItemPrefixWhitespace); | |
| return endOfPrefix; | |
| } | |
| return nok(code); | |
| } | |
| /** @type {State} */ | |
| function endOfPrefix(code) { | |
| ok(self.containerState, "expected state"); | |
| self.containerState.size = initialSize + self.sliceSerialize(effects.exit(types.listItemPrefix), true).length; | |
| return ok$3(code); | |
| } | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeListContinuation(effects, ok$4, nok) { | |
| const self = this; | |
| ok(self.containerState, "expected state"); | |
| self.containerState._closeFlow = void 0; | |
| return effects.check(blankLine, onBlank, notBlank); | |
| /** @type {State} */ | |
| function onBlank(code) { | |
| ok(self.containerState, "expected state"); | |
| ok(typeof self.containerState.size === "number", "expected size"); | |
| self.containerState.furtherBlankLines = self.containerState.furtherBlankLines || self.containerState.initialBlankLine; | |
| return factorySpace(effects, ok$4, types.listItemIndent, self.containerState.size + 1)(code); | |
| } | |
| /** @type {State} */ | |
| function notBlank(code) { | |
| ok(self.containerState, "expected state"); | |
| if (self.containerState.furtherBlankLines || !markdownSpace(code)) { | |
| self.containerState.furtherBlankLines = void 0; | |
| self.containerState.initialBlankLine = void 0; | |
| return notInCurrentItem(code); | |
| } | |
| self.containerState.furtherBlankLines = void 0; | |
| self.containerState.initialBlankLine = void 0; | |
| return effects.attempt(indentConstruct, ok$4, notInCurrentItem)(code); | |
| } | |
| /** @type {State} */ | |
| function notInCurrentItem(code) { | |
| ok(self.containerState, "expected state"); | |
| self.containerState._closeFlow = true; | |
| self.interrupt = void 0; | |
| ok(self.parser.constructs.disable.null, "expected `disable.null` to be populated"); | |
| return factorySpace(effects, effects.attempt(list$1, ok$4, nok), types.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : constants.tabSize)(code); | |
| } | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeIndent(effects, ok$5, nok) { | |
| const self = this; | |
| ok(self.containerState, "expected state"); | |
| ok(typeof self.containerState.size === "number", "expected size"); | |
| return factorySpace(effects, afterPrefix, types.listItemIndent, self.containerState.size + 1); | |
| /** @type {State} */ | |
| function afterPrefix(code) { | |
| ok(self.containerState, "expected state"); | |
| const tail = self.events[self.events.length - 1]; | |
| return tail && tail[1].type === types.listItemIndent && tail[2].sliceSerialize(tail[1], true).length === self.containerState.size ? ok$5(code) : nok(code); | |
| } | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Exiter} | |
| */ | |
| function tokenizeListEnd(effects) { | |
| ok(this.containerState, "expected state"); | |
| ok(typeof this.containerState.type === "string", "expected type"); | |
| effects.exit(this.containerState.type); | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeListItemPrefixWhitespace(effects, ok$6, nok) { | |
| const self = this; | |
| ok(self.parser.constructs.disable.null, "expected `disable.null` to be populated"); | |
| return factorySpace(effects, afterPrefix, types.listItemPrefixWhitespace, self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : constants.tabSize + 1); | |
| /** @type {State} */ | |
| function afterPrefix(code) { | |
| const tail = self.events[self.events.length - 1]; | |
| return !markdownSpace(code) && tail && tail[1].type === types.listItemPrefixWhitespace ? ok$6(code) : nok(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-core-commonmark/dev/lib/setext-underline.js | |
| /** | |
| * @import { | |
| * Code, | |
| * Construct, | |
| * Resolver, | |
| * State, | |
| * TokenizeContext, | |
| * Tokenizer | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {Construct} */ | |
| var setextUnderline = { | |
| name: "setextUnderline", | |
| resolveTo: resolveToSetextUnderline, | |
| tokenize: tokenizeSetextUnderline | |
| }; | |
| /** @type {Resolver} */ | |
| function resolveToSetextUnderline(events, context) { | |
| let index = events.length; | |
| /** @type {number | undefined} */ | |
| let content; | |
| /** @type {number | undefined} */ | |
| let text; | |
| /** @type {number | undefined} */ | |
| let definition; | |
| while (index--) if (events[index][0] === "enter") { | |
| if (events[index][1].type === types.content) { | |
| content = index; | |
| break; | |
| } | |
| if (events[index][1].type === types.paragraph) text = index; | |
| } else { | |
| if (events[index][1].type === types.content) events.splice(index, 1); | |
| if (!definition && events[index][1].type === types.definition) definition = index; | |
| } | |
| ok(text !== void 0, "expected a `text` index to be found"); | |
| ok(content !== void 0, "expected a `text` index to be found"); | |
| ok(events[content][2] === context, "enter context should be same"); | |
| ok(events[events.length - 1][2] === context, "enter context should be same"); | |
| const heading = { | |
| type: types.setextHeading, | |
| start: { ...events[content][1].start }, | |
| end: { ...events[events.length - 1][1].end } | |
| }; | |
| events[text][1].type = types.setextHeadingText; | |
| if (definition) { | |
| events.splice(text, 0, [ | |
| "enter", | |
| heading, | |
| context | |
| ]); | |
| events.splice(definition + 1, 0, [ | |
| "exit", | |
| events[content][1], | |
| context | |
| ]); | |
| events[content][1].end = { ...events[definition][1].end }; | |
| } else events[content][1] = heading; | |
| events.push([ | |
| "exit", | |
| heading, | |
| context | |
| ]); | |
| return events; | |
| } | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Tokenizer} | |
| */ | |
| function tokenizeSetextUnderline(effects, ok$2, nok) { | |
| const self = this; | |
| /** @type {NonNullable<Code>} */ | |
| let marker; | |
| return start; | |
| /** | |
| * At start of heading (setext) underline. | |
| * | |
| * ```markdown | |
| * | aa | |
| * > | == | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function start(code) { | |
| let index = self.events.length; | |
| /** @type {boolean | undefined} */ | |
| let paragraph; | |
| ok(code === codes.dash || code === codes.equalsTo, "expected `=` or `-`"); | |
| while (index--) if (self.events[index][1].type !== types.lineEnding && self.events[index][1].type !== types.linePrefix && self.events[index][1].type !== types.content) { | |
| paragraph = self.events[index][1].type === types.paragraph; | |
| break; | |
| } | |
| if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) { | |
| effects.enter(types.setextHeadingLine); | |
| marker = code; | |
| return before(code); | |
| } | |
| return nok(code); | |
| } | |
| /** | |
| * After optional whitespace, at `-` or `=`. | |
| * | |
| * ```markdown | |
| * | aa | |
| * > | == | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function before(code) { | |
| effects.enter(types.setextHeadingLineSequence); | |
| return inside(code); | |
| } | |
| /** | |
| * In sequence. | |
| * | |
| * ```markdown | |
| * | aa | |
| * > | == | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function inside(code) { | |
| if (code === marker) { | |
| effects.consume(code); | |
| return inside; | |
| } | |
| effects.exit(types.setextHeadingLineSequence); | |
| return markdownSpace(code) ? factorySpace(effects, after, types.lineSuffix)(code) : after(code); | |
| } | |
| /** | |
| * After sequence, after optional whitespace. | |
| * | |
| * ```markdown | |
| * | aa | |
| * > | == | |
| * ^ | |
| * ``` | |
| * | |
| * @type {State} | |
| */ | |
| function after(code) { | |
| if (code === codes.eof || markdownLineEnding(code)) { | |
| effects.exit(types.setextHeadingLine); | |
| return ok$2(code); | |
| } | |
| return nok(code); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark/dev/lib/initialize/flow.js | |
| /** | |
| * @import { | |
| * InitialConstruct, | |
| * Initializer, | |
| * State, | |
| * TokenizeContext | |
| * } from 'micromark-util-types' | |
| */ | |
| /** @type {InitialConstruct} */ | |
| var flow$1 = { tokenize: initializeFlow }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Self. | |
| * @type {Initializer} | |
| * Initializer. | |
| */ | |
| function initializeFlow(effects) { | |
| const self = this; | |
| const initial = effects.attempt(blankLine, atBlankEnding, effects.attempt(this.parser.constructs.flowInitial, afterConstruct, factorySpace(effects, effects.attempt(this.parser.constructs.flow, afterConstruct, effects.attempt(content, afterConstruct)), types.linePrefix))); | |
| return initial; | |
| /** @type {State} */ | |
| function atBlankEnding(code) { | |
| ok(code === codes.eof || markdownLineEnding(code), "expected eol or eof"); | |
| if (code === codes.eof) { | |
| effects.consume(code); | |
| return; | |
| } | |
| effects.enter(types.lineEndingBlank); | |
| effects.consume(code); | |
| effects.exit(types.lineEndingBlank); | |
| self.currentConstruct = void 0; | |
| return initial; | |
| } | |
| /** @type {State} */ | |
| function afterConstruct(code) { | |
| ok(code === codes.eof || markdownLineEnding(code), "expected eol or eof"); | |
| if (code === codes.eof) { | |
| effects.consume(code); | |
| return; | |
| } | |
| effects.enter(types.lineEnding); | |
| effects.consume(code); | |
| effects.exit(types.lineEnding); | |
| self.currentConstruct = void 0; | |
| return initial; | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark/dev/lib/initialize/text.js | |
| /** | |
| * @import { | |
| * Code, | |
| * InitialConstruct, | |
| * Initializer, | |
| * Resolver, | |
| * State, | |
| * TokenizeContext | |
| * } from 'micromark-util-types' | |
| */ | |
| var resolver = { resolveAll: createResolver() }; | |
| var string$1 = initializeFactory("string"); | |
| var text$2 = initializeFactory("text"); | |
| /** | |
| * @param {'string' | 'text'} field | |
| * Field. | |
| * @returns {InitialConstruct} | |
| * Construct. | |
| */ | |
| function initializeFactory(field) { | |
| return { | |
| resolveAll: createResolver(field === "text" ? resolveAllLineSuffixes : void 0), | |
| tokenize: initializeText | |
| }; | |
| /** | |
| * @this {TokenizeContext} | |
| * Context. | |
| * @type {Initializer} | |
| */ | |
| function initializeText(effects) { | |
| const self = this; | |
| const constructs = this.parser.constructs[field]; | |
| const text = effects.attempt(constructs, start, notText); | |
| return start; | |
| /** @type {State} */ | |
| function start(code) { | |
| return atBreak(code) ? text(code) : notText(code); | |
| } | |
| /** @type {State} */ | |
| function notText(code) { | |
| if (code === codes.eof) { | |
| effects.consume(code); | |
| return; | |
| } | |
| effects.enter(types.data); | |
| effects.consume(code); | |
| return data; | |
| } | |
| /** @type {State} */ | |
| function data(code) { | |
| if (atBreak(code)) { | |
| effects.exit(types.data); | |
| return text(code); | |
| } | |
| effects.consume(code); | |
| return data; | |
| } | |
| /** | |
| * @param {Code} code | |
| * Code. | |
| * @returns {boolean} | |
| * Whether the code is a break. | |
| */ | |
| function atBreak(code) { | |
| if (code === codes.eof) return true; | |
| const list = constructs[code]; | |
| let index = -1; | |
| if (list) { | |
| ok(Array.isArray(list), "expected `disable.null` to be populated"); | |
| while (++index < list.length) { | |
| const item = list[index]; | |
| if (!item.previous || item.previous.call(self, self.previous)) return true; | |
| } | |
| } | |
| return false; | |
| } | |
| } | |
| } | |
| /** | |
| * @param {Resolver | undefined} [extraResolver] | |
| * Resolver. | |
| * @returns {Resolver} | |
| * Resolver. | |
| */ | |
| function createResolver(extraResolver) { | |
| return resolveAllText; | |
| /** @type {Resolver} */ | |
| function resolveAllText(events, context) { | |
| let index = -1; | |
| /** @type {number | undefined} */ | |
| let enter; | |
| while (++index <= events.length) if (enter === void 0) { | |
| if (events[index] && events[index][1].type === types.data) { | |
| enter = index; | |
| index++; | |
| } | |
| } else if (!events[index] || events[index][1].type !== types.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; | |
| } | |
| } | |
| /** | |
| * A rather ugly set of instructions which again looks at chunks in the input | |
| * stream. | |
| * The reason to do this here is that it is *much* faster to parse in reverse. | |
| * And that we can’t hook into `null` to split the line suffix before an EOF. | |
| * To do: figure out if we can make this into a clean utility, or even in core. | |
| * As it will be useful for GFMs literal autolink extension (and maybe even | |
| * tables?) | |
| * | |
| * @type {Resolver} | |
| */ | |
| function resolveAllLineSuffixes(events, context) { | |
| let eventIndex = 0; | |
| while (++eventIndex <= events.length) if ((eventIndex === events.length || events[eventIndex][1].type === types.lineEnding) && events[eventIndex - 1][1].type === types.data) { | |
| const data = events[eventIndex - 1][1]; | |
| const chunks = context.sliceStream(data); | |
| let index = chunks.length; | |
| let bufferIndex = -1; | |
| let size = 0; | |
| /** @type {boolean | undefined} */ | |
| let tabs; | |
| while (index--) { | |
| const chunk = chunks[index]; | |
| if (typeof chunk === "string") { | |
| bufferIndex = chunk.length; | |
| while (chunk.charCodeAt(bufferIndex - 1) === codes.space) { | |
| size++; | |
| bufferIndex--; | |
| } | |
| if (bufferIndex) break; | |
| bufferIndex = -1; | |
| } else if (chunk === codes.horizontalTab) { | |
| tabs = true; | |
| size++; | |
| } else if (chunk === codes.virtualSpace) {} else { | |
| index++; | |
| break; | |
| } | |
| } | |
| if (context._contentTypeTextTrailing && eventIndex === events.length) size = 0; | |
| if (size) { | |
| const token = { | |
| type: eventIndex === events.length || tabs || size < constants.hardBreakPrefixSizeMin ? types.lineSuffix : types.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; | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark/dev/lib/constructs.js | |
| /** | |
| * @import {Extension} from 'micromark-util-types' | |
| */ | |
| var constructs_exports = /* @__PURE__ */ __exportAll({ | |
| attentionMarkers: () => attentionMarkers, | |
| contentInitial: () => contentInitial, | |
| disable: () => disable, | |
| document: () => document$1, | |
| flow: () => flow, | |
| flowInitial: () => flowInitial, | |
| insideSpan: () => insideSpan, | |
| string: () => string, | |
| text: () => text$1 | |
| }); | |
| /** @satisfies {Extension['document']} */ | |
| var document$1 = { | |
| [codes.asterisk]: list$1, | |
| [codes.plusSign]: list$1, | |
| [codes.dash]: list$1, | |
| [codes.digit0]: list$1, | |
| [codes.digit1]: list$1, | |
| [codes.digit2]: list$1, | |
| [codes.digit3]: list$1, | |
| [codes.digit4]: list$1, | |
| [codes.digit5]: list$1, | |
| [codes.digit6]: list$1, | |
| [codes.digit7]: list$1, | |
| [codes.digit8]: list$1, | |
| [codes.digit9]: list$1, | |
| [codes.greaterThan]: blockQuote | |
| }; | |
| /** @satisfies {Extension['contentInitial']} */ | |
| var contentInitial = { [codes.leftSquareBracket]: definition }; | |
| /** @satisfies {Extension['flowInitial']} */ | |
| var flowInitial = { | |
| [codes.horizontalTab]: codeIndented, | |
| [codes.virtualSpace]: codeIndented, | |
| [codes.space]: codeIndented | |
| }; | |
| /** @satisfies {Extension['flow']} */ | |
| var flow = { | |
| [codes.numberSign]: headingAtx, | |
| [codes.asterisk]: thematicBreak$1, | |
| [codes.dash]: [setextUnderline, thematicBreak$1], | |
| [codes.lessThan]: htmlFlow, | |
| [codes.equalsTo]: setextUnderline, | |
| [codes.underscore]: thematicBreak$1, | |
| [codes.graveAccent]: codeFenced, | |
| [codes.tilde]: codeFenced | |
| }; | |
| /** @satisfies {Extension['string']} */ | |
| var string = { | |
| [codes.ampersand]: characterReference, | |
| [codes.backslash]: characterEscape | |
| }; | |
| /** @satisfies {Extension['text']} */ | |
| var text$1 = { | |
| [codes.carriageReturn]: lineEnding, | |
| [codes.lineFeed]: lineEnding, | |
| [codes.carriageReturnLineFeed]: lineEnding, | |
| [codes.exclamationMark]: labelStartImage, | |
| [codes.ampersand]: characterReference, | |
| [codes.asterisk]: attention, | |
| [codes.lessThan]: [autolink, htmlText], | |
| [codes.leftSquareBracket]: labelStartLink, | |
| [codes.backslash]: [hardBreakEscape, characterEscape], | |
| [codes.rightSquareBracket]: labelEnd, | |
| [codes.underscore]: attention, | |
| [codes.graveAccent]: codeText | |
| }; | |
| /** @satisfies {Extension['insideSpan']} */ | |
| var insideSpan = { null: [attention, resolver] }; | |
| /** @satisfies {Extension['attentionMarkers']} */ | |
| var attentionMarkers = { null: [codes.asterisk, codes.underscore] }; | |
| /** @satisfies {Extension['disable']} */ | |
| var disable = { null: [] }; | |
| //#endregion | |
| //#region ../node_modules/ms/index.js | |
| var require_ms = /* @__PURE__ */ __commonJSMin(((exports, module) => { | |
| /** | |
| * Helpers. | |
| */ | |
| var s = 1e3; | |
| var m = s * 60; | |
| var h = m * 60; | |
| var d = h * 24; | |
| var w = d * 7; | |
| var y = d * 365.25; | |
| /** | |
| * Parse or format the given `val`. | |
| * | |
| * Options: | |
| * | |
| * - `long` verbose formatting [false] | |
| * | |
| * @param {String|Number} val | |
| * @param {Object} [options] | |
| * @throws {Error} throw an error if val is not a non-empty string or a number | |
| * @return {String|Number} | |
| * @api public | |
| */ | |
| module.exports = function(val, options) { | |
| options = options || {}; | |
| var type = typeof val; | |
| if (type === "string" && val.length > 0) return parse(val); | |
| else if (type === "number" && isFinite(val)) return options.long ? fmtLong(val) : fmtShort(val); | |
| throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val)); | |
| }; | |
| /** | |
| * Parse the given `str` and return milliseconds. | |
| * | |
| * @param {String} str | |
| * @return {Number} | |
| * @api private | |
| */ | |
| function parse(str) { | |
| str = String(str); | |
| if (str.length > 100) return; | |
| var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str); | |
| if (!match) return; | |
| var n = parseFloat(match[1]); | |
| switch ((match[2] || "ms").toLowerCase()) { | |
| case "years": | |
| case "year": | |
| case "yrs": | |
| case "yr": | |
| case "y": return n * y; | |
| case "weeks": | |
| case "week": | |
| case "w": return n * w; | |
| case "days": | |
| case "day": | |
| case "d": return n * d; | |
| case "hours": | |
| case "hour": | |
| case "hrs": | |
| case "hr": | |
| case "h": return n * h; | |
| case "minutes": | |
| case "minute": | |
| case "mins": | |
| case "min": | |
| case "m": return n * m; | |
| case "seconds": | |
| case "second": | |
| case "secs": | |
| case "sec": | |
| case "s": return n * s; | |
| case "milliseconds": | |
| case "millisecond": | |
| case "msecs": | |
| case "msec": | |
| case "ms": return n; | |
| default: return; | |
| } | |
| } | |
| /** | |
| * Short format for `ms`. | |
| * | |
| * @param {Number} ms | |
| * @return {String} | |
| * @api private | |
| */ | |
| function fmtShort(ms) { | |
| var msAbs = Math.abs(ms); | |
| if (msAbs >= d) return Math.round(ms / d) + "d"; | |
| if (msAbs >= h) return Math.round(ms / h) + "h"; | |
| if (msAbs >= m) return Math.round(ms / m) + "m"; | |
| if (msAbs >= s) return Math.round(ms / s) + "s"; | |
| return ms + "ms"; | |
| } | |
| /** | |
| * Long format for `ms`. | |
| * | |
| * @param {Number} ms | |
| * @return {String} | |
| * @api private | |
| */ | |
| function fmtLong(ms) { | |
| var msAbs = Math.abs(ms); | |
| if (msAbs >= d) return plural(ms, msAbs, d, "day"); | |
| if (msAbs >= h) return plural(ms, msAbs, h, "hour"); | |
| if (msAbs >= m) return plural(ms, msAbs, m, "minute"); | |
| if (msAbs >= s) return plural(ms, msAbs, s, "second"); | |
| return ms + " ms"; | |
| } | |
| /** | |
| * Pluralization helper. | |
| */ | |
| function plural(ms, msAbs, n, name) { | |
| var isPlural = msAbs >= n * 1.5; | |
| return Math.round(ms / n) + " " + name + (isPlural ? "s" : ""); | |
| } | |
| })); | |
| //#endregion | |
| //#region ../node_modules/debug/src/common.js | |
| var require_common = /* @__PURE__ */ __commonJSMin(((exports, module) => { | |
| /** | |
| * This is the common logic for both the Node.js and web browser | |
| * implementations of `debug()`. | |
| */ | |
| function setup(env) { | |
| createDebug.debug = createDebug; | |
| createDebug.default = createDebug; | |
| createDebug.coerce = coerce; | |
| createDebug.disable = disable; | |
| createDebug.enable = enable; | |
| createDebug.enabled = enabled; | |
| createDebug.humanize = require_ms(); | |
| createDebug.destroy = destroy; | |
| Object.keys(env).forEach((key) => { | |
| createDebug[key] = env[key]; | |
| }); | |
| /** | |
| * The currently active debug mode names, and names to skip. | |
| */ | |
| createDebug.names = []; | |
| createDebug.skips = []; | |
| /** | |
| * Map of special "%n" handling functions, for the debug "format" argument. | |
| * | |
| * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". | |
| */ | |
| createDebug.formatters = {}; | |
| /** | |
| * Selects a color for a debug namespace | |
| * @param {String} namespace The namespace string for the debug instance to be colored | |
| * @return {Number|String} An ANSI color code for the given namespace | |
| * @api private | |
| */ | |
| function selectColor(namespace) { | |
| let hash = 0; | |
| for (let i = 0; i < namespace.length; i++) { | |
| hash = (hash << 5) - hash + namespace.charCodeAt(i); | |
| hash |= 0; | |
| } | |
| return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; | |
| } | |
| createDebug.selectColor = selectColor; | |
| /** | |
| * Create a debugger with the given `namespace`. | |
| * | |
| * @param {String} namespace | |
| * @return {Function} | |
| * @api public | |
| */ | |
| function createDebug(namespace) { | |
| let prevTime; | |
| let enableOverride = null; | |
| let namespacesCache; | |
| let enabledCache; | |
| function debug(...args) { | |
| if (!debug.enabled) return; | |
| const self = debug; | |
| const curr = Number(/* @__PURE__ */ new Date()); | |
| self.diff = curr - (prevTime || curr); | |
| self.prev = prevTime; | |
| self.curr = curr; | |
| prevTime = curr; | |
| args[0] = createDebug.coerce(args[0]); | |
| if (typeof args[0] !== "string") args.unshift("%O"); | |
| let index = 0; | |
| args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { | |
| if (match === "%%") return "%"; | |
| index++; | |
| const formatter = createDebug.formatters[format]; | |
| if (typeof formatter === "function") { | |
| const val = args[index]; | |
| match = formatter.call(self, val); | |
| args.splice(index, 1); | |
| index--; | |
| } | |
| return match; | |
| }); | |
| createDebug.formatArgs.call(self, args); | |
| (self.log || createDebug.log).apply(self, args); | |
| } | |
| debug.namespace = namespace; | |
| debug.useColors = createDebug.useColors(); | |
| debug.color = createDebug.selectColor(namespace); | |
| debug.extend = extend; | |
| debug.destroy = createDebug.destroy; | |
| Object.defineProperty(debug, "enabled", { | |
| enumerable: true, | |
| configurable: false, | |
| get: () => { | |
| if (enableOverride !== null) return enableOverride; | |
| if (namespacesCache !== createDebug.namespaces) { | |
| namespacesCache = createDebug.namespaces; | |
| enabledCache = createDebug.enabled(namespace); | |
| } | |
| return enabledCache; | |
| }, | |
| set: (v) => { | |
| enableOverride = v; | |
| } | |
| }); | |
| if (typeof createDebug.init === "function") createDebug.init(debug); | |
| return debug; | |
| } | |
| function extend(namespace, delimiter) { | |
| const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace); | |
| newDebug.log = this.log; | |
| return newDebug; | |
| } | |
| /** | |
| * Enables a debug mode by namespaces. This can include modes | |
| * separated by a colon and wildcards. | |
| * | |
| * @param {String} namespaces | |
| * @api public | |
| */ | |
| function enable(namespaces) { | |
| createDebug.save(namespaces); | |
| createDebug.namespaces = namespaces; | |
| createDebug.names = []; | |
| createDebug.skips = []; | |
| const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean); | |
| for (const ns of split) if (ns[0] === "-") createDebug.skips.push(ns.slice(1)); | |
| else createDebug.names.push(ns); | |
| } | |
| /** | |
| * Checks if the given string matches a namespace template, honoring | |
| * asterisks as wildcards. | |
| * | |
| * @param {String} search | |
| * @param {String} template | |
| * @return {Boolean} | |
| */ | |
| function matchesTemplate(search, template) { | |
| let searchIndex = 0; | |
| let templateIndex = 0; | |
| let starIndex = -1; | |
| let matchIndex = 0; | |
| while (searchIndex < search.length) if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) if (template[templateIndex] === "*") { | |
| starIndex = templateIndex; | |
| matchIndex = searchIndex; | |
| templateIndex++; | |
| } else { | |
| searchIndex++; | |
| templateIndex++; | |
| } | |
| else if (starIndex !== -1) { | |
| templateIndex = starIndex + 1; | |
| matchIndex++; | |
| searchIndex = matchIndex; | |
| } else return false; | |
| while (templateIndex < template.length && template[templateIndex] === "*") templateIndex++; | |
| return templateIndex === template.length; | |
| } | |
| /** | |
| * Disable debug output. | |
| * | |
| * @return {String} namespaces | |
| * @api public | |
| */ | |
| function disable() { | |
| const namespaces = [...createDebug.names, ...createDebug.skips.map((namespace) => "-" + namespace)].join(","); | |
| createDebug.enable(""); | |
| return namespaces; | |
| } | |
| /** | |
| * Returns true if the given mode name is enabled, false otherwise. | |
| * | |
| * @param {String} name | |
| * @return {Boolean} | |
| * @api public | |
| */ | |
| function enabled(name) { | |
| for (const skip of createDebug.skips) if (matchesTemplate(name, skip)) return false; | |
| for (const ns of createDebug.names) if (matchesTemplate(name, ns)) return true; | |
| return false; | |
| } | |
| /** | |
| * Coerce `val`. | |
| * | |
| * @param {Mixed} val | |
| * @return {Mixed} | |
| * @api private | |
| */ | |
| function coerce(val) { | |
| if (val instanceof Error) return val.stack || val.message; | |
| return val; | |
| } | |
| /** | |
| * XXX DO NOT USE. This is a temporary stub function. | |
| * XXX It WILL be removed in the next major release. | |
| */ | |
| function destroy() { | |
| console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); | |
| } | |
| createDebug.enable(createDebug.load()); | |
| return createDebug; | |
| } | |
| module.exports = setup; | |
| })); | |
| var debug = (0, (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => { | |
| /** | |
| * This is the web browser implementation of `debug()`. | |
| */ | |
| exports.formatArgs = formatArgs; | |
| exports.save = save; | |
| exports.load = load; | |
| exports.useColors = useColors; | |
| exports.storage = localstorage(); | |
| exports.destroy = (() => { | |
| let warned = false; | |
| return () => { | |
| if (!warned) { | |
| warned = true; | |
| console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); | |
| } | |
| }; | |
| })(); | |
| /** | |
| * Colors. | |
| */ | |
| exports.colors = [ | |
| "#0000CC", | |
| "#0000FF", | |
| "#0033CC", | |
| "#0033FF", | |
| "#0066CC", | |
| "#0066FF", | |
| "#0099CC", | |
| "#0099FF", | |
| "#00CC00", | |
| "#00CC33", | |
| "#00CC66", | |
| "#00CC99", | |
| "#00CCCC", | |
| "#00CCFF", | |
| "#3300CC", | |
| "#3300FF", | |
| "#3333CC", | |
| "#3333FF", | |
| "#3366CC", | |
| "#3366FF", | |
| "#3399CC", | |
| "#3399FF", | |
| "#33CC00", | |
| "#33CC33", | |
| "#33CC66", | |
| "#33CC99", | |
| "#33CCCC", | |
| "#33CCFF", | |
| "#6600CC", | |
| "#6600FF", | |
| "#6633CC", | |
| "#6633FF", | |
| "#66CC00", | |
| "#66CC33", | |
| "#9900CC", | |
| "#9900FF", | |
| "#9933CC", | |
| "#9933FF", | |
| "#99CC00", | |
| "#99CC33", | |
| "#CC0000", | |
| "#CC0033", | |
| "#CC0066", | |
| "#CC0099", | |
| "#CC00CC", | |
| "#CC00FF", | |
| "#CC3300", | |
| "#CC3333", | |
| "#CC3366", | |
| "#CC3399", | |
| "#CC33CC", | |
| "#CC33FF", | |
| "#CC6600", | |
| "#CC6633", | |
| "#CC9900", | |
| "#CC9933", | |
| "#CCCC00", | |
| "#CCCC33", | |
| "#FF0000", | |
| "#FF0033", | |
| "#FF0066", | |
| "#FF0099", | |
| "#FF00CC", | |
| "#FF00FF", | |
| "#FF3300", | |
| "#FF3333", | |
| "#FF3366", | |
| "#FF3399", | |
| "#FF33CC", | |
| "#FF33FF", | |
| "#FF6600", | |
| "#FF6633", | |
| "#FF9900", | |
| "#FF9933", | |
| "#FFCC00", | |
| "#FFCC33" | |
| ]; | |
| /** | |
| * Currently only WebKit-based Web Inspectors, Firefox >= v31, | |
| * and the Firebug extension (any Firefox version) are known | |
| * to support "%c" CSS customizations. | |
| * | |
| * TODO: add a `localStorage` variable to explicitly enable/disable colors | |
| */ | |
| function useColors() { | |
| if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) return true; | |
| if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) return false; | |
| let m; | |
| return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); | |
| } | |
| /** | |
| * Colorize log arguments if enabled. | |
| * | |
| * @api public | |
| */ | |
| function formatArgs(args) { | |
| args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff); | |
| if (!this.useColors) return; | |
| const c = "color: " + this.color; | |
| args.splice(1, 0, c, "color: inherit"); | |
| let index = 0; | |
| let lastC = 0; | |
| args[0].replace(/%[a-zA-Z%]/g, (match) => { | |
| if (match === "%%") return; | |
| index++; | |
| if (match === "%c") lastC = index; | |
| }); | |
| args.splice(lastC, 0, c); | |
| } | |
| /** | |
| * Invokes `console.debug()` when available. | |
| * No-op when `console.debug` is not a "function". | |
| * If `console.debug` is not available, falls back | |
| * to `console.log`. | |
| * | |
| * @api public | |
| */ | |
| exports.log = console.debug || console.log || (() => {}); | |
| /** | |
| * Save `namespaces`. | |
| * | |
| * @param {String} namespaces | |
| * @api private | |
| */ | |
| function save(namespaces) { | |
| try { | |
| if (namespaces) exports.storage.setItem("debug", namespaces); | |
| else exports.storage.removeItem("debug"); | |
| } catch (error) {} | |
| } | |
| /** | |
| * Load `namespaces`. | |
| * | |
| * @return {String} returns the previously persisted debug modes | |
| * @api private | |
| */ | |
| function load() { | |
| let r; | |
| try { | |
| r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG"); | |
| } catch (error) {} | |
| if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG; | |
| return r; | |
| } | |
| /** | |
| * Localstorage attempts to return the localstorage. | |
| * | |
| * This is necessary because safari throws | |
| * when a user disables cookies/localstorage | |
| * and you attempt to access it. | |
| * | |
| * @return {LocalStorage} | |
| * @api private | |
| */ | |
| function localstorage() { | |
| try { | |
| return localStorage; | |
| } catch (error) {} | |
| } | |
| module.exports = require_common()(exports); | |
| var { formatters } = module.exports; | |
| /** | |
| * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. | |
| */ | |
| formatters.j = function(v) { | |
| try { | |
| return JSON.stringify(v); | |
| } catch (error) { | |
| return "[UnexpectedJSONParseError]: " + error.message; | |
| } | |
| }; | |
| })))(), 1)).default)("micromark"); | |
| /** | |
| * Create a tokenizer. | |
| * Tokenizers deal with one type of data (e.g., containers, flow, text). | |
| * The parser is the object dealing with it all. | |
| * `initialize` works like other constructs, except that only its `tokenize` | |
| * function is used, in which case it doesn’t receive an `ok` or `nok`. | |
| * `from` can be given to set the point before the first character, although | |
| * when further lines are indented, they must be set with `defineSkip`. | |
| * | |
| * @param {ParseContext} parser | |
| * Parser. | |
| * @param {InitialConstruct} initialize | |
| * Construct. | |
| * @param {Omit<Point, '_bufferIndex' | '_index'> | undefined} [from] | |
| * Point (optional). | |
| * @returns {TokenizeContext} | |
| * Context. | |
| */ | |
| function createTokenizer(parser, initialize, from) { | |
| /** @type {Point} */ | |
| let point = { | |
| _bufferIndex: -1, | |
| _index: 0, | |
| line: from && from.line || 1, | |
| column: from && from.column || 1, | |
| offset: from && from.offset || 0 | |
| }; | |
| /** @type {Record<string, number>} */ | |
| const columnStart = {}; | |
| /** @type {Array<Construct>} */ | |
| const resolveAllConstructs = []; | |
| /** @type {Array<Chunk>} */ | |
| let chunks = []; | |
| /** @type {Array<Token>} */ | |
| let stack = []; | |
| /** @type {boolean | undefined} */ | |
| let consumed = true; | |
| /** | |
| * Tools used for tokenizing. | |
| * | |
| * @type {Effects} | |
| */ | |
| const effects = { | |
| attempt: constructFactory(onsuccessfulconstruct), | |
| check: constructFactory(onsuccessfulcheck), | |
| consume, | |
| enter, | |
| exit, | |
| interrupt: constructFactory(onsuccessfulcheck, { interrupt: true }) | |
| }; | |
| /** | |
| * State and tools for resolving and serializing. | |
| * | |
| * @type {TokenizeContext} | |
| */ | |
| const context = { | |
| code: codes.eof, | |
| containerState: {}, | |
| defineSkip, | |
| events: [], | |
| now, | |
| parser, | |
| previous: codes.eof, | |
| sliceSerialize, | |
| sliceStream, | |
| write | |
| }; | |
| /** | |
| * The state function. | |
| * | |
| * @type {State | undefined} | |
| */ | |
| let state = initialize.tokenize.call(context, effects); | |
| /** | |
| * Track which character we expect to be consumed, to catch bugs. | |
| * | |
| * @type {Code} | |
| */ | |
| let expectedCode; | |
| if (initialize.resolveAll) resolveAllConstructs.push(initialize); | |
| return context; | |
| /** @type {TokenizeContext['write']} */ | |
| function write(slice) { | |
| chunks = push(chunks, slice); | |
| main(); | |
| if (chunks[chunks.length - 1] !== codes.eof) return []; | |
| addResult(initialize, 0); | |
| context.events = resolveAll(resolveAllConstructs, context.events, context); | |
| return context.events; | |
| } | |
| /** @type {TokenizeContext['sliceSerialize']} */ | |
| function sliceSerialize(token, expandTabs) { | |
| return serializeChunks(sliceStream(token), expandTabs); | |
| } | |
| /** @type {TokenizeContext['sliceStream']} */ | |
| function sliceStream(token) { | |
| return sliceChunks(chunks, token); | |
| } | |
| /** @type {TokenizeContext['now']} */ | |
| function now() { | |
| const { _bufferIndex, _index, line, column, offset } = point; | |
| return { | |
| _bufferIndex, | |
| _index, | |
| line, | |
| column, | |
| offset | |
| }; | |
| } | |
| /** @type {TokenizeContext['defineSkip']} */ | |
| function defineSkip(value) { | |
| columnStart[value.line] = value.column; | |
| accountForPotentialSkip(); | |
| debug("position: define skip: `%j`", point); | |
| } | |
| /** | |
| * Main loop (note that `_index` and `_bufferIndex` in `point` are modified by | |
| * `consume`). | |
| * Here is where we walk through the chunks, which either include strings of | |
| * several characters, or numerical character codes. | |
| * The reason to do this in a loop instead of a call is so the stack can | |
| * drain. | |
| * | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| function main() { | |
| /** @type {number} */ | |
| let chunkIndex; | |
| while (point._index < chunks.length) { | |
| const chunk = chunks[point._index]; | |
| if (typeof chunk === "string") { | |
| chunkIndex = point._index; | |
| if (point._bufferIndex < 0) point._bufferIndex = 0; | |
| while (point._index === chunkIndex && point._bufferIndex < chunk.length) go(chunk.charCodeAt(point._bufferIndex)); | |
| } else go(chunk); | |
| } | |
| } | |
| /** | |
| * Deal with one code. | |
| * | |
| * @param {Code} code | |
| * Code. | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| function go(code) { | |
| ok(consumed === true, "expected character to be consumed"); | |
| consumed = void 0; | |
| debug("main: passing `%s` to %s", code, state && state.name); | |
| expectedCode = code; | |
| ok(typeof state === "function", "expected state"); | |
| state = state(code); | |
| } | |
| /** @type {Effects['consume']} */ | |
| function consume(code) { | |
| ok(code === expectedCode, "expected given code to equal expected code"); | |
| debug("consume: `%s`", code); | |
| ok(consumed === void 0, "expected code to not have been consumed: this might be because `return x(code)` instead of `return x` was used"); | |
| ok(code === null ? context.events.length === 0 || context.events[context.events.length - 1][0] === "exit" : context.events[context.events.length - 1][0] === "enter", "expected last token to be open"); | |
| if (markdownLineEnding(code)) { | |
| point.line++; | |
| point.column = 1; | |
| point.offset += code === codes.carriageReturnLineFeed ? 2 : 1; | |
| accountForPotentialSkip(); | |
| debug("position: after eol: `%j`", point); | |
| } else if (code !== codes.virtualSpace) { | |
| point.column++; | |
| point.offset++; | |
| } | |
| if (point._bufferIndex < 0) point._index++; | |
| else { | |
| point._bufferIndex++; | |
| if (point._bufferIndex === chunks[point._index].length) { | |
| point._bufferIndex = -1; | |
| point._index++; | |
| } | |
| } | |
| context.previous = code; | |
| consumed = true; | |
| } | |
| /** @type {Effects['enter']} */ | |
| function enter(type, fields) { | |
| /** @type {Token} */ | |
| const token = fields || {}; | |
| token.type = type; | |
| token.start = now(); | |
| ok(typeof type === "string", "expected string type"); | |
| ok(type.length > 0, "expected non-empty string"); | |
| debug("enter: `%s`", type); | |
| context.events.push([ | |
| "enter", | |
| token, | |
| context | |
| ]); | |
| stack.push(token); | |
| return token; | |
| } | |
| /** @type {Effects['exit']} */ | |
| function exit(type) { | |
| ok(typeof type === "string", "expected string type"); | |
| ok(type.length > 0, "expected non-empty string"); | |
| const token = stack.pop(); | |
| ok(token, "cannot close w/o open tokens"); | |
| token.end = now(); | |
| ok(type === token.type, "expected exit token to match current token"); | |
| ok(!(token.start._index === token.end._index && token.start._bufferIndex === token.end._bufferIndex), "expected non-empty token (`" + type + "`)"); | |
| debug("exit: `%s`", token.type); | |
| context.events.push([ | |
| "exit", | |
| token, | |
| context | |
| ]); | |
| return token; | |
| } | |
| /** | |
| * Use results. | |
| * | |
| * @type {ReturnHandle} | |
| */ | |
| function onsuccessfulconstruct(construct, info) { | |
| addResult(construct, info.from); | |
| } | |
| /** | |
| * Discard results. | |
| * | |
| * @type {ReturnHandle} | |
| */ | |
| function onsuccessfulcheck(_, info) { | |
| info.restore(); | |
| } | |
| /** | |
| * Factory to attempt/check/interrupt. | |
| * | |
| * @param {ReturnHandle} onreturn | |
| * Callback. | |
| * @param {{interrupt?: boolean | undefined} | undefined} [fields] | |
| * Fields. | |
| */ | |
| function constructFactory(onreturn, fields) { | |
| return hook; | |
| /** | |
| * Handle either an object mapping codes to constructs, a list of | |
| * constructs, or a single construct. | |
| * | |
| * @param {Array<Construct> | ConstructRecord | Construct} constructs | |
| * Constructs. | |
| * @param {State} returnState | |
| * State. | |
| * @param {State | undefined} [bogusState] | |
| * State. | |
| * @returns {State} | |
| * State. | |
| */ | |
| function hook(constructs, returnState, bogusState) { | |
| /** @type {ReadonlyArray<Construct>} */ | |
| let listOfConstructs; | |
| /** @type {number} */ | |
| let constructIndex; | |
| /** @type {Construct} */ | |
| let currentConstruct; | |
| /** @type {Info} */ | |
| let info; | |
| return Array.isArray(constructs) ? handleListOfConstructs(constructs) : "tokenize" in constructs ? handleListOfConstructs([constructs]) : handleMapOfConstructs(constructs); | |
| /** | |
| * Handle a list of construct. | |
| * | |
| * @param {ConstructRecord} map | |
| * Constructs. | |
| * @returns {State} | |
| * State. | |
| */ | |
| function handleMapOfConstructs(map) { | |
| return start; | |
| /** @type {State} */ | |
| function start(code) { | |
| const left = code !== null && map[code]; | |
| const all = code !== null && map.null; | |
| return handleListOfConstructs([...Array.isArray(left) ? left : left ? [left] : [], ...Array.isArray(all) ? all : all ? [all] : []])(code); | |
| } | |
| } | |
| /** | |
| * Handle a list of construct. | |
| * | |
| * @param {ReadonlyArray<Construct>} list | |
| * Constructs. | |
| * @returns {State} | |
| * State. | |
| */ | |
| function handleListOfConstructs(list) { | |
| listOfConstructs = list; | |
| constructIndex = 0; | |
| if (list.length === 0) { | |
| ok(bogusState, "expected `bogusState` to be given"); | |
| return bogusState; | |
| } | |
| return handleConstruct(list[constructIndex]); | |
| } | |
| /** | |
| * Handle a single construct. | |
| * | |
| * @param {Construct} construct | |
| * Construct. | |
| * @returns {State} | |
| * State. | |
| */ | |
| function handleConstruct(construct) { | |
| return start; | |
| /** @type {State} */ | |
| function start(code) { | |
| info = store(); | |
| currentConstruct = construct; | |
| if (!construct.partial) context.currentConstruct = construct; | |
| ok(context.parser.constructs.disable.null, "expected `disable.null` to be populated"); | |
| if (construct.name && context.parser.constructs.disable.null.includes(construct.name)) return nok(code); | |
| return construct.tokenize.call(fields ? Object.assign(Object.create(context), fields) : context, effects, ok$1, nok)(code); | |
| } | |
| } | |
| /** @type {State} */ | |
| function ok$1(code) { | |
| ok(code === expectedCode, "expected code"); | |
| consumed = true; | |
| onreturn(currentConstruct, info); | |
| return returnState; | |
| } | |
| /** @type {State} */ | |
| function nok(code) { | |
| ok(code === expectedCode, "expected code"); | |
| consumed = true; | |
| info.restore(); | |
| if (++constructIndex < listOfConstructs.length) return handleConstruct(listOfConstructs[constructIndex]); | |
| return bogusState; | |
| } | |
| } | |
| } | |
| /** | |
| * @param {Construct} construct | |
| * Construct. | |
| * @param {number} from | |
| * From. | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| function addResult(construct, from) { | |
| if (construct.resolveAll && !resolveAllConstructs.includes(construct)) resolveAllConstructs.push(construct); | |
| if (construct.resolve) splice(context.events, from, context.events.length - from, construct.resolve(context.events.slice(from), context)); | |
| if (construct.resolveTo) context.events = construct.resolveTo(context.events, context); | |
| ok(construct.partial || context.events.length === 0 || context.events[context.events.length - 1][0] === "exit", "expected last token to end"); | |
| } | |
| /** | |
| * Store state. | |
| * | |
| * @returns {Info} | |
| * Info. | |
| */ | |
| 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 | |
| }; | |
| /** | |
| * Restore state. | |
| * | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| function restore() { | |
| point = startPoint; | |
| context.previous = startPrevious; | |
| context.currentConstruct = startCurrentConstruct; | |
| context.events.length = startEventsIndex; | |
| stack = startStack; | |
| accountForPotentialSkip(); | |
| debug("position: restore: `%j`", point); | |
| } | |
| } | |
| /** | |
| * Move the current point a bit forward in the line when it’s on a column | |
| * skip. | |
| * | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| function accountForPotentialSkip() { | |
| if (point.line in columnStart && point.column < 2) { | |
| point.column = columnStart[point.line]; | |
| point.offset += columnStart[point.line] - 1; | |
| } | |
| } | |
| } | |
| /** | |
| * Get the chunks from a slice of chunks in the range of a token. | |
| * | |
| * @param {ReadonlyArray<Chunk>} chunks | |
| * Chunks. | |
| * @param {Pick<Token, 'end' | 'start'>} token | |
| * Token. | |
| * @returns {Array<Chunk>} | |
| * Chunks. | |
| */ | |
| function sliceChunks(chunks, token) { | |
| const startIndex = token.start._index; | |
| const startBufferIndex = token.start._bufferIndex; | |
| const endIndex = token.end._index; | |
| const endBufferIndex = token.end._bufferIndex; | |
| /** @type {Array<Chunk>} */ | |
| let view; | |
| if (startIndex === endIndex) { | |
| ok(endBufferIndex > -1, "expected non-negative end buffer index"); | |
| ok(startBufferIndex > -1, "expected non-negative start buffer index"); | |
| 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 { | |
| ok(startBufferIndex === 0, "expected `startBufferIndex` to be `0`"); | |
| view.shift(); | |
| } | |
| } | |
| if (endBufferIndex > 0) view.push(chunks[endIndex].slice(0, endBufferIndex)); | |
| } | |
| return view; | |
| } | |
| /** | |
| * Get the string value of a slice of chunks. | |
| * | |
| * @param {ReadonlyArray<Chunk>} chunks | |
| * Chunks. | |
| * @param {boolean | undefined} [expandTabs=false] | |
| * Whether to expand tabs (default: `false`). | |
| * @returns {string} | |
| * Result. | |
| */ | |
| function serializeChunks(chunks, expandTabs) { | |
| let index = -1; | |
| /** @type {Array<string>} */ | |
| const result = []; | |
| /** @type {boolean | undefined} */ | |
| let atTab; | |
| while (++index < chunks.length) { | |
| const chunk = chunks[index]; | |
| /** @type {string} */ | |
| let value; | |
| if (typeof chunk === "string") value = chunk; | |
| else switch (chunk) { | |
| case codes.carriageReturn: | |
| value = values.cr; | |
| break; | |
| case codes.lineFeed: | |
| value = values.lf; | |
| break; | |
| case codes.carriageReturnLineFeed: | |
| value = values.cr + values.lf; | |
| break; | |
| case codes.horizontalTab: | |
| value = expandTabs ? values.space : values.ht; | |
| break; | |
| case codes.virtualSpace: | |
| if (!expandTabs && atTab) continue; | |
| value = values.space; | |
| break; | |
| default: | |
| ok(typeof chunk === "number", "expected number"); | |
| value = String.fromCharCode(chunk); | |
| } | |
| atTab = chunk === codes.horizontalTab; | |
| result.push(value); | |
| } | |
| return result.join(""); | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark/dev/lib/parse.js | |
| /** | |
| * @import { | |
| * Create, | |
| * FullNormalizedExtension, | |
| * InitialConstruct, | |
| * ParseContext, | |
| * ParseOptions | |
| * } from 'micromark-util-types' | |
| */ | |
| /** | |
| * @param {ParseOptions | null | undefined} [options] | |
| * Configuration (optional). | |
| * @returns {ParseContext} | |
| * Parser. | |
| */ | |
| function parse(options) { | |
| /** @type {ParseContext} */ | |
| const parser = { | |
| constructs: combineExtensions([constructs_exports, ...(options || {}).extensions || []]), | |
| content: create(content$1), | |
| defined: [], | |
| document: create(document$2), | |
| flow: create(flow$1), | |
| lazy: {}, | |
| string: create(string$1), | |
| text: create(text$2) | |
| }; | |
| return parser; | |
| /** | |
| * @param {InitialConstruct} initial | |
| * Construct to start with. | |
| * @returns {Create} | |
| * Create a tokenizer. | |
| */ | |
| function create(initial) { | |
| return creator; | |
| /** @type {Create} */ | |
| function creator(from) { | |
| return createTokenizer(parser, initial, from); | |
| } | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark/dev/lib/postprocess.js | |
| /** | |
| * @import {Event} from 'micromark-util-types' | |
| */ | |
| /** | |
| * @param {Array<Event>} events | |
| * Events. | |
| * @returns {Array<Event>} | |
| * Events. | |
| */ | |
| function postprocess(events) { | |
| while (!subtokenize(events)); | |
| return events; | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark/dev/lib/preprocess.js | |
| /** | |
| * @import {Chunk, Code, Encoding, Value} from 'micromark-util-types' | |
| */ | |
| /** | |
| * @callback Preprocessor | |
| * Preprocess a value. | |
| * @param {Value} value | |
| * Value. | |
| * @param {Encoding | null | undefined} [encoding] | |
| * Encoding when `value` is a typed array (optional). | |
| * @param {boolean | null | undefined} [end=false] | |
| * Whether this is the last chunk (default: `false`). | |
| * @returns {Array<Chunk>} | |
| * Chunks. | |
| */ | |
| var search = /[\0\t\n\r]/g; | |
| /** | |
| * @returns {Preprocessor} | |
| * Preprocess a value. | |
| */ | |
| function preprocess() { | |
| let column = 1; | |
| let buffer = ""; | |
| /** @type {boolean | undefined} */ | |
| let start = true; | |
| /** @type {boolean | undefined} */ | |
| let atCarriageReturn; | |
| return preprocessor; | |
| /** @type {Preprocessor} */ | |
| function preprocessor(value, encoding, end) { | |
| /** @type {Array<Chunk>} */ | |
| const chunks = []; | |
| /** @type {RegExpMatchArray | null} */ | |
| let match; | |
| /** @type {number} */ | |
| let next; | |
| /** @type {number} */ | |
| let startPosition; | |
| /** @type {number} */ | |
| let endPosition; | |
| /** @type {Code} */ | |
| let code; | |
| value = buffer + (typeof value === "string" ? value.toString() : new TextDecoder(encoding || void 0).decode(value)); | |
| startPosition = 0; | |
| buffer = ""; | |
| if (start) { | |
| if (value.charCodeAt(0) === codes.byteOrderMarker) 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; | |
| code = value.charCodeAt(endPosition); | |
| if (!match) { | |
| buffer = value.slice(startPosition); | |
| break; | |
| } | |
| if (code === codes.lf && startPosition === endPosition && atCarriageReturn) { | |
| chunks.push(codes.carriageReturnLineFeed); | |
| atCarriageReturn = void 0; | |
| } else { | |
| if (atCarriageReturn) { | |
| chunks.push(codes.carriageReturn); | |
| atCarriageReturn = void 0; | |
| } | |
| if (startPosition < endPosition) { | |
| chunks.push(value.slice(startPosition, endPosition)); | |
| column += endPosition - startPosition; | |
| } | |
| switch (code) { | |
| case codes.nul: | |
| chunks.push(codes.replacementCharacter); | |
| column++; | |
| break; | |
| case codes.ht: | |
| next = Math.ceil(column / constants.tabSize) * constants.tabSize; | |
| chunks.push(codes.horizontalTab); | |
| while (column++ < next) chunks.push(codes.virtualSpace); | |
| break; | |
| case codes.lf: | |
| chunks.push(codes.lineFeed); | |
| column = 1; | |
| break; | |
| default: | |
| atCarriageReturn = true; | |
| column = 1; | |
| } | |
| } | |
| startPosition = endPosition + 1; | |
| } | |
| if (end) { | |
| if (atCarriageReturn) chunks.push(codes.carriageReturn); | |
| if (buffer) chunks.push(buffer); | |
| chunks.push(codes.eof); | |
| } | |
| return chunks; | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/micromark-util-decode-string/dev/index.js | |
| var characterEscapeOrReference = /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi; | |
| /** | |
| * Decode markdown strings (which occur in places such as fenced code info | |
| * strings, destinations, labels, and titles). | |
| * | |
| * The “string” content type allows character escapes and -references. | |
| * This decodes those. | |
| * | |
| * @param {string} value | |
| * Value to decode. | |
| * @returns {string} | |
| * Decoded value. | |
| */ | |
| function decodeString(value) { | |
| return value.replace(characterEscapeOrReference, decode); | |
| } | |
| /** | |
| * @param {string} $0 | |
| * Match. | |
| * @param {string} $1 | |
| * Character escape. | |
| * @param {string} $2 | |
| * Character reference. | |
| * @returns {string} | |
| * Decoded value | |
| */ | |
| function decode($0, $1, $2) { | |
| if ($1) return $1; | |
| if ($2.charCodeAt(0) === codes.numberSign) { | |
| const head = $2.charCodeAt(1); | |
| const hex = head === codes.lowercaseX || head === codes.uppercaseX; | |
| return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? constants.numericBaseHexadecimal : constants.numericBaseDecimal); | |
| } | |
| return decodeNamedCharacterReference($2) || $0; | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-from-markdown/dev/lib/index.js | |
| /** | |
| * @import { | |
| * Break, | |
| * Blockquote, | |
| * Code, | |
| * Definition, | |
| * Emphasis, | |
| * Heading, | |
| * Html, | |
| * Image, | |
| * InlineCode, | |
| * Link, | |
| * ListItem, | |
| * List, | |
| * Nodes, | |
| * Paragraph, | |
| * PhrasingContent, | |
| * ReferenceType, | |
| * Root, | |
| * Strong, | |
| * Text, | |
| * ThematicBreak | |
| * } from 'mdast' | |
| * @import { | |
| * Encoding, | |
| * Event, | |
| * Token, | |
| * Value | |
| * } from 'micromark-util-types' | |
| * @import {Point} from 'unist' | |
| * @import { | |
| * CompileContext, | |
| * CompileData, | |
| * Config, | |
| * Extension, | |
| * Handle, | |
| * OnEnterError, | |
| * Options | |
| * } from './types.js' | |
| */ | |
| var own$2 = {}.hasOwnProperty; | |
| /** | |
| * Turn markdown into a syntax tree. | |
| * | |
| * @overload | |
| * @param {Value} value | |
| * @param {Encoding | null | undefined} [encoding] | |
| * @param {Options | null | undefined} [options] | |
| * @returns {Root} | |
| * | |
| * @overload | |
| * @param {Value} value | |
| * @param {Options | null | undefined} [options] | |
| * @returns {Root} | |
| * | |
| * @param {Value} value | |
| * Markdown to parse. | |
| * @param {Encoding | Options | null | undefined} [encoding] | |
| * Character encoding for when `value` is `Buffer`. | |
| * @param {Options | null | undefined} [options] | |
| * Configuration. | |
| * @returns {Root} | |
| * mdast tree. | |
| */ | |
| function fromMarkdown(value, encoding, options) { | |
| if (encoding && typeof encoding === "object") { | |
| options = encoding; | |
| encoding = void 0; | |
| } | |
| return compiler(options)(postprocess(parse(options).document().write(preprocess()(value, encoding, true)))); | |
| } | |
| /** | |
| * Note this compiler only understand complete buffering, not streaming. | |
| * | |
| * @param {Options | null | undefined} [options] | |
| */ | |
| function compiler(options) { | |
| /** @type {Config} */ | |
| const config = { | |
| transforms: [], | |
| canContainEols: [ | |
| "emphasis", | |
| "fragment", | |
| "heading", | |
| "paragraph", | |
| "strong" | |
| ], | |
| enter: { | |
| autolink: opener(link), | |
| autolinkProtocol: onenterdata, | |
| autolinkEmail: onenterdata, | |
| atxHeading: opener(heading), | |
| blockQuote: opener(blockQuote), | |
| characterEscape: onenterdata, | |
| characterReference: onenterdata, | |
| codeFenced: opener(codeFlow), | |
| codeFencedFenceInfo: buffer, | |
| codeFencedFenceMeta: buffer, | |
| codeIndented: opener(codeFlow, buffer), | |
| codeText: opener(codeText, buffer), | |
| codeTextData: onenterdata, | |
| data: onenterdata, | |
| codeFlowValue: onenterdata, | |
| definition: opener(definition), | |
| definitionDestinationString: buffer, | |
| definitionLabelString: buffer, | |
| definitionTitleString: buffer, | |
| emphasis: opener(emphasis), | |
| hardBreakEscape: opener(hardBreak), | |
| hardBreakTrailing: opener(hardBreak), | |
| htmlFlow: opener(html, buffer), | |
| htmlFlowData: onenterdata, | |
| htmlText: opener(html, buffer), | |
| htmlTextData: onenterdata, | |
| image: opener(image), | |
| label: buffer, | |
| link: opener(link), | |
| listItem: opener(listItem), | |
| listItemValue: onenterlistitemvalue, | |
| listOrdered: opener(list, onenterlistordered), | |
| listUnordered: opener(list), | |
| paragraph: opener(paragraph), | |
| reference: onenterreference, | |
| referenceString: buffer, | |
| resourceDestinationString: buffer, | |
| resourceTitleString: buffer, | |
| setextHeading: opener(heading), | |
| strong: opener(strong), | |
| thematicBreak: opener(thematicBreak) | |
| }, | |
| exit: { | |
| atxHeading: closer(), | |
| atxHeadingSequence: onexitatxheadingsequence, | |
| autolink: closer(), | |
| autolinkEmail: onexitautolinkemail, | |
| autolinkProtocol: onexitautolinkprotocol, | |
| blockQuote: closer(), | |
| characterEscapeValue: onexitdata, | |
| characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker, | |
| characterReferenceMarkerNumeric: onexitcharacterreferencemarker, | |
| characterReferenceValue: onexitcharacterreferencevalue, | |
| characterReference: onexitcharacterreference, | |
| codeFenced: closer(onexitcodefenced), | |
| codeFencedFence: onexitcodefencedfence, | |
| codeFencedFenceInfo: onexitcodefencedfenceinfo, | |
| codeFencedFenceMeta: onexitcodefencedfencemeta, | |
| codeFlowValue: onexitdata, | |
| codeIndented: closer(onexitcodeindented), | |
| codeText: closer(onexitcodetext), | |
| codeTextData: onexitdata, | |
| data: onexitdata, | |
| definition: closer(), | |
| definitionDestinationString: onexitdefinitiondestinationstring, | |
| definitionLabelString: onexitdefinitionlabelstring, | |
| definitionTitleString: onexitdefinitiontitlestring, | |
| emphasis: closer(), | |
| hardBreakEscape: closer(onexithardbreak), | |
| hardBreakTrailing: closer(onexithardbreak), | |
| htmlFlow: closer(onexithtmlflow), | |
| htmlFlowData: onexitdata, | |
| htmlText: closer(onexithtmltext), | |
| htmlTextData: onexitdata, | |
| image: closer(onexitimage), | |
| label: onexitlabel, | |
| labelText: onexitlabeltext, | |
| lineEnding: onexitlineending, | |
| link: closer(onexitlink), | |
| listItem: closer(), | |
| listOrdered: closer(), | |
| listUnordered: closer(), | |
| paragraph: closer(), | |
| referenceString: onexitreferencestring, | |
| resourceDestinationString: onexitresourcedestinationstring, | |
| resourceTitleString: onexitresourcetitlestring, | |
| resource: onexitresource, | |
| setextHeading: closer(onexitsetextheading), | |
| setextHeadingLineSequence: onexitsetextheadinglinesequence, | |
| setextHeadingText: onexitsetextheadingtext, | |
| strong: closer(), | |
| thematicBreak: closer() | |
| } | |
| }; | |
| configure(config, (options || {}).mdastExtensions || []); | |
| /** @type {CompileData} */ | |
| const data = {}; | |
| return compile; | |
| /** | |
| * Turn micromark events into an mdast tree. | |
| * | |
| * @param {Array<Event>} events | |
| * Events. | |
| * @returns {Root} | |
| * mdast tree. | |
| */ | |
| function compile(events) { | |
| /** @type {Root} */ | |
| let tree = { | |
| type: "root", | |
| children: [] | |
| }; | |
| /** @type {Omit<CompileContext, 'sliceSerialize'>} */ | |
| const context = { | |
| stack: [tree], | |
| tokenStack: [], | |
| config, | |
| enter, | |
| exit, | |
| buffer, | |
| resume, | |
| data | |
| }; | |
| /** @type {Array<number>} */ | |
| const listStack = []; | |
| let index = -1; | |
| while (++index < events.length) if (events[index][1].type === types.listOrdered || events[index][1].type === types.listUnordered) if (events[index][0] === "enter") listStack.push(index); | |
| else { | |
| const tail = listStack.pop(); | |
| ok(typeof tail === "number", "expected list to be open"); | |
| index = prepareList(events, tail, index); | |
| } | |
| index = -1; | |
| while (++index < events.length) { | |
| const handler = config[events[index][0]]; | |
| if (own$2.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]; | |
| (tail[1] || defaultOnError).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; | |
| } | |
| /** | |
| * @param {Array<Event>} events | |
| * @param {number} start | |
| * @param {number} length | |
| * @returns {number} | |
| */ | |
| function prepareList(events, start, length) { | |
| let index = start - 1; | |
| let containerBalance = -1; | |
| let listSpread = false; | |
| /** @type {Token | undefined} */ | |
| let listItem; | |
| /** @type {number | undefined} */ | |
| let lineIndex; | |
| /** @type {number | undefined} */ | |
| let firstBlankLineIndex; | |
| /** @type {boolean | undefined} */ | |
| let atMarker; | |
| while (++index <= length) { | |
| const event = events[index]; | |
| switch (event[1].type) { | |
| case types.listUnordered: | |
| case types.listOrdered: | |
| case types.blockQuote: | |
| if (event[0] === "enter") containerBalance++; | |
| else containerBalance--; | |
| atMarker = void 0; | |
| break; | |
| case types.lineEndingBlank: | |
| if (event[0] === "enter") { | |
| if (listItem && !atMarker && !containerBalance && !firstBlankLineIndex) firstBlankLineIndex = index; | |
| atMarker = void 0; | |
| } | |
| break; | |
| case types.linePrefix: | |
| case types.listItemValue: | |
| case types.listItemMarker: | |
| case types.listItemPrefix: | |
| case types.listItemPrefixWhitespace: break; | |
| default: atMarker = void 0; | |
| } | |
| if (!containerBalance && event[0] === "enter" && event[1].type === types.listItemPrefix || containerBalance === -1 && event[0] === "exit" && (event[1].type === types.listUnordered || event[1].type === types.listOrdered)) { | |
| if (listItem) { | |
| let tailIndex = index; | |
| lineIndex = void 0; | |
| while (tailIndex--) { | |
| const tailEvent = events[tailIndex]; | |
| if (tailEvent[1].type === types.lineEnding || tailEvent[1].type === types.lineEndingBlank) { | |
| if (tailEvent[0] === "exit") continue; | |
| if (lineIndex) { | |
| events[lineIndex][1].type = types.lineEndingBlank; | |
| listSpread = true; | |
| } | |
| tailEvent[1].type = types.lineEnding; | |
| lineIndex = tailIndex; | |
| } else if (tailEvent[1].type === types.linePrefix || tailEvent[1].type === types.blockQuotePrefix || tailEvent[1].type === types.blockQuotePrefixWhitespace || tailEvent[1].type === types.blockQuoteMarker || tailEvent[1].type === types.listItemIndent) {} else break; | |
| } | |
| if (firstBlankLineIndex && (!lineIndex || firstBlankLineIndex < lineIndex)) listItem._spread = true; | |
| listItem.end = Object.assign({}, lineIndex ? events[lineIndex][1].start : event[1].end); | |
| events.splice(lineIndex || index, 0, [ | |
| "exit", | |
| listItem, | |
| event[2] | |
| ]); | |
| index++; | |
| length++; | |
| } | |
| if (event[1].type === types.listItemPrefix) { | |
| /** @type {Token} */ | |
| const item = { | |
| type: "listItem", | |
| _spread: false, | |
| start: Object.assign({}, event[1].start), | |
| end: void 0 | |
| }; | |
| listItem = item; | |
| events.splice(index, 0, [ | |
| "enter", | |
| item, | |
| event[2] | |
| ]); | |
| index++; | |
| length++; | |
| firstBlankLineIndex = void 0; | |
| atMarker = true; | |
| } | |
| } | |
| } | |
| events[start][1]._spread = listSpread; | |
| return length; | |
| } | |
| /** | |
| * Create an opener handle. | |
| * | |
| * @param {(token: Token) => Nodes} create | |
| * Create a node. | |
| * @param {Handle | undefined} [and] | |
| * Optional function to also run. | |
| * @returns {Handle} | |
| * Handle. | |
| */ | |
| function opener(create, and) { | |
| return open; | |
| /** | |
| * @this {CompileContext} | |
| * @param {Token} token | |
| * @returns {undefined} | |
| */ | |
| function open(token) { | |
| enter.call(this, create(token), token); | |
| if (and) and.call(this, token); | |
| } | |
| } | |
| /** | |
| * @type {CompileContext['buffer']} | |
| */ | |
| function buffer() { | |
| this.stack.push({ | |
| type: "fragment", | |
| children: [] | |
| }); | |
| } | |
| /** | |
| * @type {CompileContext['enter']} | |
| */ | |
| function enter(node, token, errorHandler) { | |
| const parent = this.stack[this.stack.length - 1]; | |
| ok(parent, "expected `parent`"); | |
| ok("children" in parent, "expected `parent`"); | |
| parent.children.push(node); | |
| this.stack.push(node); | |
| this.tokenStack.push([token, errorHandler || void 0]); | |
| node.position = { | |
| start: point(token.start), | |
| end: void 0 | |
| }; | |
| } | |
| /** | |
| * Create a closer handle. | |
| * | |
| * @param {Handle | undefined} [and] | |
| * Optional function to also run. | |
| * @returns {Handle} | |
| * Handle. | |
| */ | |
| function closer(and) { | |
| return close; | |
| /** | |
| * @this {CompileContext} | |
| * @param {Token} token | |
| * @returns {undefined} | |
| */ | |
| function close(token) { | |
| if (and) and.call(this, token); | |
| exit.call(this, token); | |
| } | |
| } | |
| /** | |
| * @type {CompileContext['exit']} | |
| */ | |
| function exit(token, onExitError) { | |
| const node = this.stack.pop(); | |
| ok(node, "expected `node`"); | |
| 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 (open[1] || defaultOnError).call(this, token, open[0]); | |
| ok(node.type !== "fragment", "unexpected fragment `exit`ed"); | |
| ok(node.position, "expected `position` to be defined"); | |
| node.position.end = point(token.end); | |
| } | |
| /** | |
| * @type {CompileContext['resume']} | |
| */ | |
| function resume() { | |
| return toString$1(this.stack.pop()); | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onenterlistordered() { | |
| this.data.expectingFirstListItemValue = true; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onenterlistitemvalue(token) { | |
| if (this.data.expectingFirstListItemValue) { | |
| const ancestor = this.stack[this.stack.length - 2]; | |
| ok(ancestor, "expected nodes on stack"); | |
| ok(ancestor.type === "list", "expected list on stack"); | |
| ancestor.start = Number.parseInt(this.sliceSerialize(token), constants.numericBaseDecimal); | |
| this.data.expectingFirstListItemValue = void 0; | |
| } | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitcodefencedfenceinfo() { | |
| const data = this.resume(); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "code", "expected code on stack"); | |
| node.lang = data; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitcodefencedfencemeta() { | |
| const data = this.resume(); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "code", "expected code on stack"); | |
| node.meta = data; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitcodefencedfence() { | |
| if (this.data.flowCodeInside) return; | |
| this.buffer(); | |
| this.data.flowCodeInside = true; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitcodefenced() { | |
| const data = this.resume(); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "code", "expected code on stack"); | |
| node.value = data.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, ""); | |
| this.data.flowCodeInside = void 0; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitcodeindented() { | |
| const data = this.resume(); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "code", "expected code on stack"); | |
| node.value = data.replace(/(\r?\n|\r)$/g, ""); | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitdefinitionlabelstring(token) { | |
| const label = this.resume(); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "definition", "expected definition on stack"); | |
| node.label = label; | |
| node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase(); | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitdefinitiontitlestring() { | |
| const data = this.resume(); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "definition", "expected definition on stack"); | |
| node.title = data; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitdefinitiondestinationstring() { | |
| const data = this.resume(); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "definition", "expected definition on stack"); | |
| node.url = data; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitatxheadingsequence(token) { | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "heading", "expected heading on stack"); | |
| if (!node.depth) { | |
| const depth = this.sliceSerialize(token).length; | |
| ok(depth === 1 || depth === 2 || depth === 3 || depth === 4 || depth === 5 || depth === 6, "expected `depth` between `1` and `6`"); | |
| node.depth = depth; | |
| } | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitsetextheadingtext() { | |
| this.data.setextHeadingSlurpLineEnding = true; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitsetextheadinglinesequence(token) { | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "heading", "expected heading on stack"); | |
| node.depth = this.sliceSerialize(token).codePointAt(0) === codes.equalsTo ? 1 : 2; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitsetextheading() { | |
| this.data.setextHeadingSlurpLineEnding = void 0; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onenterdata(token) { | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok("children" in node, "expected parent on stack"); | |
| /** @type {Array<Nodes>} */ | |
| const siblings = node.children; | |
| let tail = siblings[siblings.length - 1]; | |
| if (!tail || tail.type !== "text") { | |
| tail = text(); | |
| tail.position = { | |
| start: point(token.start), | |
| end: void 0 | |
| }; | |
| siblings.push(tail); | |
| } | |
| this.stack.push(tail); | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitdata(token) { | |
| const tail = this.stack.pop(); | |
| ok(tail, "expected a `node` to be on the stack"); | |
| ok("value" in tail, "expected a `literal` to be on the stack"); | |
| ok(tail.position, "expected `node` to have an open position"); | |
| tail.value += this.sliceSerialize(token); | |
| tail.position.end = point(token.end); | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitlineending(token) { | |
| const context = this.stack[this.stack.length - 1]; | |
| ok(context, "expected `node`"); | |
| if (this.data.atHardBreak) { | |
| ok("children" in context, "expected `parent`"); | |
| const tail = context.children[context.children.length - 1]; | |
| ok(tail.position, "expected tail to have a starting position"); | |
| 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); | |
| } | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexithardbreak() { | |
| this.data.atHardBreak = true; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexithtmlflow() { | |
| const data = this.resume(); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "html", "expected html on stack"); | |
| node.value = data; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexithtmltext() { | |
| const data = this.resume(); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "html", "expected html on stack"); | |
| node.value = data; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitcodetext() { | |
| const data = this.resume(); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "inlineCode", "expected inline code on stack"); | |
| node.value = data; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitlink() { | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "link", "expected link on stack"); | |
| if (this.data.inReference) { | |
| /** @type {ReferenceType} */ | |
| 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; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitimage() { | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "image", "expected image on stack"); | |
| if (this.data.inReference) { | |
| /** @type {ReferenceType} */ | |
| 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; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitlabeltext(token) { | |
| const string = this.sliceSerialize(token); | |
| const ancestor = this.stack[this.stack.length - 2]; | |
| ok(ancestor, "expected ancestor on stack"); | |
| ok(ancestor.type === "image" || ancestor.type === "link", "expected image or link on stack"); | |
| ancestor.label = decodeString(string); | |
| ancestor.identifier = normalizeIdentifier(string).toLowerCase(); | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitlabel() { | |
| const fragment = this.stack[this.stack.length - 1]; | |
| ok(fragment, "expected node on stack"); | |
| ok(fragment.type === "fragment", "expected fragment on stack"); | |
| const value = this.resume(); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "image" || node.type === "link", "expected image or link on stack"); | |
| this.data.inReference = true; | |
| if (node.type === "link") node.children = fragment.children; | |
| else node.alt = value; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitresourcedestinationstring() { | |
| const data = this.resume(); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "image" || node.type === "link", "expected image or link on stack"); | |
| node.url = data; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitresourcetitlestring() { | |
| const data = this.resume(); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "image" || node.type === "link", "expected image or link on stack"); | |
| node.title = data; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitresource() { | |
| this.data.inReference = void 0; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onenterreference() { | |
| this.data.referenceType = "collapsed"; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitreferencestring(token) { | |
| const label = this.resume(); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "image" || node.type === "link", "expected image reference or link reference on stack"); | |
| node.label = label; | |
| node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase(); | |
| this.data.referenceType = "full"; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitcharacterreferencemarker(token) { | |
| ok(token.type === "characterReferenceMarkerNumeric" || token.type === "characterReferenceMarkerHexadecimal"); | |
| this.data.characterReferenceType = token.type; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitcharacterreferencevalue(token) { | |
| const data = this.sliceSerialize(token); | |
| const type = this.data.characterReferenceType; | |
| /** @type {string} */ | |
| let value; | |
| if (type) { | |
| value = decodeNumericCharacterReference(data, type === types.characterReferenceMarkerNumeric ? constants.numericBaseDecimal : constants.numericBaseHexadecimal); | |
| this.data.characterReferenceType = void 0; | |
| } else { | |
| const result = decodeNamedCharacterReference(data); | |
| ok(result !== false, "expected reference to decode"); | |
| value = result; | |
| } | |
| const tail = this.stack[this.stack.length - 1]; | |
| ok(tail, "expected `node`"); | |
| ok("value" in tail, "expected `node.value`"); | |
| tail.value += value; | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitcharacterreference(token) { | |
| const tail = this.stack.pop(); | |
| ok(tail, "expected `node`"); | |
| ok(tail.position, "expected `node.position`"); | |
| tail.position.end = point(token.end); | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitautolinkprotocol(token) { | |
| onexitdata.call(this, token); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "link", "expected link on stack"); | |
| node.url = this.sliceSerialize(token); | |
| } | |
| /** | |
| * @this {CompileContext} | |
| * @type {Handle} | |
| */ | |
| function onexitautolinkemail(token) { | |
| onexitdata.call(this, token); | |
| const node = this.stack[this.stack.length - 1]; | |
| ok(node, "expected node on stack"); | |
| ok(node.type === "link", "expected link on stack"); | |
| node.url = "mailto:" + this.sliceSerialize(token); | |
| } | |
| /** @returns {Blockquote} */ | |
| function blockQuote() { | |
| return { | |
| type: "blockquote", | |
| children: [] | |
| }; | |
| } | |
| /** @returns {Code} */ | |
| function codeFlow() { | |
| return { | |
| type: "code", | |
| lang: null, | |
| meta: null, | |
| value: "" | |
| }; | |
| } | |
| /** @returns {InlineCode} */ | |
| function codeText() { | |
| return { | |
| type: "inlineCode", | |
| value: "" | |
| }; | |
| } | |
| /** @returns {Definition} */ | |
| function definition() { | |
| return { | |
| type: "definition", | |
| identifier: "", | |
| label: null, | |
| title: null, | |
| url: "" | |
| }; | |
| } | |
| /** @returns {Emphasis} */ | |
| function emphasis() { | |
| return { | |
| type: "emphasis", | |
| children: [] | |
| }; | |
| } | |
| /** @returns {Heading} */ | |
| function heading() { | |
| return { | |
| type: "heading", | |
| depth: 0, | |
| children: [] | |
| }; | |
| } | |
| /** @returns {Break} */ | |
| function hardBreak() { | |
| return { type: "break" }; | |
| } | |
| /** @returns {Html} */ | |
| function html() { | |
| return { | |
| type: "html", | |
| value: "" | |
| }; | |
| } | |
| /** @returns {Image} */ | |
| function image() { | |
| return { | |
| type: "image", | |
| title: null, | |
| url: "", | |
| alt: null | |
| }; | |
| } | |
| /** @returns {Link} */ | |
| function link() { | |
| return { | |
| type: "link", | |
| title: null, | |
| url: "", | |
| children: [] | |
| }; | |
| } | |
| /** | |
| * @param {Token} token | |
| * @returns {List} | |
| */ | |
| function list(token) { | |
| return { | |
| type: "list", | |
| ordered: token.type === "listOrdered", | |
| start: null, | |
| spread: token._spread, | |
| children: [] | |
| }; | |
| } | |
| /** | |
| * @param {Token} token | |
| * @returns {ListItem} | |
| */ | |
| function listItem(token) { | |
| return { | |
| type: "listItem", | |
| spread: token._spread, | |
| checked: null, | |
| children: [] | |
| }; | |
| } | |
| /** @returns {Paragraph} */ | |
| function paragraph() { | |
| return { | |
| type: "paragraph", | |
| children: [] | |
| }; | |
| } | |
| /** @returns {Strong} */ | |
| function strong() { | |
| return { | |
| type: "strong", | |
| children: [] | |
| }; | |
| } | |
| /** @returns {Text} */ | |
| function text() { | |
| return { | |
| type: "text", | |
| value: "" | |
| }; | |
| } | |
| /** @returns {ThematicBreak} */ | |
| function thematicBreak() { | |
| return { type: "thematicBreak" }; | |
| } | |
| } | |
| /** | |
| * Copy a point-like value. | |
| * | |
| * @param {Point} d | |
| * Point-like value. | |
| * @returns {Point} | |
| * unist point. | |
| */ | |
| function point(d) { | |
| return { | |
| line: d.line, | |
| column: d.column, | |
| offset: d.offset | |
| }; | |
| } | |
| /** | |
| * @param {Config} combined | |
| * @param {Array<Array<Extension> | Extension>} extensions | |
| * @returns {undefined} | |
| */ | |
| function configure(combined, extensions) { | |
| let index = -1; | |
| while (++index < extensions.length) { | |
| const value = extensions[index]; | |
| if (Array.isArray(value)) configure(combined, value); | |
| else extension(combined, value); | |
| } | |
| } | |
| /** | |
| * @param {Config} combined | |
| * @param {Extension} extension | |
| * @returns {undefined} | |
| */ | |
| function extension(combined, extension) { | |
| /** @type {keyof Extension} */ | |
| let key; | |
| for (key in extension) if (own$2.call(extension, key)) switch (key) { | |
| case "canContainEols": { | |
| const right = extension[key]; | |
| if (right) combined[key].push(...right); | |
| break; | |
| } | |
| case "transforms": { | |
| const right = extension[key]; | |
| if (right) combined[key].push(...right); | |
| break; | |
| } | |
| case "enter": | |
| case "exit": { | |
| const right = extension[key]; | |
| if (right) Object.assign(combined[key], right); | |
| break; | |
| } | |
| } | |
| } | |
| /** @type {OnEnterError} */ | |
| function defaultOnError(left, right) { | |
| if (left) throw new Error("Cannot close `" + left.type + "` (" + stringifyPosition({ | |
| start: left.start, | |
| end: left.end | |
| }) + "): a different token (`" + right.type + "`, " + stringifyPosition({ | |
| start: right.start, | |
| end: right.end | |
| }) + ") is open"); | |
| else throw new Error("Cannot close document, a token (`" + right.type + "`, " + stringifyPosition({ | |
| start: right.start, | |
| end: right.end | |
| }) + ") is still open"); | |
| } | |
| //#endregion | |
| //#region ../node_modules/remark-parse/lib/index.js | |
| /** | |
| * @typedef {import('mdast').Root} Root | |
| * @typedef {import('mdast-util-from-markdown').Options} FromMarkdownOptions | |
| * @typedef {import('unified').Parser<Root>} Parser | |
| * @typedef {import('unified').Processor<Root>} Processor | |
| */ | |
| /** | |
| * @typedef {Omit<FromMarkdownOptions, 'extensions' | 'mdastExtensions'>} Options | |
| */ | |
| /** | |
| * Aadd support for parsing from markdown. | |
| * | |
| * @param {Readonly<Options> | null | undefined} [options] | |
| * Configuration (optional). | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| function remarkParse(options) { | |
| /** @type {Processor} */ | |
| const self = this; | |
| self.parser = parser; | |
| /** | |
| * @type {Parser} | |
| */ | |
| function parser(doc) { | |
| return fromMarkdown(doc, { | |
| ...self.data("settings"), | |
| ...options, | |
| extensions: self.data("micromarkExtensions") || [], | |
| mdastExtensions: self.data("fromMarkdownExtensions") || [] | |
| }); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/blockquote.js | |
| /** | |
| * @import {Element} from 'hast' | |
| * @import {Blockquote} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `blockquote` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Blockquote} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function blockquote(state, node) { | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "blockquote", | |
| properties: {}, | |
| children: state.wrap(state.all(node), true) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/break.js | |
| /** | |
| * @import {Element, Text} from 'hast' | |
| * @import {Break} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `break` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Break} node | |
| * mdast node. | |
| * @returns {Array<Element | Text>} | |
| * hast element content. | |
| */ | |
| function hardBreak(state, node) { | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "br", | |
| properties: {}, | |
| children: [] | |
| }; | |
| state.patch(node, result); | |
| return [state.applyData(node, result), { | |
| type: "text", | |
| value: "\n" | |
| }]; | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/code.js | |
| /** | |
| * @import {Element, Properties} from 'hast' | |
| * @import {Code} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `code` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Code} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function code(state, node) { | |
| const value = node.value ? node.value + "\n" : ""; | |
| /** @type {Properties} */ | |
| const properties = {}; | |
| const language = node.lang ? node.lang.split(/\s+/) : []; | |
| if (language.length > 0) properties.className = ["language-" + language[0]]; | |
| /** @type {Element} */ | |
| let result = { | |
| type: "element", | |
| tagName: "code", | |
| properties, | |
| children: [{ | |
| type: "text", | |
| value | |
| }] | |
| }; | |
| if (node.meta) result.data = { meta: node.meta }; | |
| state.patch(node, result); | |
| result = state.applyData(node, result); | |
| result = { | |
| type: "element", | |
| tagName: "pre", | |
| properties: {}, | |
| children: [result] | |
| }; | |
| state.patch(node, result); | |
| return result; | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/delete.js | |
| /** | |
| * @import {Element} from 'hast' | |
| * @import {Delete} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `delete` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Delete} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function strikethrough(state, node) { | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "del", | |
| properties: {}, | |
| children: state.all(node) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/emphasis.js | |
| /** | |
| * @import {Element} from 'hast' | |
| * @import {Emphasis} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `emphasis` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Emphasis} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function emphasis(state, node) { | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "em", | |
| properties: {}, | |
| children: state.all(node) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/footnote-reference.js | |
| /** | |
| * @import {Element} from 'hast' | |
| * @import {FootnoteReference} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `footnoteReference` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {FootnoteReference} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function footnoteReference(state, node) { | |
| const clobberPrefix = typeof state.options.clobberPrefix === "string" ? state.options.clobberPrefix : "user-content-"; | |
| const id = String(node.identifier).toUpperCase(); | |
| const safeId = normalizeUri(id.toLowerCase()); | |
| const index = state.footnoteOrder.indexOf(id); | |
| /** @type {number} */ | |
| let counter; | |
| let reuseCounter = state.footnoteCounts.get(id); | |
| if (reuseCounter === void 0) { | |
| reuseCounter = 0; | |
| state.footnoteOrder.push(id); | |
| counter = state.footnoteOrder.length; | |
| } else counter = index + 1; | |
| reuseCounter += 1; | |
| state.footnoteCounts.set(id, reuseCounter); | |
| /** @type {Element} */ | |
| const link = { | |
| type: "element", | |
| tagName: "a", | |
| properties: { | |
| href: "#" + clobberPrefix + "fn-" + safeId, | |
| id: clobberPrefix + "fnref-" + safeId + (reuseCounter > 1 ? "-" + reuseCounter : ""), | |
| dataFootnoteRef: true, | |
| ariaDescribedBy: ["footnote-label"] | |
| }, | |
| children: [{ | |
| type: "text", | |
| value: String(counter) | |
| }] | |
| }; | |
| state.patch(node, link); | |
| /** @type {Element} */ | |
| const sup = { | |
| type: "element", | |
| tagName: "sup", | |
| properties: {}, | |
| children: [link] | |
| }; | |
| state.patch(node, sup); | |
| return state.applyData(node, sup); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/heading.js | |
| /** | |
| * @import {Element} from 'hast' | |
| * @import {Heading} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `heading` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Heading} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function heading(state, node) { | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "h" + node.depth, | |
| properties: {}, | |
| children: state.all(node) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/html.js | |
| /** | |
| * @import {Element} from 'hast' | |
| * @import {Html} from 'mdast' | |
| * @import {State} from '../state.js' | |
| * @import {Raw} from '../../index.js' | |
| */ | |
| /** | |
| * Turn an mdast `html` node into hast (`raw` node in dangerous mode, otherwise | |
| * nothing). | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Html} node | |
| * mdast node. | |
| * @returns {Element | Raw | undefined} | |
| * hast node. | |
| */ | |
| function html(state, node) { | |
| if (state.options.allowDangerousHtml) { | |
| /** @type {Raw} */ | |
| const result = { | |
| type: "raw", | |
| value: node.value | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/revert.js | |
| /** | |
| * @import {ElementContent} from 'hast' | |
| * @import {Reference, Nodes} from 'mdast' | |
| * @import {State} from './state.js' | |
| */ | |
| /** | |
| * Return the content of a reference without definition as plain text. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Extract<Nodes, Reference>} node | |
| * Reference node (image, link). | |
| * @returns {Array<ElementContent>} | |
| * hast content. | |
| */ | |
| function revert(state, node) { | |
| const subtype = node.referenceType; | |
| let suffix = "]"; | |
| if (subtype === "collapsed") suffix += "[]"; | |
| else if (subtype === "full") suffix += "[" + (node.label || node.identifier) + "]"; | |
| if (node.type === "imageReference") return [{ | |
| type: "text", | |
| value: "![" + node.alt + suffix | |
| }]; | |
| const contents = state.all(node); | |
| const head = contents[0]; | |
| if (head && head.type === "text") head.value = "[" + head.value; | |
| else contents.unshift({ | |
| type: "text", | |
| value: "[" | |
| }); | |
| const tail = contents[contents.length - 1]; | |
| if (tail && tail.type === "text") tail.value += suffix; | |
| else contents.push({ | |
| type: "text", | |
| value: suffix | |
| }); | |
| return contents; | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/image-reference.js | |
| /** | |
| * @import {ElementContent, Element, Properties} from 'hast' | |
| * @import {ImageReference} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `imageReference` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {ImageReference} node | |
| * mdast node. | |
| * @returns {Array<ElementContent> | ElementContent} | |
| * hast node. | |
| */ | |
| function imageReference(state, node) { | |
| const id = String(node.identifier).toUpperCase(); | |
| const definition = state.definitionById.get(id); | |
| if (!definition) return revert(state, node); | |
| /** @type {Properties} */ | |
| const properties = { | |
| src: normalizeUri(definition.url || ""), | |
| alt: node.alt | |
| }; | |
| if (definition.title !== null && definition.title !== void 0) properties.title = definition.title; | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "img", | |
| properties, | |
| children: [] | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/image.js | |
| /** | |
| * @import {Element, Properties} from 'hast' | |
| * @import {Image} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `image` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Image} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function image(state, node) { | |
| /** @type {Properties} */ | |
| 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; | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "img", | |
| properties, | |
| children: [] | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/inline-code.js | |
| /** | |
| * @import {Element, Text} from 'hast' | |
| * @import {InlineCode} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `inlineCode` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {InlineCode} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function inlineCode(state, node) { | |
| /** @type {Text} */ | |
| const text = { | |
| type: "text", | |
| value: node.value.replace(/\r?\n|\r/g, " ") | |
| }; | |
| state.patch(node, text); | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "code", | |
| properties: {}, | |
| children: [text] | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/link-reference.js | |
| /** | |
| * @import {ElementContent, Element, Properties} from 'hast' | |
| * @import {LinkReference} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `linkReference` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {LinkReference} node | |
| * mdast node. | |
| * @returns {Array<ElementContent> | ElementContent} | |
| * hast node. | |
| */ | |
| function linkReference(state, node) { | |
| const id = String(node.identifier).toUpperCase(); | |
| const definition = state.definitionById.get(id); | |
| if (!definition) return revert(state, node); | |
| /** @type {Properties} */ | |
| const properties = { href: normalizeUri(definition.url || "") }; | |
| if (definition.title !== null && definition.title !== void 0) properties.title = definition.title; | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "a", | |
| properties, | |
| children: state.all(node) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/link.js | |
| /** | |
| * @import {Element, Properties} from 'hast' | |
| * @import {Link} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `link` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Link} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function link(state, node) { | |
| /** @type {Properties} */ | |
| const properties = { href: normalizeUri(node.url) }; | |
| if (node.title !== null && node.title !== void 0) properties.title = node.title; | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "a", | |
| properties, | |
| children: state.all(node) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/list-item.js | |
| /** | |
| * @import {ElementContent, Element, Properties} from 'hast' | |
| * @import {ListItem, Parents} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `listItem` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {ListItem} node | |
| * mdast node. | |
| * @param {Parents | undefined} parent | |
| * Parent of `node`. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function listItem(state, node, parent) { | |
| const results = state.all(node); | |
| const loose = parent ? listLoose(parent) : listItemLoose(node); | |
| /** @type {Properties} */ | |
| const properties = {}; | |
| /** @type {Array<ElementContent>} */ | |
| const children = []; | |
| if (typeof node.checked === "boolean") { | |
| const head = results[0]; | |
| /** @type {Element} */ | |
| let paragraph; | |
| if (head && head.type === "element" && head.tagName === "p") paragraph = head; | |
| else { | |
| paragraph = { | |
| type: "element", | |
| tagName: "p", | |
| properties: {}, | |
| children: [] | |
| }; | |
| results.unshift(paragraph); | |
| } | |
| if (paragraph.children.length > 0) paragraph.children.unshift({ | |
| type: "text", | |
| value: " " | |
| }); | |
| paragraph.children.unshift({ | |
| type: "element", | |
| tagName: "input", | |
| properties: { | |
| type: "checkbox", | |
| checked: node.checked, | |
| disabled: true | |
| }, | |
| children: [] | |
| }); | |
| 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" | |
| }); | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "li", | |
| properties, | |
| children | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| /** | |
| * @param {Parents} node | |
| * @return {Boolean} | |
| */ | |
| function listLoose(node) { | |
| let loose = false; | |
| if (node.type === "list") { | |
| loose = node.spread || false; | |
| const children = node.children; | |
| let index = -1; | |
| while (!loose && ++index < children.length) loose = listItemLoose(children[index]); | |
| } | |
| return loose; | |
| } | |
| /** | |
| * @param {ListItem} node | |
| * @return {Boolean} | |
| */ | |
| function listItemLoose(node) { | |
| const spread = node.spread; | |
| return spread === null || spread === void 0 ? node.children.length > 1 : spread; | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/list.js | |
| /** | |
| * @import {Element, Properties} from 'hast' | |
| * @import {List} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `list` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {List} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function list(state, node) { | |
| /** @type {Properties} */ | |
| const properties = {}; | |
| const results = state.all(node); | |
| let index = -1; | |
| if (typeof node.start === "number" && node.start !== 1) properties.start = node.start; | |
| while (++index < results.length) { | |
| const child = results[index]; | |
| if (child.type === "element" && child.tagName === "li" && child.properties && Array.isArray(child.properties.className) && child.properties.className.includes("task-list-item")) { | |
| properties.className = ["contains-task-list"]; | |
| break; | |
| } | |
| } | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: node.ordered ? "ol" : "ul", | |
| properties, | |
| children: state.wrap(results, true) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/paragraph.js | |
| /** | |
| * @import {Element} from 'hast' | |
| * @import {Paragraph} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `paragraph` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Paragraph} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function paragraph(state, node) { | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "p", | |
| properties: {}, | |
| children: state.all(node) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/root.js | |
| /** | |
| * @import {Parents as HastParents, Root as HastRoot} from 'hast' | |
| * @import {Root as MdastRoot} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `root` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {MdastRoot} node | |
| * mdast node. | |
| * @returns {HastParents} | |
| * hast node. | |
| */ | |
| function root(state, node) { | |
| /** @type {HastRoot} */ | |
| const result = { | |
| type: "root", | |
| children: state.wrap(state.all(node)) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/strong.js | |
| /** | |
| * @import {Element} from 'hast' | |
| * @import {Strong} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `strong` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Strong} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function strong(state, node) { | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "strong", | |
| properties: {}, | |
| children: state.all(node) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/table.js | |
| /** | |
| * @import {Table} from 'mdast' | |
| * @import {Element} from 'hast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `table` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {Table} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function table(state, node) { | |
| const rows = state.all(node); | |
| const firstRow = rows.shift(); | |
| /** @type {Array<Element>} */ | |
| const tableContent = []; | |
| if (firstRow) { | |
| /** @type {Element} */ | |
| const head = { | |
| type: "element", | |
| tagName: "thead", | |
| properties: {}, | |
| children: state.wrap([firstRow], true) | |
| }; | |
| state.patch(node.children[0], head); | |
| tableContent.push(head); | |
| } | |
| if (rows.length > 0) { | |
| /** @type {Element} */ | |
| const body = { | |
| type: "element", | |
| tagName: "tbody", | |
| properties: {}, | |
| children: state.wrap(rows, true) | |
| }; | |
| const start = pointStart(node.children[1]); | |
| const end = pointEnd(node.children[node.children.length - 1]); | |
| if (start && end) body.position = { | |
| start, | |
| end | |
| }; | |
| tableContent.push(body); | |
| } | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "table", | |
| properties: {}, | |
| children: state.wrap(tableContent, true) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/table-row.js | |
| /** | |
| * @import {Element, ElementContent, Properties} from 'hast' | |
| * @import {Parents, TableRow} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `tableRow` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {TableRow} node | |
| * mdast node. | |
| * @param {Parents | undefined} parent | |
| * Parent of `node`. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function tableRow(state, node, parent) { | |
| const siblings = parent ? parent.children : void 0; | |
| const tagName = (siblings ? siblings.indexOf(node) : 1) === 0 ? "th" : "td"; | |
| const align = parent && parent.type === "table" ? parent.align : void 0; | |
| const length = align ? align.length : node.children.length; | |
| let cellIndex = -1; | |
| /** @type {Array<ElementContent>} */ | |
| const cells = []; | |
| while (++cellIndex < length) { | |
| const cell = node.children[cellIndex]; | |
| /** @type {Properties} */ | |
| const properties = {}; | |
| const alignValue = align ? align[cellIndex] : void 0; | |
| if (alignValue) properties.align = alignValue; | |
| /** @type {Element} */ | |
| let result = { | |
| type: "element", | |
| tagName, | |
| properties, | |
| children: [] | |
| }; | |
| if (cell) { | |
| result.children = state.all(cell); | |
| state.patch(cell, result); | |
| result = state.applyData(cell, result); | |
| } | |
| cells.push(result); | |
| } | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "tr", | |
| properties: {}, | |
| children: state.wrap(cells, true) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/table-cell.js | |
| /** | |
| * @import {Element} from 'hast' | |
| * @import {TableCell} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `tableCell` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {TableCell} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function tableCell(state, node) { | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "td", | |
| properties: {}, | |
| children: state.all(node) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/trim-lines/index.js | |
| var tab = 9; | |
| var space = 32; | |
| /** | |
| * Remove initial and final spaces and tabs at the line breaks in `value`. | |
| * Does not trim initial and final spaces and tabs of the value itself. | |
| * | |
| * @param {string} value | |
| * Value to trim. | |
| * @returns {string} | |
| * Trimmed value. | |
| */ | |
| function trimLines(value) { | |
| const source = String(value); | |
| const search = /\r?\n|\r/g; | |
| let match = search.exec(source); | |
| let last = 0; | |
| /** @type {Array<string>} */ | |
| const lines = []; | |
| while (match) { | |
| lines.push(trimLine(source.slice(last, match.index), last > 0, true), match[0]); | |
| last = match.index + match[0].length; | |
| match = search.exec(source); | |
| } | |
| lines.push(trimLine(source.slice(last), last > 0, false)); | |
| return lines.join(""); | |
| } | |
| /** | |
| * @param {string} value | |
| * Line to trim. | |
| * @param {boolean} start | |
| * Whether to trim the start of the line. | |
| * @param {boolean} end | |
| * Whether to trim the end of the line. | |
| * @returns {string} | |
| * Trimmed line. | |
| */ | |
| function trimLine(value, start, end) { | |
| let startIndex = 0; | |
| let endIndex = value.length; | |
| if (start) { | |
| let code = value.codePointAt(startIndex); | |
| while (code === tab || code === space) { | |
| startIndex++; | |
| code = value.codePointAt(startIndex); | |
| } | |
| } | |
| if (end) { | |
| let code = value.codePointAt(endIndex - 1); | |
| while (code === tab || code === space) { | |
| endIndex--; | |
| code = value.codePointAt(endIndex - 1); | |
| } | |
| } | |
| return endIndex > startIndex ? value.slice(startIndex, endIndex) : ""; | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/text.js | |
| /** | |
| * @import {Element as HastElement, Text as HastText} from 'hast' | |
| * @import {Text as MdastText} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `text` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {MdastText} node | |
| * mdast node. | |
| * @returns {HastElement | HastText} | |
| * hast node. | |
| */ | |
| function text(state, node) { | |
| /** @type {HastText} */ | |
| const result = { | |
| type: "text", | |
| value: trimLines(String(node.value)) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js | |
| /** | |
| * @import {Element} from 'hast' | |
| * @import {ThematicBreak} from 'mdast' | |
| * @import {State} from '../state.js' | |
| */ | |
| /** | |
| * Turn an mdast `thematicBreak` node into hast. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {ThematicBreak} node | |
| * mdast node. | |
| * @returns {Element} | |
| * hast node. | |
| */ | |
| function thematicBreak(state, node) { | |
| /** @type {Element} */ | |
| const result = { | |
| type: "element", | |
| tagName: "hr", | |
| properties: {}, | |
| children: [] | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/handlers/index.js | |
| /** | |
| * @import {Handlers} from '../state.js' | |
| */ | |
| /** | |
| * Default handlers for nodes. | |
| * | |
| * @satisfies {Handlers} | |
| */ | |
| var handlers = { | |
| blockquote, | |
| break: hardBreak, | |
| code, | |
| delete: strikethrough, | |
| emphasis, | |
| footnoteReference, | |
| heading, | |
| html, | |
| imageReference, | |
| image, | |
| inlineCode, | |
| linkReference, | |
| link, | |
| listItem, | |
| list, | |
| paragraph, | |
| root, | |
| strong, | |
| table, | |
| tableCell, | |
| tableRow, | |
| text, | |
| thematicBreak, | |
| toml: ignore, | |
| yaml: ignore, | |
| definition: ignore, | |
| footnoteDefinition: ignore | |
| }; | |
| function ignore() {} | |
| //#endregion | |
| //#region ../node_modules/@ungap/structured-clone/esm/deserialize.js | |
| var env = typeof self === "object" ? self : globalThis; | |
| var guard = (name, init) => { | |
| switch (name) { | |
| case "Function": | |
| case "SharedWorker": | |
| case "Worker": | |
| case "eval": | |
| case "setInterval": | |
| case "setTimeout": throw new TypeError("unable to deserialize " + name); | |
| } | |
| return new env[name](init); | |
| }; | |
| var deserializer = ($, _) => { | |
| const as = (out, index) => { | |
| $.set(index, out); | |
| return out; | |
| }; | |
| const unpair = (index) => { | |
| if ($.has(index)) return $.get(index); | |
| const [type, value] = _[index]; | |
| switch (type) { | |
| case 0: | |
| case -1: return as(value, index); | |
| case 1: { | |
| const arr = as([], index); | |
| for (const index of value) arr.push(unpair(index)); | |
| return arr; | |
| } | |
| case 2: { | |
| const object = as({}, index); | |
| for (const [key, index] of value) object[unpair(key)] = unpair(index); | |
| return object; | |
| } | |
| case 3: return as(new Date(value), index); | |
| case 4: { | |
| const { source, flags } = value; | |
| return as(new RegExp(source, flags), index); | |
| } | |
| case 5: { | |
| const map = as(/* @__PURE__ */ new Map(), index); | |
| for (const [key, index] of value) map.set(unpair(key), unpair(index)); | |
| return map; | |
| } | |
| case 6: { | |
| const set = as(/* @__PURE__ */ new Set(), index); | |
| for (const index of value) set.add(unpair(index)); | |
| return set; | |
| } | |
| case 7: { | |
| const { name, message } = value; | |
| return as(guard(name, message), index); | |
| } | |
| case 8: return as(BigInt(value), index); | |
| case "BigInt": return as(Object(BigInt(value)), index); | |
| case "ArrayBuffer": return as(new Uint8Array(value).buffer, value); | |
| case "DataView": { | |
| const { buffer } = new Uint8Array(value); | |
| return as(new DataView(buffer), value); | |
| } | |
| } | |
| return as(guard(type, value), index); | |
| }; | |
| return unpair; | |
| }; | |
| /** | |
| * @typedef {Array<string,any>} Record a type representation | |
| */ | |
| /** | |
| * Returns a deserialized value from a serialized array of Records. | |
| * @param {Record[]} serialized a previously serialized value. | |
| * @returns {any} | |
| */ | |
| var deserialize = (serialized) => deserializer(/* @__PURE__ */ new Map(), serialized)(0); | |
| //#endregion | |
| //#region ../node_modules/@ungap/structured-clone/esm/serialize.js | |
| var EMPTY = ""; | |
| var { toString } = {}; | |
| var { keys } = Object; | |
| var typeOf = (value) => { | |
| const type = typeof value; | |
| if (type !== "object" || !value) return [0, type]; | |
| const asString = toString.call(value).slice(8, -1); | |
| switch (asString) { | |
| case "Array": return [1, EMPTY]; | |
| case "Object": return [2, EMPTY]; | |
| case "Date": return [3, EMPTY]; | |
| case "RegExp": return [4, EMPTY]; | |
| case "Map": return [5, EMPTY]; | |
| case "Set": return [6, EMPTY]; | |
| case "DataView": return [1, asString]; | |
| } | |
| if (asString.includes("Array")) return [1, asString]; | |
| if (asString.includes("Error")) return [7, asString]; | |
| return [2, asString]; | |
| }; | |
| var shouldSkip = ([TYPE, type]) => TYPE === 0 && (type === "function" || type === "symbol"); | |
| var serializer = (strict, json, $, _) => { | |
| const as = (out, value) => { | |
| const index = _.push(out) - 1; | |
| $.set(value, index); | |
| return index; | |
| }; | |
| const pair = (value) => { | |
| if ($.has(value)) return $.get(value); | |
| let [TYPE, type] = typeOf(value); | |
| switch (TYPE) { | |
| case 0: { | |
| let entry = value; | |
| switch (type) { | |
| case "bigint": | |
| TYPE = 8; | |
| entry = value.toString(); | |
| break; | |
| case "function": | |
| case "symbol": | |
| if (strict) throw new TypeError("unable to serialize " + type); | |
| entry = null; | |
| break; | |
| case "undefined": return as([-1], value); | |
| } | |
| return as([TYPE, entry], value); | |
| } | |
| case 1: { | |
| if (type) { | |
| let spread = value; | |
| if (type === "DataView") spread = new Uint8Array(value.buffer); | |
| else if (type === "ArrayBuffer") spread = new Uint8Array(value); | |
| return as([type, [...spread]], value); | |
| } | |
| const arr = []; | |
| const index = as([TYPE, arr], value); | |
| for (const entry of value) arr.push(pair(entry)); | |
| return index; | |
| } | |
| case 2: { | |
| if (type) switch (type) { | |
| case "BigInt": return as([type, value.toString()], value); | |
| case "Boolean": | |
| case "Number": | |
| case "String": return as([type, value.valueOf()], value); | |
| } | |
| if (json && "toJSON" in value) return pair(value.toJSON()); | |
| const entries = []; | |
| const index = as([TYPE, entries], value); | |
| for (const key of keys(value)) if (strict || !shouldSkip(typeOf(value[key]))) entries.push([pair(key), pair(value[key])]); | |
| return index; | |
| } | |
| case 3: return as([TYPE, value.toISOString()], value); | |
| case 4: { | |
| const { source, flags } = value; | |
| return as([TYPE, { | |
| source, | |
| flags | |
| }], value); | |
| } | |
| case 5: { | |
| const entries = []; | |
| const index = as([TYPE, entries], value); | |
| for (const [key, entry] of value) if (strict || !(shouldSkip(typeOf(key)) || shouldSkip(typeOf(entry)))) entries.push([pair(key), pair(entry)]); | |
| return index; | |
| } | |
| case 6: { | |
| const entries = []; | |
| const index = as([TYPE, entries], value); | |
| for (const entry of value) if (strict || !shouldSkip(typeOf(entry))) entries.push(pair(entry)); | |
| return index; | |
| } | |
| } | |
| const { message } = value; | |
| return as([TYPE, { | |
| name: type, | |
| message | |
| }], value); | |
| }; | |
| return pair; | |
| }; | |
| /** | |
| * @typedef {Array<string,any>} Record a type representation | |
| */ | |
| /** | |
| * Returns an array of serialized Records. | |
| * @param {any} value a serializable value. | |
| * @param {{json?: boolean, lossy?: boolean}?} options an object with a `lossy` or `json` property that, | |
| * if `true`, will not throw errors on incompatible types, and behave more | |
| * like JSON stringify would behave. Symbol and Function will be discarded. | |
| * @returns {Record[]} | |
| */ | |
| var serialize = (value, { json, lossy } = {}) => { | |
| const _ = []; | |
| return serializer(!(json || lossy), !!json, /* @__PURE__ */ new Map(), _)(value), _; | |
| }; | |
| //#endregion | |
| //#region ../node_modules/@ungap/structured-clone/esm/index.js | |
| /** | |
| * @typedef {Array<string,any>} Record a type representation | |
| */ | |
| /** | |
| * Returns an array of serialized Records. | |
| * @param {any} any a serializable value. | |
| * @param {{transfer?: any[], json?: boolean, lossy?: boolean}?} options an object with | |
| * a transfer option (ignored when polyfilled) and/or non standard fields that | |
| * fallback to the polyfill if present. | |
| * @returns {Record[]} | |
| */ | |
| var esm_default = typeof structuredClone === "function" ? (any, options) => options && ("json" in options || "lossy" in options) ? deserialize(serialize(any, options)) : structuredClone(any) : (any, options) => deserialize(serialize(any, options)); | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/footer.js | |
| /** | |
| * @import {ElementContent, Element} from 'hast' | |
| * @import {State} from './state.js' | |
| */ | |
| /** | |
| * @callback FootnoteBackContentTemplate | |
| * Generate content for the backreference dynamically. | |
| * | |
| * For the following markdown: | |
| * | |
| * ```markdown | |
| * Alpha[^micromark], bravo[^micromark], and charlie[^remark]. | |
| * | |
| * [^remark]: things about remark | |
| * [^micromark]: things about micromark | |
| * ``` | |
| * | |
| * This function will be called with: | |
| * | |
| * * `0` and `0` for the backreference from `things about micromark` to | |
| * `alpha`, as it is the first used definition, and the first call to it | |
| * * `0` and `1` for the backreference from `things about micromark` to | |
| * `bravo`, as it is the first used definition, and the second call to it | |
| * * `1` and `0` for the backreference from `things about remark` to | |
| * `charlie`, as it is the second used definition | |
| * @param {number} referenceIndex | |
| * Index of the definition in the order that they are first referenced, | |
| * 0-indexed. | |
| * @param {number} rereferenceIndex | |
| * Index of calls to the same definition, 0-indexed. | |
| * @returns {Array<ElementContent> | ElementContent | string} | |
| * Content for the backreference when linking back from definitions to their | |
| * reference. | |
| * | |
| * @callback FootnoteBackLabelTemplate | |
| * Generate a back label dynamically. | |
| * | |
| * For the following markdown: | |
| * | |
| * ```markdown | |
| * Alpha[^micromark], bravo[^micromark], and charlie[^remark]. | |
| * | |
| * [^remark]: things about remark | |
| * [^micromark]: things about micromark | |
| * ``` | |
| * | |
| * This function will be called with: | |
| * | |
| * * `0` and `0` for the backreference from `things about micromark` to | |
| * `alpha`, as it is the first used definition, and the first call to it | |
| * * `0` and `1` for the backreference from `things about micromark` to | |
| * `bravo`, as it is the first used definition, and the second call to it | |
| * * `1` and `0` for the backreference from `things about remark` to | |
| * `charlie`, as it is the second used definition | |
| * @param {number} referenceIndex | |
| * Index of the definition in the order that they are first referenced, | |
| * 0-indexed. | |
| * @param {number} rereferenceIndex | |
| * Index of calls to the same definition, 0-indexed. | |
| * @returns {string} | |
| * Back label to use when linking back from definitions to their reference. | |
| */ | |
| /** | |
| * Generate the default content that GitHub uses on backreferences. | |
| * | |
| * @param {number} _ | |
| * Index of the definition in the order that they are first referenced, | |
| * 0-indexed. | |
| * @param {number} rereferenceIndex | |
| * Index of calls to the same definition, 0-indexed. | |
| * @returns {Array<ElementContent>} | |
| * Content. | |
| */ | |
| function defaultFootnoteBackContent(_, rereferenceIndex) { | |
| /** @type {Array<ElementContent>} */ | |
| const result = [{ | |
| type: "text", | |
| value: "↩" | |
| }]; | |
| if (rereferenceIndex > 1) result.push({ | |
| type: "element", | |
| tagName: "sup", | |
| properties: {}, | |
| children: [{ | |
| type: "text", | |
| value: String(rereferenceIndex) | |
| }] | |
| }); | |
| return result; | |
| } | |
| /** | |
| * Generate the default label that GitHub uses on backreferences. | |
| * | |
| * @param {number} referenceIndex | |
| * Index of the definition in the order that they are first referenced, | |
| * 0-indexed. | |
| * @param {number} rereferenceIndex | |
| * Index of calls to the same definition, 0-indexed. | |
| * @returns {string} | |
| * Label. | |
| */ | |
| function defaultFootnoteBackLabel(referenceIndex, rereferenceIndex) { | |
| return "Back to reference " + (referenceIndex + 1) + (rereferenceIndex > 1 ? "-" + rereferenceIndex : ""); | |
| } | |
| /** | |
| * Generate a hast footer for called footnote definitions. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @returns {Element | undefined} | |
| * `section` element or `undefined`. | |
| */ | |
| function footer(state) { | |
| const clobberPrefix = typeof state.options.clobberPrefix === "string" ? state.options.clobberPrefix : "user-content-"; | |
| const footnoteBackContent = state.options.footnoteBackContent || defaultFootnoteBackContent; | |
| const footnoteBackLabel = state.options.footnoteBackLabel || defaultFootnoteBackLabel; | |
| const footnoteLabel = state.options.footnoteLabel || "Footnotes"; | |
| const footnoteLabelTagName = state.options.footnoteLabelTagName || "h2"; | |
| const footnoteLabelProperties = state.options.footnoteLabelProperties || { className: ["sr-only"] }; | |
| /** @type {Array<ElementContent>} */ | |
| const listItems = []; | |
| let referenceIndex = -1; | |
| while (++referenceIndex < state.footnoteOrder.length) { | |
| const definition = state.footnoteById.get(state.footnoteOrder[referenceIndex]); | |
| if (!definition) continue; | |
| const content = state.all(definition); | |
| const id = String(definition.identifier).toUpperCase(); | |
| const safeId = normalizeUri(id.toLowerCase()); | |
| let rereferenceIndex = 0; | |
| /** @type {Array<ElementContent>} */ | |
| 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 = content[content.length - 1]; | |
| if (tail && tail.type === "element" && tail.tagName === "p") { | |
| const tailTail = tail.children[tail.children.length - 1]; | |
| if (tailTail && tailTail.type === "text") tailTail.value += " "; | |
| else tail.children.push({ | |
| type: "text", | |
| value: " " | |
| }); | |
| tail.children.push(...backReferences); | |
| } else content.push(...backReferences); | |
| /** @type {Element} */ | |
| const listItem = { | |
| type: "element", | |
| tagName: "li", | |
| properties: { id: clobberPrefix + "fn-" + safeId }, | |
| children: state.wrap(content, true) | |
| }; | |
| state.patch(definition, listItem); | |
| listItems.push(listItem); | |
| } | |
| if (listItems.length === 0) return; | |
| return { | |
| type: "element", | |
| tagName: "section", | |
| properties: { | |
| dataFootnotes: true, | |
| className: ["footnotes"] | |
| }, | |
| children: [ | |
| { | |
| type: "element", | |
| tagName: footnoteLabelTagName, | |
| properties: { | |
| ...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" | |
| } | |
| ] | |
| }; | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/state.js | |
| /** | |
| * @import { | |
| * ElementContent as HastElementContent, | |
| * Element as HastElement, | |
| * Nodes as HastNodes, | |
| * Properties as HastProperties, | |
| * RootContent as HastRootContent, | |
| * Text as HastText | |
| * } from 'hast' | |
| * @import { | |
| * Definition as MdastDefinition, | |
| * FootnoteDefinition as MdastFootnoteDefinition, | |
| * Nodes as MdastNodes, | |
| * Parents as MdastParents | |
| * } from 'mdast' | |
| * @import {VFile} from 'vfile' | |
| * @import { | |
| * FootnoteBackContentTemplate, | |
| * FootnoteBackLabelTemplate | |
| * } from './footer.js' | |
| */ | |
| /** | |
| * @callback Handler | |
| * Handle a node. | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {any} node | |
| * mdast node to handle. | |
| * @param {MdastParents | undefined} parent | |
| * Parent of `node`. | |
| * @returns {Array<HastElementContent> | HastElementContent | undefined} | |
| * hast node. | |
| * | |
| * @typedef {Partial<Record<MdastNodes['type'], Handler>>} Handlers | |
| * Handle nodes. | |
| * | |
| * @typedef Options | |
| * Configuration (optional). | |
| * @property {boolean | null | undefined} [allowDangerousHtml=false] | |
| * Whether to persist raw HTML in markdown in the hast tree (default: | |
| * `false`). | |
| * @property {string | null | undefined} [clobberPrefix='user-content-'] | |
| * Prefix to use before the `id` property on footnotes to prevent them from | |
| * *clobbering* (default: `'user-content-'`). | |
| * | |
| * Pass `''` for trusted markdown and when you are careful with | |
| * polyfilling. | |
| * You could pass a different prefix. | |
| * | |
| * DOM clobbering is this: | |
| * | |
| * ```html | |
| * <p id="x"></p> | |
| * <script>alert(x) // `x` now refers to the `p#x` DOM element<\/script> | |
| * ``` | |
| * | |
| * The above example shows that elements are made available by browsers, by | |
| * their ID, on the `window` object. | |
| * This is a security risk because you might be expecting some other variable | |
| * at that place. | |
| * It can also break polyfills. | |
| * Using a prefix solves these problems. | |
| * @property {VFile | null | undefined} [file] | |
| * Corresponding virtual file representing the input document (optional). | |
| * @property {FootnoteBackContentTemplate | string | null | undefined} [footnoteBackContent] | |
| * Content of the backreference back to references (default: `defaultFootnoteBackContent`). | |
| * | |
| * The default value is: | |
| * | |
| * ```js | |
| * function defaultFootnoteBackContent(_, rereferenceIndex) { | |
| * const result = [{type: 'text', value: '↩'}] | |
| * | |
| * if (rereferenceIndex > 1) { | |
| * result.push({ | |
| * type: 'element', | |
| * tagName: 'sup', | |
| * properties: {}, | |
| * children: [{type: 'text', value: String(rereferenceIndex)}] | |
| * }) | |
| * } | |
| * | |
| * return result | |
| * } | |
| * ``` | |
| * | |
| * This content is used in the `a` element of each backreference (the `↩` | |
| * links). | |
| * @property {FootnoteBackLabelTemplate | string | null | undefined} [footnoteBackLabel] | |
| * Label to describe the backreference back to references (default: | |
| * `defaultFootnoteBackLabel`). | |
| * | |
| * The default value is: | |
| * | |
| * ```js | |
| * function defaultFootnoteBackLabel(referenceIndex, rereferenceIndex) { | |
| * return ( | |
| * 'Back to reference ' + | |
| * (referenceIndex + 1) + | |
| * (rereferenceIndex > 1 ? '-' + rereferenceIndex : '') | |
| * ) | |
| * } | |
| * ``` | |
| * | |
| * Change it when the markdown is not in English. | |
| * | |
| * This label is used in the `ariaLabel` property on each backreference | |
| * (the `↩` links). | |
| * It affects users of assistive technology. | |
| * @property {string | null | undefined} [footnoteLabel='Footnotes'] | |
| * Textual label to use for the footnotes section (default: `'Footnotes'`). | |
| * | |
| * Change it when the markdown is not in English. | |
| * | |
| * This label is typically hidden visually (assuming a `sr-only` CSS class | |
| * is defined that does that) and so affects screen readers only. | |
| * If you do have such a class, but want to show this section to everyone, | |
| * pass different properties with the `footnoteLabelProperties` option. | |
| * @property {HastProperties | null | undefined} [footnoteLabelProperties={className: ['sr-only']}] | |
| * Properties to use on the footnote label (default: `{className: | |
| * ['sr-only']}`). | |
| * | |
| * Change it to show the label and add other properties. | |
| * | |
| * This label is typically hidden visually (assuming an `sr-only` CSS class | |
| * is defined that does that) and so affects screen readers only. | |
| * If you do have such a class, but want to show this section to everyone, | |
| * pass an empty string. | |
| * You can also add different properties. | |
| * | |
| * > **Note**: `id: 'footnote-label'` is always added, because footnote | |
| * > calls use it with `aria-describedby` to provide an accessible label. | |
| * @property {string | null | undefined} [footnoteLabelTagName='h2'] | |
| * HTML tag name to use for the footnote label element (default: `'h2'`). | |
| * | |
| * Change it to match your document structure. | |
| * | |
| * This label is typically hidden visually (assuming a `sr-only` CSS class | |
| * is defined that does that) and so affects screen readers only. | |
| * If you do have such a class, but want to show this section to everyone, | |
| * pass different properties with the `footnoteLabelProperties` option. | |
| * @property {Handlers | null | undefined} [handlers] | |
| * Extra handlers for nodes (optional). | |
| * @property {Array<MdastNodes['type']> | null | undefined} [passThrough] | |
| * List of custom mdast node types to pass through (keep) in hast (note that | |
| * the node itself is passed, but eventual children are transformed) | |
| * (optional). | |
| * @property {Handler | null | undefined} [unknownHandler] | |
| * Handler for all unknown nodes (optional). | |
| * | |
| * @typedef State | |
| * Info passed around. | |
| * @property {(node: MdastNodes) => Array<HastElementContent>} all | |
| * Transform the children of an mdast parent to hast. | |
| * @property {<Type extends HastNodes>(from: MdastNodes, to: Type) => HastElement | Type} applyData | |
| * Honor the `data` of `from`, and generate an element instead of `node`. | |
| * @property {Map<string, MdastDefinition>} definitionById | |
| * Definitions by their identifier. | |
| * @property {Map<string, MdastFootnoteDefinition>} footnoteById | |
| * Footnote definitions by their identifier. | |
| * @property {Map<string, number>} footnoteCounts | |
| * Counts for how often the same footnote was called. | |
| * @property {Array<string>} footnoteOrder | |
| * Identifiers of order when footnote calls first appear in tree order. | |
| * @property {Handlers} handlers | |
| * Applied handlers. | |
| * @property {(node: MdastNodes, parent: MdastParents | undefined) => Array<HastElementContent> | HastElementContent | undefined} one | |
| * Transform an mdast node to hast. | |
| * @property {Options} options | |
| * Configuration. | |
| * @property {(from: MdastNodes, node: HastNodes) => undefined} patch | |
| * Copy a node’s positional info. | |
| * @property {<Type extends HastRootContent>(nodes: Array<Type>, loose?: boolean | undefined) => Array<HastText | Type>} wrap | |
| * Wrap `nodes` with line endings between each node, adds initial/final line endings when `loose`. | |
| */ | |
| var own$1 = {}.hasOwnProperty; | |
| /** @type {Options} */ | |
| var emptyOptions = {}; | |
| /** | |
| * Create `state` from an mdast tree. | |
| * | |
| * @param {MdastNodes} tree | |
| * mdast node to transform. | |
| * @param {Options | null | undefined} [options] | |
| * Configuration (optional). | |
| * @returns {State} | |
| * `state` function. | |
| */ | |
| function createState(tree, options) { | |
| const settings = options || emptyOptions; | |
| /** @type {Map<string, MdastDefinition>} */ | |
| const definitionById = /* @__PURE__ */ new Map(); | |
| /** @type {Map<string, MdastFootnoteDefinition>} */ | |
| const footnoteById = /* @__PURE__ */ new Map(); | |
| /** @type {State} */ | |
| const state = { | |
| all, | |
| applyData, | |
| definitionById, | |
| footnoteById, | |
| footnoteCounts: /* @__PURE__ */ new Map(), | |
| footnoteOrder: [], | |
| handlers: { | |
| ...handlers, | |
| ...settings.handlers | |
| }, | |
| one, | |
| options: settings, | |
| patch, | |
| wrap: wrap$1 | |
| }; | |
| 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; | |
| /** | |
| * Transform an mdast node into a hast node. | |
| * | |
| * @param {MdastNodes} node | |
| * mdast node. | |
| * @param {MdastParents | undefined} [parent] | |
| * Parent of `node`. | |
| * @returns {Array<HastElementContent> | HastElementContent | undefined} | |
| * Resulting hast node. | |
| */ | |
| function one(node, parent) { | |
| const type = node.type; | |
| const handle = state.handlers[type]; | |
| if (own$1.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); | |
| } | |
| return (state.options.unknownHandler || defaultUnknownHandler)(state, node, parent); | |
| } | |
| /** | |
| * Transform the children of an mdast node into hast nodes. | |
| * | |
| * @param {MdastNodes} parent | |
| * mdast node to compile | |
| * @returns {Array<HastElementContent>} | |
| * Resulting hast nodes. | |
| */ | |
| function all(parent) { | |
| /** @type {Array<HastElementContent>} */ | |
| 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; | |
| } | |
| } | |
| /** | |
| * Copy a node’s positional info. | |
| * | |
| * @param {MdastNodes} from | |
| * mdast node to copy from. | |
| * @param {HastNodes} to | |
| * hast node to copy into. | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| function patch(from, to) { | |
| if (from.position) to.position = position$1(from); | |
| } | |
| /** | |
| * Honor the `data` of `from` and maybe generate an element instead of `to`. | |
| * | |
| * @template {HastNodes} Type | |
| * Node type. | |
| * @param {MdastNodes} from | |
| * mdast node to use data from. | |
| * @param {Type} to | |
| * hast node to change. | |
| * @returns {HastElement | Type} | |
| * Nothing. | |
| */ | |
| function applyData(from, to) { | |
| /** @type {HastElement | Type} */ | |
| let result = to; | |
| 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 result = { | |
| type: "element", | |
| tagName: hName, | |
| properties: {}, | |
| children: "children" in result ? result.children : [result] | |
| }; | |
| 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; | |
| } | |
| /** | |
| * Transform an unknown node. | |
| * | |
| * @param {State} state | |
| * Info passed around. | |
| * @param {MdastNodes} node | |
| * Unknown mdast node. | |
| * @returns {HastElement | HastText} | |
| * Resulting hast node. | |
| */ | |
| function defaultUnknownHandler(state, node) { | |
| const data = node.data || {}; | |
| /** @type {HastElement | HastText} */ | |
| const result = "value" in node && !(own$1.call(data, "hProperties") || own$1.call(data, "hChildren")) ? { | |
| type: "text", | |
| value: node.value | |
| } : { | |
| type: "element", | |
| tagName: "div", | |
| properties: {}, | |
| children: state.all(node) | |
| }; | |
| state.patch(node, result); | |
| return state.applyData(node, result); | |
| } | |
| /** | |
| * Wrap `nodes` with line endings between each node. | |
| * | |
| * @template {HastRootContent} Type | |
| * Node type. | |
| * @param {Array<Type>} nodes | |
| * List of nodes to wrap. | |
| * @param {boolean | undefined} [loose=false] | |
| * Whether to add line endings at start and end (default: `false`). | |
| * @returns {Array<HastText | Type>} | |
| * Wrapped nodes. | |
| */ | |
| function wrap$1(nodes, loose) { | |
| /** @type {Array<HastText | Type>} */ | |
| const result = []; | |
| let index = -1; | |
| if (loose) result.push({ | |
| type: "text", | |
| value: "\n" | |
| }); | |
| while (++index < nodes.length) { | |
| if (index) result.push({ | |
| type: "text", | |
| value: "\n" | |
| }); | |
| result.push(nodes[index]); | |
| } | |
| if (loose && nodes.length > 0) result.push({ | |
| type: "text", | |
| value: "\n" | |
| }); | |
| return result; | |
| } | |
| /** | |
| * Trim spaces and tabs at the start of `value`. | |
| * | |
| * @param {string} value | |
| * Value to trim. | |
| * @returns {string} | |
| * Result. | |
| */ | |
| function trimMarkdownSpaceStart(value) { | |
| let index = 0; | |
| let code = value.charCodeAt(index); | |
| while (code === 9 || code === 32) { | |
| index++; | |
| code = value.charCodeAt(index); | |
| } | |
| return value.slice(index); | |
| } | |
| //#endregion | |
| //#region ../node_modules/mdast-util-to-hast/lib/index.js | |
| /** | |
| * @import {Nodes as HastNodes} from 'hast' | |
| * @import {Nodes as MdastNodes} from 'mdast' | |
| * @import {Options} from './state.js' | |
| */ | |
| /** | |
| * Transform mdast to hast. | |
| * | |
| * ##### Notes | |
| * | |
| * ###### HTML | |
| * | |
| * Raw HTML is available in mdast as `html` nodes and can be embedded in hast | |
| * as semistandard `raw` nodes. | |
| * Most utilities ignore `raw` nodes but two notable ones don’t: | |
| * | |
| * * `hast-util-to-html` also has an option `allowDangerousHtml` which will | |
| * output the raw HTML. | |
| * This is typically discouraged as noted by the option name but is useful | |
| * if you completely trust authors | |
| * * `hast-util-raw` can handle the raw embedded HTML strings by parsing them | |
| * into standard hast nodes (`element`, `text`, etc). | |
| * This is a heavy task as it needs a full HTML parser, but it is the only | |
| * way to support untrusted content | |
| * | |
| * ###### Footnotes | |
| * | |
| * Many options supported here relate to footnotes. | |
| * Footnotes are not specified by CommonMark, which we follow by default. | |
| * They are supported by GitHub, so footnotes can be enabled in markdown with | |
| * `mdast-util-gfm`. | |
| * | |
| * The options `footnoteBackLabel` and `footnoteLabel` define natural language | |
| * that explains footnotes, which is hidden for sighted users but shown to | |
| * assistive technology. | |
| * When your page is not in English, you must define translated values. | |
| * | |
| * Back references use ARIA attributes, but the section label itself uses a | |
| * heading that is hidden with an `sr-only` class. | |
| * To show it to sighted users, define different attributes in | |
| * `footnoteLabelProperties`. | |
| * | |
| * ###### Clobbering | |
| * | |
| * Footnotes introduces a problem, as it links footnote calls to footnote | |
| * definitions on the page through `id` attributes generated from user content, | |
| * which results in DOM clobbering. | |
| * | |
| * DOM clobbering is this: | |
| * | |
| * ```html | |
| * <p id=x></p> | |
| * <script>alert(x) // `x` now refers to the DOM `p#x` element<\/script> | |
| * ``` | |
| * | |
| * Elements by their ID are made available by browsers on the `window` object, | |
| * which is a security risk. | |
| * Using a prefix solves this problem. | |
| * | |
| * More information on how to handle clobbering and the prefix is explained in | |
| * Example: headings (DOM clobbering) in `rehype-sanitize`. | |
| * | |
| * ###### Unknown nodes | |
| * | |
| * Unknown nodes are nodes with a type that isn’t in `handlers` or `passThrough`. | |
| * The default behavior for unknown nodes is: | |
| * | |
| * * when the node has a `value` (and doesn’t have `data.hName`, | |
| * `data.hProperties`, or `data.hChildren`, see later), create a hast `text` | |
| * node | |
| * * otherwise, create a `<div>` element (which could be changed with | |
| * `data.hName`), with its children mapped from mdast to hast as well | |
| * | |
| * This behavior can be changed by passing an `unknownHandler`. | |
| * | |
| * @param {MdastNodes} tree | |
| * mdast tree. | |
| * @param {Options | null | undefined} [options] | |
| * Configuration (optional). | |
| * @returns {HastNodes} | |
| * hast tree. | |
| */ | |
| function toHast(tree, options) { | |
| const state = createState(tree, options); | |
| const node = state.one(tree, void 0); | |
| const foot = footer(state); | |
| /** @type {HastNodes} */ | |
| 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; | |
| } | |
| //#endregion | |
| //#region ../node_modules/remark-rehype/lib/index.js | |
| /** | |
| * @import {Root as HastRoot} from 'hast' | |
| * @import {Root as MdastRoot} from 'mdast' | |
| * @import {Options as ToHastOptions} from 'mdast-util-to-hast' | |
| * @import {Processor} from 'unified' | |
| * @import {VFile} from 'vfile' | |
| */ | |
| /** | |
| * @typedef {Omit<ToHastOptions, 'file'>} Options | |
| * | |
| * @callback TransformBridge | |
| * Bridge-mode. | |
| * | |
| * Runs the destination with the new hast tree. | |
| * Discards result. | |
| * @param {MdastRoot} tree | |
| * Tree. | |
| * @param {VFile} file | |
| * File. | |
| * @returns {Promise<undefined>} | |
| * Nothing. | |
| * | |
| * @callback TransformMutate | |
| * Mutate-mode. | |
| * | |
| * Further transformers run on the hast tree. | |
| * @param {MdastRoot} tree | |
| * Tree. | |
| * @param {VFile} file | |
| * File. | |
| * @returns {HastRoot} | |
| * Tree (hast). | |
| */ | |
| /** | |
| * Turn markdown into HTML. | |
| * | |
| * ##### Notes | |
| * | |
| * ###### Signature | |
| * | |
| * * if a processor is given, | |
| * runs the (rehype) plugins used on it with a hast tree, | |
| * then discards the result (*bridge mode*) | |
| * * otherwise, | |
| * returns a hast tree, | |
| * the plugins used after `remarkRehype` are rehype plugins (*mutate mode*) | |
| * | |
| * > 👉 **Note**: | |
| * > It’s highly unlikely that you want to pass a `processor`. | |
| * | |
| * ###### HTML | |
| * | |
| * Raw HTML is available in mdast as `html` nodes and can be embedded in hast | |
| * as semistandard `raw` nodes. | |
| * Most plugins ignore `raw` nodes but two notable ones don’t: | |
| * | |
| * * `rehype-stringify` also has an option `allowDangerousHtml` which will | |
| * output the raw HTML. | |
| * This is typically discouraged as noted by the option name but is useful if | |
| * you completely trust authors | |
| * * `rehype-raw` can handle the raw embedded HTML strings by parsing them | |
| * into standard hast nodes (`element`, `text`, etc); | |
| * this is a heavy task as it needs a full HTML parser, | |
| * but it is the only way to support untrusted content | |
| * | |
| * ###### Footnotes | |
| * | |
| * Many options supported here relate to footnotes. | |
| * Footnotes are not specified by CommonMark, | |
| * which we follow by default. | |
| * They are supported by GitHub, | |
| * so footnotes can be enabled in markdown with `remark-gfm`. | |
| * | |
| * The options `footnoteBackLabel` and `footnoteLabel` define natural language | |
| * that explains footnotes, | |
| * which is hidden for sighted users but shown to assistive technology. | |
| * When your page is not in English, | |
| * you must define translated values. | |
| * | |
| * Back references use ARIA attributes, | |
| * but the section label itself uses a heading that is hidden with an | |
| * `sr-only` class. | |
| * To show it to sighted users, | |
| * define different attributes in `footnoteLabelProperties`. | |
| * | |
| * ###### Clobbering | |
| * | |
| * Footnotes introduces a problem, | |
| * as it links footnote calls to footnote definitions on the page through `id` | |
| * attributes generated from user content, | |
| * which results in DOM clobbering. | |
| * | |
| * DOM clobbering is this: | |
| * | |
| * ```html | |
| * <p id=x></p> | |
| * <script>alert(x) // `x` now refers to the DOM `p#x` element<\/script> | |
| * ``` | |
| * | |
| * Elements by their ID are made available by browsers on the `window` object, | |
| * which is a security risk. | |
| * Using a prefix solves this problem. | |
| * | |
| * More information on how to handle clobbering and the prefix is explained in | |
| * *Example: headings (DOM clobbering)* in `rehype-sanitize`. | |
| * | |
| * ###### Unknown nodes | |
| * | |
| * Unknown nodes are nodes with a type that isn’t in `handlers` or `passThrough`. | |
| * The default behavior for unknown nodes is: | |
| * | |
| * * when the node has a `value` | |
| * (and doesn’t have `data.hName`, `data.hProperties`, or `data.hChildren`, | |
| * see later), | |
| * create a hast `text` node | |
| * * otherwise, | |
| * create a `<div>` element (which could be changed with `data.hName`), | |
| * with its children mapped from mdast to hast as well | |
| * | |
| * This behavior can be changed by passing an `unknownHandler`. | |
| * | |
| * @overload | |
| * @param {Processor} processor | |
| * @param {Readonly<Options> | null | undefined} [options] | |
| * @returns {TransformBridge} | |
| * | |
| * @overload | |
| * @param {Readonly<Options> | null | undefined} [options] | |
| * @returns {TransformMutate} | |
| * | |
| * @overload | |
| * @param {Readonly<Options> | Processor | null | undefined} [destination] | |
| * @param {Readonly<Options> | null | undefined} [options] | |
| * @returns {TransformBridge | TransformMutate} | |
| * | |
| * @param {Readonly<Options> | Processor | null | undefined} [destination] | |
| * Processor or configuration (optional). | |
| * @param {Readonly<Options> | null | undefined} [options] | |
| * When a processor was given, | |
| * configuration (optional). | |
| * @returns {TransformBridge | TransformMutate} | |
| * Transform. | |
| */ | |
| function remarkRehype(destination, options) { | |
| if (destination && "run" in destination) | |
| /** | |
| * @type {TransformBridge} | |
| */ | |
| return async function(tree, file) { | |
| const hastTree = toHast(tree, { | |
| file, | |
| ...options | |
| }); | |
| await destination.run(hastTree, file); | |
| }; | |
| /** | |
| * @type {TransformMutate} | |
| */ | |
| return function(tree, file) { | |
| return toHast(tree, { | |
| file, | |
| ...destination || options | |
| }); | |
| }; | |
| } | |
| //#endregion | |
| //#region ../node_modules/bail/index.js | |
| /** | |
| * Throw a given error. | |
| * | |
| * @param {Error|null|undefined} [error] | |
| * Maybe error. | |
| * @returns {asserts error is null|undefined} | |
| */ | |
| function bail(error) { | |
| if (error) throw error; | |
| } | |
| //#endregion | |
| //#region ../node_modules/extend/index.js | |
| var require_extend = /* @__PURE__ */ __commonJSMin(((exports, module) => { | |
| var hasOwn = Object.prototype.hasOwnProperty; | |
| var toStr = Object.prototype.toString; | |
| var defineProperty = Object.defineProperty; | |
| var gOPD = Object.getOwnPropertyDescriptor; | |
| var isArray = function isArray(arr) { | |
| if (typeof Array.isArray === "function") return Array.isArray(arr); | |
| return toStr.call(arr) === "[object Array]"; | |
| }; | |
| var isPlainObject = function isPlainObject(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 setProperty(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 getProperty(obj, name) { | |
| if (name === "__proto__") { | |
| if (!hasOwn.call(obj, name)) return; | |
| else if (gOPD) return gOPD(obj, name).value; | |
| } | |
| return obj[name]; | |
| }; | |
| module.exports = function extend() { | |
| 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 && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { | |
| if (copyIsArray) { | |
| copyIsArray = false; | |
| clone = src && isArray(src) ? src : []; | |
| } else clone = src && isPlainObject(src) ? src : {}; | |
| setProperty(target, { | |
| name, | |
| newValue: extend(deep, clone, copy) | |
| }); | |
| } else if (typeof copy !== "undefined") setProperty(target, { | |
| name, | |
| newValue: copy | |
| }); | |
| } | |
| } | |
| } | |
| return target; | |
| }; | |
| })); | |
| //#endregion | |
| //#region ../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); | |
| } | |
| //#endregion | |
| //#region ../node_modules/trough/lib/index.js | |
| /** | |
| * @typedef {(error?: Error | null | undefined, ...output: Array<any>) => void} Callback | |
| * Callback. | |
| * | |
| * @typedef {(...input: Array<any>) => any} Middleware | |
| * Ware. | |
| * | |
| * @typedef Pipeline | |
| * Pipeline. | |
| * @property {Run} run | |
| * Run the pipeline. | |
| * @property {Use} use | |
| * Add middleware. | |
| * | |
| * @typedef {(...input: Array<any>) => void} Run | |
| * Call all middleware. | |
| * | |
| * Calls `done` on completion with either an error or the output of the | |
| * last middleware. | |
| * | |
| * > 👉 **Note**: as the length of input defines whether async functions get a | |
| * > `next` function, | |
| * > it’s recommended to keep `input` at one value normally. | |
| * | |
| * @typedef {(fn: Middleware) => Pipeline} Use | |
| * Add middleware. | |
| */ | |
| /** | |
| * Create new middleware. | |
| * | |
| * @returns {Pipeline} | |
| * Pipeline. | |
| */ | |
| function trough() { | |
| /** @type {Array<Middleware>} */ | |
| const fns = []; | |
| /** @type {Pipeline} */ | |
| const pipeline = { | |
| run, | |
| use | |
| }; | |
| return pipeline; | |
| /** @type {Run} */ | |
| function run(...values) { | |
| let middlewareIndex = -1; | |
| /** @type {Callback} */ | |
| const callback = values.pop(); | |
| if (typeof callback !== "function") throw new TypeError("Expected function as last argument, not " + callback); | |
| next(null, ...values); | |
| /** | |
| * Run the next `fn`, or we’re done. | |
| * | |
| * @param {Error | null | undefined} error | |
| * @param {Array<any>} output | |
| */ | |
| 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) wrap(fn, next)(...output); | |
| else callback(null, ...output); | |
| } | |
| } | |
| /** @type {Use} */ | |
| function use(middelware) { | |
| if (typeof middelware !== "function") throw new TypeError("Expected `middelware` to be a function, not " + middelware); | |
| fns.push(middelware); | |
| return pipeline; | |
| } | |
| } | |
| /** | |
| * Wrap `middleware` into a uniform interface. | |
| * | |
| * You can pass all input to the resulting function. | |
| * `callback` is then called with the output of `middleware`. | |
| * | |
| * If `middleware` accepts more arguments than the later given in input, | |
| * an extra `done` function is passed to it after that input, | |
| * which must be called by `middleware`. | |
| * | |
| * The first value in `input` is the main input value. | |
| * All other input values are the rest input values. | |
| * The values given to `callback` are the input values, | |
| * merged with every non-nullish output value. | |
| * | |
| * * if `middleware` throws an error, | |
| * returns a promise that is rejected, | |
| * or calls the given `done` function with an error, | |
| * `callback` is called with that error | |
| * * if `middleware` returns a value or returns a promise that is resolved, | |
| * that value is the main output value | |
| * * if `middleware` calls `done`, | |
| * all non-nullish values except for the first one (the error) overwrite the | |
| * output values | |
| * | |
| * @param {Middleware} middleware | |
| * Function to wrap. | |
| * @param {Callback} callback | |
| * Callback called with the output of `middleware`. | |
| * @returns {Run} | |
| * Wrapped middleware. | |
| */ | |
| function wrap(middleware, callback) { | |
| /** @type {boolean} */ | |
| let called; | |
| return wrapped; | |
| /** | |
| * Call `middleware`. | |
| * @this {any} | |
| * @param {Array<any>} parameters | |
| * @returns {void} | |
| */ | |
| function wrapped(...parameters) { | |
| const fnExpectsCallback = middleware.length > parameters.length; | |
| /** @type {any} */ | |
| let result; | |
| if (fnExpectsCallback) parameters.push(done); | |
| try { | |
| result = middleware.apply(this, parameters); | |
| } catch (error) { | |
| const exception = 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); | |
| } | |
| /** | |
| * Call `callback`, only once. | |
| * | |
| * @type {Callback} | |
| */ | |
| function done(error, ...output) { | |
| if (!called) { | |
| called = true; | |
| callback(error, ...output); | |
| } | |
| } | |
| /** | |
| * Call `done` with one value. | |
| * | |
| * @param {any} [value] | |
| */ | |
| function then(value) { | |
| done(null, value); | |
| } | |
| } | |
| //#endregion | |
| //#region ../node_modules/vfile/lib/minpath.browser.js | |
| var minpath = { | |
| basename, | |
| dirname, | |
| extname, | |
| join, | |
| sep: "/" | |
| }; | |
| /** | |
| * Get the basename from a path. | |
| * | |
| * @param {string} path | |
| * File path. | |
| * @param {string | null | undefined} [extname] | |
| * Extension to strip. | |
| * @returns {string} | |
| * Stem or basename. | |
| */ | |
| function basename(path, extname) { | |
| if (extname !== void 0 && typeof extname !== "string") throw new TypeError("\"ext\" argument must be a string"); | |
| assertPath$1(path); | |
| let start = 0; | |
| let end = -1; | |
| let index = path.length; | |
| /** @type {boolean | undefined} */ | |
| let seenNonSlash; | |
| if (extname === void 0 || extname.length === 0 || extname.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 (extname === path) return ""; | |
| let firstNonSlashEnd = -1; | |
| let extnameIndex = extname.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) === extname.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); | |
| } | |
| /** | |
| * Get the dirname from a path. | |
| * | |
| * @param {string} path | |
| * File path. | |
| * @returns {string} | |
| * File path. | |
| */ | |
| function dirname(path) { | |
| assertPath$1(path); | |
| if (path.length === 0) return "."; | |
| let end = -1; | |
| let index = path.length; | |
| /** @type {boolean | undefined} */ | |
| 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); | |
| } | |
| /** | |
| * Get an extname from a path. | |
| * | |
| * @param {string} path | |
| * File path. | |
| * @returns {string} | |
| * Extname. | |
| */ | |
| function extname(path) { | |
| assertPath$1(path); | |
| let index = path.length; | |
| let end = -1; | |
| let startPart = 0; | |
| let startDot = -1; | |
| let preDotState = 0; | |
| /** @type {boolean | undefined} */ | |
| let unmatchedSlash; | |
| while (index--) { | |
| const code = path.codePointAt(index); | |
| if (code === 47) { | |
| if (unmatchedSlash) { | |
| startPart = index + 1; | |
| break; | |
| } | |
| continue; | |
| } | |
| if (end < 0) { | |
| unmatchedSlash = true; | |
| end = index + 1; | |
| } | |
| if (code === 46) { | |
| if (startDot < 0) startDot = index; | |
| else if (preDotState !== 1) preDotState = 1; | |
| } else if (startDot > -1) preDotState = -1; | |
| } | |
| if (startDot < 0 || end < 0 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) return ""; | |
| return path.slice(startDot, end); | |
| } | |
| /** | |
| * Join segments from a path. | |
| * | |
| * @param {Array<string>} segments | |
| * Path segments. | |
| * @returns {string} | |
| * File path. | |
| */ | |
| function join(...segments) { | |
| let index = -1; | |
| /** @type {string | undefined} */ | |
| let joined; | |
| while (++index < segments.length) { | |
| assertPath$1(segments[index]); | |
| if (segments[index]) joined = joined === void 0 ? segments[index] : joined + "/" + segments[index]; | |
| } | |
| return joined === void 0 ? "." : normalize(joined); | |
| } | |
| /** | |
| * Normalize a basic file path. | |
| * | |
| * @param {string} path | |
| * File path. | |
| * @returns {string} | |
| * File path. | |
| */ | |
| function normalize(path) { | |
| assertPath$1(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; | |
| } | |
| /** | |
| * Resolve `.` and `..` elements in a path with directory names. | |
| * | |
| * @param {string} path | |
| * File path. | |
| * @param {boolean} allowAboveRoot | |
| * Whether `..` can move above root. | |
| * @returns {string} | |
| * File path. | |
| */ | |
| function normalizeString(path, allowAboveRoot) { | |
| let result = ""; | |
| let lastSegmentLength = 0; | |
| let lastSlash = -1; | |
| let dots = 0; | |
| let index = -1; | |
| /** @type {number | undefined} */ | |
| let code; | |
| /** @type {number} */ | |
| let lastSlashIndex; | |
| while (++index <= path.length) { | |
| if (index < path.length) code = path.codePointAt(index); | |
| else if (code === 47) break; | |
| else code = 47; | |
| if (code === 47) { | |
| if (lastSlash === index - 1 || dots === 1) {} else if (lastSlash !== index - 1 && dots === 2) { | |
| if (result.length < 2 || lastSegmentLength !== 2 || result.codePointAt(result.length - 1) !== 46 || result.codePointAt(result.length - 2) !== 46) { | |
| if (result.length > 2) { | |
| lastSlashIndex = result.lastIndexOf("/"); | |
| if (lastSlashIndex !== result.length - 1) { | |
| if (lastSlashIndex < 0) { | |
| result = ""; | |
| lastSegmentLength = 0; | |
| } else { | |
| result = result.slice(0, lastSlashIndex); | |
| lastSegmentLength = result.length - 1 - result.lastIndexOf("/"); | |
| } | |
| lastSlash = index; | |
| dots = 0; | |
| continue; | |
| } | |
| } else if (result.length > 0) { | |
| result = ""; | |
| lastSegmentLength = 0; | |
| lastSlash = index; | |
| dots = 0; | |
| continue; | |
| } | |
| } | |
| if (allowAboveRoot) { | |
| result = result.length > 0 ? result + "/.." : ".."; | |
| lastSegmentLength = 2; | |
| } | |
| } else { | |
| if (result.length > 0) result += "/" + path.slice(lastSlash + 1, index); | |
| else result = path.slice(lastSlash + 1, index); | |
| lastSegmentLength = index - lastSlash - 1; | |
| } | |
| lastSlash = index; | |
| dots = 0; | |
| } else if (code === 46 && dots > -1) dots++; | |
| else dots = -1; | |
| } | |
| return result; | |
| } | |
| /** | |
| * Make sure `path` is a string. | |
| * | |
| * @param {string} path | |
| * File path. | |
| * @returns {asserts path is string} | |
| * Nothing. | |
| */ | |
| function assertPath$1(path) { | |
| if (typeof path !== "string") throw new TypeError("Path must be a string. Received " + JSON.stringify(path)); | |
| } | |
| //#endregion | |
| //#region ../node_modules/vfile/lib/minproc.browser.js | |
| var minproc = { cwd }; | |
| function cwd() { | |
| return "/"; | |
| } | |
| //#endregion | |
| //#region ../node_modules/vfile/lib/minurl.shared.js | |
| /** | |
| * Checks if a value has the shape of a WHATWG URL object. | |
| * | |
| * Using a symbol or instanceof would not be able to recognize URL objects | |
| * coming from other implementations (e.g. in Electron), so instead we are | |
| * checking some well known properties for a lack of a better test. | |
| * | |
| * We use `href` and `protocol` as they are the only properties that are | |
| * easy to retrieve and calculate due to the lazy nature of the getters. | |
| * | |
| * We check for auth attribute to distinguish legacy url instance with | |
| * WHATWG URL instance. | |
| * | |
| * @param {unknown} fileUrlOrPath | |
| * File path or URL. | |
| * @returns {fileUrlOrPath is URL} | |
| * Whether it’s a URL. | |
| */ | |
| function isUrl(fileUrlOrPath) { | |
| return Boolean(fileUrlOrPath !== null && typeof fileUrlOrPath === "object" && "href" in fileUrlOrPath && fileUrlOrPath.href && "protocol" in fileUrlOrPath && fileUrlOrPath.protocol && fileUrlOrPath.auth === void 0); | |
| } | |
| //#endregion | |
| //#region ../node_modules/vfile/lib/minurl.browser.js | |
| /** | |
| * @param {URL | string} path | |
| * File URL. | |
| * @returns {string} | |
| * File URL. | |
| */ | |
| function urlToPath(path) { | |
| if (typeof path === "string") path = new URL(path); | |
| else if (!isUrl(path)) { | |
| /** @type {NodeJS.ErrnoException} */ | |
| const error = /* @__PURE__ */ new TypeError("The \"path\" argument must be of type string or an instance of URL. Received `" + path + "`"); | |
| error.code = "ERR_INVALID_ARG_TYPE"; | |
| throw error; | |
| } | |
| if (path.protocol !== "file:") { | |
| /** @type {NodeJS.ErrnoException} */ | |
| const error = /* @__PURE__ */ new TypeError("The URL must be of scheme file"); | |
| error.code = "ERR_INVALID_URL_SCHEME"; | |
| throw error; | |
| } | |
| return getPathFromURLPosix(path); | |
| } | |
| /** | |
| * Get a path from a POSIX URL. | |
| * | |
| * @param {URL} url | |
| * URL. | |
| * @returns {string} | |
| * File path. | |
| */ | |
| function getPathFromURLPosix(url) { | |
| if (url.hostname !== "") { | |
| /** @type {NodeJS.ErrnoException} */ | |
| const error = /* @__PURE__ */ 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) { | |
| /** @type {NodeJS.ErrnoException} */ | |
| const error = /* @__PURE__ */ new TypeError("File URL path must not include encoded / characters"); | |
| error.code = "ERR_INVALID_FILE_URL_PATH"; | |
| throw error; | |
| } | |
| } | |
| return decodeURIComponent(pathname); | |
| } | |
| //#endregion | |
| //#region ../node_modules/vfile/lib/index.js | |
| /** | |
| * @import {Node, Point, Position} from 'unist' | |
| * @import {Options as MessageOptions} from 'vfile-message' | |
| * @import {Compatible, Data, Map, Options, Value} from 'vfile' | |
| */ | |
| /** | |
| * @typedef {object & {type: string, position?: Position | undefined}} NodeLike | |
| */ | |
| /** | |
| * Order of setting (least specific to most), we need this because otherwise | |
| * `{stem: 'a', path: '~/b.js'}` would throw, as a path is needed before a | |
| * stem can be set. | |
| */ | |
| var order = [ | |
| "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) { | |
| /** @type {Options | VFile} */ | |
| let options; | |
| if (!value) options = {}; | |
| else if (isUrl(value)) options = { path: value }; | |
| else if (typeof value === "string" || isUint8Array$1(value)) options = { value }; | |
| else options = value; | |
| /** | |
| * Base of `path` (default: `process.cwd()` or `'/'` in browsers). | |
| * | |
| * @type {string} | |
| */ | |
| this.cwd = "cwd" in options ? "" : minproc.cwd(); | |
| /** | |
| * Place to store custom info (default: `{}`). | |
| * | |
| * It’s OK to store custom data directly on the file but moving it to | |
| * `data` is recommended. | |
| * | |
| * @type {Data} | |
| */ | |
| this.data = {}; | |
| /** | |
| * List of file paths the file moved between. | |
| * | |
| * The first is the original path and the last is the current path. | |
| * | |
| * @type {Array<string>} | |
| */ | |
| this.history = []; | |
| /** | |
| * List of messages associated with the file. | |
| * | |
| * @type {Array<VFileMessage>} | |
| */ | |
| this.messages = []; | |
| /** | |
| * Raw value. | |
| * | |
| * @type {Value} | |
| */ | |
| this.value; | |
| /** | |
| * Source map. | |
| * | |
| * This type is equivalent to the `RawSourceMap` type from the `source-map` | |
| * module. | |
| * | |
| * @type {Map | null | undefined} | |
| */ | |
| this.map; | |
| /** | |
| * Custom, non-string, compiled, representation. | |
| * | |
| * This is used by unified to store non-string results. | |
| * One example is when turning markdown into React nodes. | |
| * | |
| * @type {unknown} | |
| */ | |
| this.result; | |
| /** | |
| * Whether a file was saved to disk. | |
| * | |
| * This is used by vfile reporters. | |
| * | |
| * @type {boolean} | |
| */ | |
| this.stored; | |
| let index = -1; | |
| while (++index < order.length) { | |
| const field = order[index]; | |
| if (field in options && options[field] !== void 0 && options[field] !== null) this[field] = field === "history" ? [...options[field]] : options[field]; | |
| } | |
| /** @type {string} */ | |
| 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(basename) { | |
| assertNonEmpty(basename, "basename"); | |
| assertPart(basename, "basename"); | |
| this.path = minpath.join(this.dirname || "", basename); | |
| } | |
| /** | |
| * Get the parent path (example: `'~'`). | |
| * | |
| * @returns {string | undefined} | |
| * Dirname. | |
| */ | |
| get dirname() { | |
| return typeof this.path === "string" ? minpath.dirname(this.path) : 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(dirname) { | |
| assertPath(this.basename, "dirname"); | |
| this.path = minpath.join(dirname || "", this.basename); | |
| } | |
| /** | |
| * Get the extname (including dot) (example: `'.js'`). | |
| * | |
| * @returns {string | undefined} | |
| * Extname. | |
| */ | |
| get extname() { | |
| return typeof this.path === "string" ? minpath.extname(this.path) : 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(extname) { | |
| assertPart(extname, "extname"); | |
| assertPath(this.dirname, "extname"); | |
| if (extname) { | |
| if (extname.codePointAt(0) !== 46) throw new Error("`extname` must start with `.`"); | |
| if (extname.includes(".", 1)) throw new Error("`extname` cannot contain multiple dots"); | |
| } | |
| this.path = minpath.join(this.dirname, this.stem + (extname || "")); | |
| } | |
| /** | |
| * Get the full path (example: `'~/index.min.js'`). | |
| * | |
| * @returns {string} | |
| * Path. | |
| */ | |
| get path() { | |
| return this.history[this.history.length - 1]; | |
| } | |
| /** | |
| * Set the full path (example: `'~/index.min.js'`). | |
| * | |
| * Cannot be nullified. | |
| * You can set a file URL (a `URL` object with a `file:` protocol) which will | |
| * be turned into a path with `url.fileURLToPath`. | |
| * | |
| * @param {URL | string} path | |
| * Path. | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| set path(path) { | |
| if (isUrl(path)) path = urlToPath(path); | |
| assertNonEmpty(path, "path"); | |
| if (this.path !== path) this.history.push(path); | |
| } | |
| /** | |
| * Get the stem (basename w/o extname) (example: `'index.min'`). | |
| * | |
| * @returns {string | undefined} | |
| * Stem. | |
| */ | |
| get stem() { | |
| return typeof this.path === "string" ? minpath.basename(this.path, this.extname) : 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 || "")); | |
| } | |
| /** | |
| * 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(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; | |
| return new TextDecoder(encoding || void 0).decode(this.value); | |
| } | |
| }; | |
| /** | |
| * Assert that `part` is not a path (as in, does not contain `path.sep`). | |
| * | |
| * @param {string | null | undefined} part | |
| * File path part. | |
| * @param {string} name | |
| * Part name. | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| function assertPart(part, name) { | |
| if (part && part.includes(minpath.sep)) throw new Error("`" + name + "` cannot be a path: did not expect `" + minpath.sep + "`"); | |
| } | |
| /** | |
| * Assert that `part` is not empty. | |
| * | |
| * @param {string | undefined} part | |
| * Thing. | |
| * @param {string} name | |
| * Part name. | |
| * @returns {asserts part is string} | |
| * Nothing. | |
| */ | |
| function assertNonEmpty(part, name) { | |
| if (!part) throw new Error("`" + name + "` cannot be empty"); | |
| } | |
| /** | |
| * Assert `path` exists. | |
| * | |
| * @param {string | undefined} path | |
| * Path. | |
| * @param {string} name | |
| * Dependency name. | |
| * @returns {asserts path is string} | |
| * Nothing. | |
| */ | |
| function assertPath(path, name) { | |
| if (!path) throw new Error("Setting `" + name + "` requires `path` to be set too"); | |
| } | |
| /** | |
| * Assert `value` is an `Uint8Array`. | |
| * | |
| * @param {unknown} value | |
| * thing. | |
| * @returns {value is Uint8Array} | |
| * Whether `value` is an `Uint8Array`. | |
| */ | |
| function isUint8Array$1(value) { | |
| return Boolean(value && typeof value === "object" && "byteLength" in value && "byteOffset" in value); | |
| } | |
| //#endregion | |
| //#region ../node_modules/unified/lib/callable-instance.js | |
| var CallableInstance = (function(property) { | |
| const proto = this.constructor.prototype; | |
| const value = proto[property]; | |
| /** @type {(...parameters: Array<unknown>) => unknown} */ | |
| const apply = function() { | |
| return value.apply(apply, arguments); | |
| }; | |
| Object.setPrototypeOf(apply, proto); | |
| return apply; | |
| }); | |
| //#endregion | |
| //#region ../node_modules/unified/lib/index.js | |
| /** | |
| * @typedef {import('trough').Pipeline} Pipeline | |
| * | |
| * @typedef {import('unist').Node} Node | |
| * | |
| * @typedef {import('vfile').Compatible} Compatible | |
| * @typedef {import('vfile').Value} Value | |
| * | |
| * @typedef {import('../index.js').CompileResultMap} CompileResultMap | |
| * @typedef {import('../index.js').Data} Data | |
| * @typedef {import('../index.js').Settings} Settings | |
| */ | |
| /** | |
| * @typedef {CompileResultMap[keyof CompileResultMap]} CompileResults | |
| * Acceptable results from compilers. | |
| * | |
| * To register custom results, add them to | |
| * {@linkcode CompileResultMap}. | |
| */ | |
| /** | |
| * @template {Node} [Tree=Node] | |
| * The node that the compiler receives (default: `Node`). | |
| * @template {CompileResults} [Result=CompileResults] | |
| * The thing that the compiler yields (default: `CompileResults`). | |
| * @callback Compiler | |
| * A **compiler** handles the compiling of a syntax tree to something else | |
| * (in most cases, text) (TypeScript type). | |
| * | |
| * It is used in the stringify phase and called with a {@linkcode Node} | |
| * and {@linkcode VFile} representation of the document to compile. | |
| * It should return the textual representation of the given tree (typically | |
| * `string`). | |
| * | |
| * > **Note**: unified typically compiles by serializing: most compilers | |
| * > return `string` (or `Uint8Array`). | |
| * > Some compilers, such as the one configured with | |
| * > [`rehype-react`][rehype-react], return other values (in this case, a | |
| * > React tree). | |
| * > If you’re using a compiler that doesn’t serialize, expect different | |
| * > result values. | |
| * > | |
| * > To register custom results in TypeScript, add them to | |
| * > {@linkcode CompileResultMap}. | |
| * | |
| * [rehype-react]: https://github.com/rehypejs/rehype-react | |
| * @param {Tree} tree | |
| * Tree to compile. | |
| * @param {VFile} file | |
| * File associated with `tree`. | |
| * @returns {Result} | |
| * New content: compiled text (`string` or `Uint8Array`, for `file.value`) or | |
| * something else (for `file.result`). | |
| */ | |
| /** | |
| * @template {Node} [Tree=Node] | |
| * The node that the parser yields (default: `Node`) | |
| * @callback Parser | |
| * A **parser** handles the parsing of text to a syntax tree. | |
| * | |
| * It is used in the parse phase and is called with a `string` and | |
| * {@linkcode VFile} of the document to parse. | |
| * It must return the syntax tree representation of the given file | |
| * ({@linkcode Node}). | |
| * @param {string} document | |
| * Document to parse. | |
| * @param {VFile} file | |
| * File associated with `document`. | |
| * @returns {Tree} | |
| * Node representing the given file. | |
| */ | |
| /** | |
| * @typedef {( | |
| * Plugin<Array<any>, any, any> | | |
| * PluginTuple<Array<any>, any, any> | | |
| * Preset | |
| * )} Pluggable | |
| * Union of the different ways to add plugins and settings. | |
| */ | |
| /** | |
| * @typedef {Array<Pluggable>} PluggableList | |
| * List of plugins and presets. | |
| */ | |
| /** | |
| * @template {Array<unknown>} [PluginParameters=[]] | |
| * Arguments passed to the plugin (default: `[]`, the empty tuple). | |
| * @template {Node | string | undefined} [Input=Node] | |
| * Value that is expected as input (default: `Node`). | |
| * | |
| * * If the plugin returns a {@linkcode Transformer}, this | |
| * should be the node it expects. | |
| * * If the plugin sets a {@linkcode Parser}, this should be | |
| * `string`. | |
| * * If the plugin sets a {@linkcode Compiler}, this should be the | |
| * node it expects. | |
| * @template [Output=Input] | |
| * Value that is yielded as output (default: `Input`). | |
| * | |
| * * If the plugin returns a {@linkcode Transformer}, this | |
| * should be the node that that yields. | |
| * * If the plugin sets a {@linkcode Parser}, this should be the | |
| * node that it yields. | |
| * * If the plugin sets a {@linkcode Compiler}, this should be | |
| * result it yields. | |
| * @typedef {( | |
| * (this: Processor, ...parameters: PluginParameters) => | |
| * Input extends string ? // Parser. | |
| * Output extends Node | undefined ? undefined | void : never : | |
| * Output extends CompileResults ? // Compiler. | |
| * Input extends Node | undefined ? undefined | void : never : | |
| * Transformer< | |
| * Input extends Node ? Input : Node, | |
| * Output extends Node ? Output : Node | |
| * > | undefined | void | |
| * )} Plugin | |
| * Single plugin. | |
| * | |
| * Plugins configure the processors they are applied on in the following | |
| * ways: | |
| * | |
| * * they change the processor, such as the parser, the compiler, or by | |
| * configuring data | |
| * * they specify how to handle trees and files | |
| * | |
| * In practice, they are functions that can receive options and configure the | |
| * processor (`this`). | |
| * | |
| * > **Note**: plugins are called when the processor is *frozen*, not when | |
| * > they are applied. | |
| */ | |
| /** | |
| * Tuple of a plugin and its configuration. | |
| * | |
| * The first item is a plugin, the rest are its parameters. | |
| * | |
| * @template {Array<unknown>} [TupleParameters=[]] | |
| * Arguments passed to the plugin (default: `[]`, the empty tuple). | |
| * @template {Node | string | undefined} [Input=undefined] | |
| * Value that is expected as input (optional). | |
| * | |
| * * If the plugin returns a {@linkcode Transformer}, this | |
| * should be the node it expects. | |
| * * If the plugin sets a {@linkcode Parser}, this should be | |
| * `string`. | |
| * * If the plugin sets a {@linkcode Compiler}, this should be the | |
| * node it expects. | |
| * @template [Output=undefined] (optional). | |
| * Value that is yielded as output. | |
| * | |
| * * If the plugin returns a {@linkcode Transformer}, this | |
| * should be the node that that yields. | |
| * * If the plugin sets a {@linkcode Parser}, this should be the | |
| * node that it yields. | |
| * * If the plugin sets a {@linkcode Compiler}, this should be | |
| * result it yields. | |
| * @typedef {( | |
| * [ | |
| * plugin: Plugin<TupleParameters, Input, Output>, | |
| * ...parameters: TupleParameters | |
| * ] | |
| * )} PluginTuple | |
| */ | |
| /** | |
| * @typedef Preset | |
| * Sharable configuration. | |
| * | |
| * They can contain plugins and settings. | |
| * @property {PluggableList | undefined} [plugins] | |
| * List of plugins and presets (optional). | |
| * @property {Settings | undefined} [settings] | |
| * Shared settings for parsers and compilers (optional). | |
| */ | |
| /** | |
| * @template {VFile} [File=VFile] | |
| * The file that the callback receives (default: `VFile`). | |
| * @callback ProcessCallback | |
| * Callback called when the process is done. | |
| * | |
| * Called with either an error or a result. | |
| * @param {Error | undefined} [error] | |
| * Fatal error (optional). | |
| * @param {File | undefined} [file] | |
| * Processed file (optional). | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| /** | |
| * @template {Node} [Tree=Node] | |
| * The tree that the callback receives (default: `Node`). | |
| * @callback RunCallback | |
| * Callback called when transformers are done. | |
| * | |
| * Called with either an error or results. | |
| * @param {Error | undefined} [error] | |
| * Fatal error (optional). | |
| * @param {Tree | undefined} [tree] | |
| * Transformed tree (optional). | |
| * @param {VFile | undefined} [file] | |
| * File (optional). | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| /** | |
| * @template {Node} [Output=Node] | |
| * Node type that the transformer yields (default: `Node`). | |
| * @callback TransformCallback | |
| * Callback passed to transforms. | |
| * | |
| * If the signature of a `transformer` accepts a third argument, the | |
| * transformer may perform asynchronous operations, and must call it. | |
| * @param {Error | undefined} [error] | |
| * Fatal error to stop the process (optional). | |
| * @param {Output | undefined} [tree] | |
| * New, changed, tree (optional). | |
| * @param {VFile | undefined} [file] | |
| * New, changed, file (optional). | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| /** | |
| * @template {Node} [Input=Node] | |
| * Node type that the transformer expects (default: `Node`). | |
| * @template {Node} [Output=Input] | |
| * Node type that the transformer yields (default: `Input`). | |
| * @callback Transformer | |
| * Transformers handle syntax trees and files. | |
| * | |
| * They are functions that are called each time a syntax tree and file are | |
| * passed through the run phase. | |
| * When an error occurs in them (either because it’s thrown, returned, | |
| * rejected, or passed to `next`), the process stops. | |
| * | |
| * The run phase is handled by [`trough`][trough], see its documentation for | |
| * the exact semantics of these functions. | |
| * | |
| * > **Note**: you should likely ignore `next`: don’t accept it. | |
| * > it supports callback-style async work. | |
| * > But promises are likely easier to reason about. | |
| * | |
| * [trough]: https://github.com/wooorm/trough#function-fninput-next | |
| * @param {Input} tree | |
| * Tree to handle. | |
| * @param {VFile} file | |
| * File to handle. | |
| * @param {TransformCallback<Output>} next | |
| * Callback. | |
| * @returns {( | |
| * Promise<Output | undefined | void> | | |
| * Promise<never> | // For some reason this is needed separately. | |
| * Output | | |
| * Error | | |
| * undefined | | |
| * void | |
| * )} | |
| * If you accept `next`, nothing. | |
| * Otherwise: | |
| * | |
| * * `Error` — fatal error to stop the process | |
| * * `Promise<undefined>` or `undefined` — the next transformer keeps using | |
| * same tree | |
| * * `Promise<Node>` or `Node` — new, changed, tree | |
| */ | |
| /** | |
| * @template {Node | undefined} ParseTree | |
| * Output of `parse`. | |
| * @template {Node | undefined} HeadTree | |
| * Input for `run`. | |
| * @template {Node | undefined} TailTree | |
| * Output for `run`. | |
| * @template {Node | undefined} CompileTree | |
| * Input of `stringify`. | |
| * @template {CompileResults | undefined} CompileResult | |
| * Output of `stringify`. | |
| * @template {Node | string | undefined} Input | |
| * Input of plugin. | |
| * @template Output | |
| * Output of plugin (optional). | |
| * @typedef {( | |
| * Input extends string | |
| * ? Output extends Node | undefined | |
| * ? // Parser. | |
| * Processor< | |
| * Output extends undefined ? ParseTree : Output, | |
| * HeadTree, | |
| * TailTree, | |
| * CompileTree, | |
| * CompileResult | |
| * > | |
| * : // Unknown. | |
| * Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult> | |
| * : Output extends CompileResults | |
| * ? Input extends Node | undefined | |
| * ? // Compiler. | |
| * Processor< | |
| * ParseTree, | |
| * HeadTree, | |
| * TailTree, | |
| * Input extends undefined ? CompileTree : Input, | |
| * Output extends undefined ? CompileResult : Output | |
| * > | |
| * : // Unknown. | |
| * Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult> | |
| * : Input extends Node | undefined | |
| * ? Output extends Node | undefined | |
| * ? // Transform. | |
| * Processor< | |
| * ParseTree, | |
| * HeadTree extends undefined ? Input : HeadTree, | |
| * Output extends undefined ? TailTree : Output, | |
| * CompileTree, | |
| * CompileResult | |
| * > | |
| * : // Unknown. | |
| * Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult> | |
| * : // Unknown. | |
| * Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult> | |
| * )} UsePlugin | |
| * Create a processor based on the input/output of a {@link Plugin plugin}. | |
| */ | |
| /** | |
| * @template {CompileResults | undefined} Result | |
| * Node type that the transformer yields. | |
| * @typedef {( | |
| * Result extends Value | undefined ? | |
| * VFile : | |
| * VFile & {result: Result} | |
| * )} VFileWithOutput | |
| * Type to generate a {@linkcode VFile} corresponding to a compiler result. | |
| * | |
| * If a result that is not acceptable on a `VFile` is used, that will | |
| * be stored on the `result` field of {@linkcode VFile}. | |
| */ | |
| var import_extend = /* @__PURE__ */ __toESM(require_extend(), 1); | |
| var own = {}.hasOwnProperty; | |
| /** | |
| * Create a new processor. | |
| * | |
| * @example | |
| * This example shows how a new processor can be created (from `remark`) and linked | |
| * to **stdin**(4) and **stdout**(4). | |
| * | |
| * ```js | |
| * import process from 'node:process' | |
| * import concatStream from 'concat-stream' | |
| * import {remark} from 'remark' | |
| * | |
| * process.stdin.pipe( | |
| * concatStream(function (buf) { | |
| * process.stdout.write(String(remark().processSync(buf))) | |
| * }) | |
| * ) | |
| * ``` | |
| * | |
| * @returns | |
| * New *unfrozen* processor (`processor`). | |
| * | |
| * This processor 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. | |
| */ | |
| var unified = new class Processor extends CallableInstance { | |
| /** | |
| * Create a processor. | |
| */ | |
| constructor() { | |
| super("copy"); | |
| /** | |
| * Compiler to use (deprecated). | |
| * | |
| * @deprecated | |
| * Use `compiler` instead. | |
| * @type {( | |
| * Compiler< | |
| * CompileTree extends undefined ? Node : CompileTree, | |
| * CompileResult extends undefined ? CompileResults : CompileResult | |
| * > | | |
| * undefined | |
| * )} | |
| */ | |
| this.Compiler = void 0; | |
| /** | |
| * Parser to use (deprecated). | |
| * | |
| * @deprecated | |
| * Use `parser` instead. | |
| * @type {( | |
| * Parser<ParseTree extends undefined ? Node : ParseTree> | | |
| * undefined | |
| * )} | |
| */ | |
| this.Parser = void 0; | |
| /** | |
| * Internal list of configured plugins. | |
| * | |
| * @deprecated | |
| * This is a private internal property and should not be used. | |
| * @type {Array<PluginTuple<Array<unknown>>>} | |
| */ | |
| this.attachers = []; | |
| /** | |
| * Compiler to use. | |
| * | |
| * @type {( | |
| * Compiler< | |
| * CompileTree extends undefined ? Node : CompileTree, | |
| * CompileResult extends undefined ? CompileResults : CompileResult | |
| * > | | |
| * undefined | |
| * )} | |
| */ | |
| this.compiler = void 0; | |
| /** | |
| * Internal state to track where we are while freezing. | |
| * | |
| * @deprecated | |
| * This is a private internal property and should not be used. | |
| * @type {number} | |
| */ | |
| this.freezeIndex = -1; | |
| /** | |
| * Internal state to track whether we’re frozen. | |
| * | |
| * @deprecated | |
| * This is a private internal property and should not be used. | |
| * @type {boolean | undefined} | |
| */ | |
| this.frozen = void 0; | |
| /** | |
| * Internal state. | |
| * | |
| * @deprecated | |
| * This is a private internal property and should not be used. | |
| * @type {Data} | |
| */ | |
| this.namespace = {}; | |
| /** | |
| * Parser to use. | |
| * | |
| * @type {( | |
| * Parser<ParseTree extends undefined ? Node : ParseTree> | | |
| * undefined | |
| * )} | |
| */ | |
| this.parser = void 0; | |
| /** | |
| * Internal list of configured transformers. | |
| * | |
| * @deprecated | |
| * This is a private internal property and should not be used. | |
| * @type {Pipeline} | |
| */ | |
| 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 = 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 own.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 = 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); | |
| /** | |
| * @param {((file: VFileWithOutput<CompileResult>) => undefined | void) | undefined} resolve | |
| * @param {(error: Error | undefined) => undefined | void} reject | |
| * @returns {undefined} | |
| */ | |
| function executor(resolve, reject) { | |
| const realFile = vfile(file); | |
| const parseTree = self.parse(realFile); | |
| self.run(parseTree, realFile, function(error, tree, file) { | |
| if (error || !tree || !file) return realDone(error); | |
| const compileTree = tree; | |
| const compileResult = self.stringify(compileTree, file); | |
| if (looksLikeAValue(compileResult)) file.value = compileResult; | |
| else file.result = compileResult; | |
| realDone(error, file); | |
| }); | |
| /** | |
| * @param {Error | undefined} error | |
| * @param {VFileWithOutput<CompileResult> | undefined} [file] | |
| * @returns {undefined} | |
| */ | |
| function realDone(error, file) { | |
| if (error || !file) reject(error); | |
| else if (resolve) resolve(file); | |
| else { | |
| ok(done, "`done` is defined if `resolve` is not"); | |
| done(void 0, file); | |
| } | |
| } | |
| } | |
| } | |
| /** | |
| * 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) { | |
| /** @type {boolean} */ | |
| let complete = false; | |
| /** @type {VFileWithOutput<CompileResult> | undefined} */ | |
| 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; | |
| /** | |
| * @type {ProcessCallback<VFileWithOutput<CompileResult>>} | |
| */ | |
| function realDone(error, file) { | |
| complete = true; | |
| bail(error); | |
| result = file; | |
| } | |
| } | |
| /** | |
| * 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); | |
| /** | |
| * @param {( | |
| * ((tree: TailTree extends undefined ? Node : TailTree) => undefined | void) | | |
| * undefined | |
| * )} resolve | |
| * @param {(error: Error) => undefined | void} reject | |
| * @returns {undefined} | |
| */ | |
| 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); | |
| /** | |
| * @param {Error | undefined} error | |
| * @param {Node} outputTree | |
| * @param {VFile} file | |
| * @returns {undefined} | |
| */ | |
| function realDone(error, outputTree, file) { | |
| const resultingTree = 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, file); | |
| } | |
| } | |
| } | |
| } | |
| /** | |
| * 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) { | |
| /** @type {boolean} */ | |
| let complete = false; | |
| /** @type {(TailTree extends undefined ? Node : TailTree) | undefined} */ | |
| 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; | |
| /** | |
| * @type {RunCallback<TailTree extends undefined ? Node : TailTree>} | |
| */ | |
| function realDone(error, tree) { | |
| bail(error); | |
| result = tree; | |
| 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 compiler = this.compiler || this.Compiler; | |
| assertCompiler("stringify", compiler); | |
| assertNode(tree); | |
| return compiler(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; | |
| /** | |
| * @param {Pluggable} value | |
| * @returns {undefined} | |
| */ | |
| function add(value) { | |
| if (typeof value === "function") addPlugin(value, []); | |
| else if (typeof value === "object") if (Array.isArray(value)) { | |
| const [plugin, ...parameters] = value; | |
| addPlugin(plugin, parameters); | |
| } else addPreset(value); | |
| else throw new TypeError("Expected usable value, not `" + value + "`"); | |
| } | |
| /** | |
| * @param {Preset} result | |
| * @returns {undefined} | |
| */ | |
| 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); | |
| } | |
| /** | |
| * @param {PluggableList | null | undefined} plugins | |
| * @returns {undefined} | |
| */ | |
| 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 + "`"); | |
| } | |
| /** | |
| * @param {Plugin} plugin | |
| * @param {Array<unknown>} parameters | |
| * @returns {undefined} | |
| */ | |
| function addPlugin(plugin, parameters) { | |
| let index = -1; | |
| let entryIndex = -1; | |
| while (++index < attachers.length) if (attachers[index][0] === plugin) { | |
| entryIndex = index; | |
| break; | |
| } | |
| if (entryIndex === -1) attachers.push([plugin, ...parameters]); | |
| else if (parameters.length > 0) { | |
| let [primary, ...rest] = parameters; | |
| const currentPrimary = attachers[entryIndex][1]; | |
| if (isPlainObject(currentPrimary) && isPlainObject(primary)) primary = (0, import_extend.default)(true, currentPrimary, primary); | |
| attachers[entryIndex] = [ | |
| plugin, | |
| primary, | |
| ...rest | |
| ]; | |
| } | |
| } | |
| } | |
| }().freeze(); | |
| /** | |
| * Assert a parser is available. | |
| * | |
| * @param {string} name | |
| * @param {unknown} value | |
| * @returns {asserts value is Parser} | |
| */ | |
| function assertParser(name, value) { | |
| if (typeof value !== "function") throw new TypeError("Cannot `" + name + "` without `parser`"); | |
| } | |
| /** | |
| * Assert a compiler is available. | |
| * | |
| * @param {string} name | |
| * @param {unknown} value | |
| * @returns {asserts value is Compiler} | |
| */ | |
| function assertCompiler(name, value) { | |
| if (typeof value !== "function") throw new TypeError("Cannot `" + name + "` without `compiler`"); | |
| } | |
| /** | |
| * Assert the processor is not frozen. | |
| * | |
| * @param {string} name | |
| * @param {unknown} frozen | |
| * @returns {asserts frozen is false} | |
| */ | |
| 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`."); | |
| } | |
| /** | |
| * Assert `node` is a unist node. | |
| * | |
| * @param {unknown} node | |
| * @returns {asserts node is Node} | |
| */ | |
| function assertNode(node) { | |
| if (!isPlainObject(node) || typeof node.type !== "string") throw new TypeError("Expected node, got `" + node + "`"); | |
| } | |
| /** | |
| * Assert that `complete` is `true`. | |
| * | |
| * @param {string} name | |
| * @param {string} asyncName | |
| * @param {unknown} complete | |
| * @returns {asserts complete is true} | |
| */ | |
| function assertDone(name, asyncName, complete) { | |
| if (!complete) throw new Error("`" + name + "` finished async. Use `" + asyncName + "` instead"); | |
| } | |
| /** | |
| * @param {Compatible | undefined} [value] | |
| * @returns {VFile} | |
| */ | |
| function vfile(value) { | |
| return looksLikeAVFile(value) ? value : new VFile(value); | |
| } | |
| /** | |
| * @param {Compatible | undefined} [value] | |
| * @returns {value is VFile} | |
| */ | |
| function looksLikeAVFile(value) { | |
| return Boolean(value && typeof value === "object" && "message" in value && "messages" in value); | |
| } | |
| /** | |
| * @param {unknown} [value] | |
| * @returns {value is Value} | |
| */ | |
| function looksLikeAValue(value) { | |
| return typeof value === "string" || isUint8Array(value); | |
| } | |
| /** | |
| * Assert `value` is an `Uint8Array`. | |
| * | |
| * @param {unknown} value | |
| * thing. | |
| * @returns {value is Uint8Array} | |
| * Whether `value` is an `Uint8Array`. | |
| */ | |
| function isUint8Array(value) { | |
| return Boolean(value && typeof value === "object" && "byteLength" in value && "byteOffset" in value); | |
| } | |
| //#endregion | |
| //#region ../node_modules/react-markdown/lib/index.js | |
| /** | |
| * @import {Element, Nodes, Parents, Root} from 'hast' | |
| * @import {Root as MdastRoot} from 'mdast' | |
| * @import {ComponentType, JSX, ReactElement, ReactNode} from 'react' | |
| * @import {Options as RemarkRehypeOptions} from 'remark-rehype' | |
| * @import {BuildVisitor} from 'unist-util-visit' | |
| * @import {PluggableList, Processor} from 'unified' | |
| */ | |
| /** | |
| * @callback AllowElement | |
| * Filter elements. | |
| * @param {Readonly<Element>} element | |
| * Element to check. | |
| * @param {number} index | |
| * Index of `element` in `parent`. | |
| * @param {Readonly<Parents> | undefined} parent | |
| * Parent of `element`. | |
| * @returns {boolean | null | undefined} | |
| * Whether to allow `element` (default: `false`). | |
| */ | |
| /** | |
| * @typedef ExtraProps | |
| * Extra fields we pass. | |
| * @property {Element | undefined} [node] | |
| * passed when `passNode` is on. | |
| */ | |
| /** | |
| * @typedef {{ | |
| * [Key in keyof JSX.IntrinsicElements]?: ComponentType<JSX.IntrinsicElements[Key] & ExtraProps> | keyof JSX.IntrinsicElements | |
| * }} Components | |
| * Map tag names to components. | |
| */ | |
| /** | |
| * @typedef Deprecation | |
| * Deprecation. | |
| * @property {string} from | |
| * Old field. | |
| * @property {string} id | |
| * ID in readme. | |
| * @property {keyof Options} [to] | |
| * New field. | |
| */ | |
| /** | |
| * @typedef Options | |
| * Configuration. | |
| * @property {AllowElement | null | undefined} [allowElement] | |
| * Filter elements (optional); | |
| * `allowedElements` / `disallowedElements` is used first. | |
| * @property {ReadonlyArray<string> | null | undefined} [allowedElements] | |
| * Tag names to allow (default: all tag names); | |
| * cannot combine w/ `disallowedElements`. | |
| * @property {string | null | undefined} [children] | |
| * Markdown. | |
| * @property {Components | null | undefined} [components] | |
| * Map tag names to components. | |
| * @property {ReadonlyArray<string> | null | undefined} [disallowedElements] | |
| * Tag names to disallow (default: `[]`); | |
| * cannot combine w/ `allowedElements`. | |
| * @property {PluggableList | null | undefined} [rehypePlugins] | |
| * List of rehype plugins to use. | |
| * @property {PluggableList | null | undefined} [remarkPlugins] | |
| * List of remark plugins to use. | |
| * @property {Readonly<RemarkRehypeOptions> | null | undefined} [remarkRehypeOptions] | |
| * Options to pass through to `remark-rehype`. | |
| * @property {boolean | null | undefined} [skipHtml=false] | |
| * Ignore HTML in markdown completely (default: `false`). | |
| * @property {boolean | null | undefined} [unwrapDisallowed=false] | |
| * Extract (unwrap) what’s in disallowed elements (default: `false`); | |
| * normally when say `strong` is not allowed, it and it’s children are dropped, | |
| * with `unwrapDisallowed` the element itself is replaced by its children. | |
| * @property {UrlTransform | null | undefined} [urlTransform] | |
| * Change URLs (default: `defaultUrlTransform`) | |
| */ | |
| /** | |
| * @typedef HooksOptionsOnly | |
| * Configuration specifically for {@linkcode MarkdownHooks}. | |
| * @property {ReactNode | null | undefined} [fallback] | |
| * Content to render while the processor processing the markdown (optional). | |
| */ | |
| /** | |
| * @typedef {Options & HooksOptionsOnly} HooksOptions | |
| * Configuration for {@linkcode MarkdownHooks}; | |
| * extends the regular {@linkcode Options} with a `fallback` prop. | |
| */ | |
| /** | |
| * @callback UrlTransform | |
| * Transform all URLs. | |
| * @param {string} url | |
| * URL. | |
| * @param {string} key | |
| * Property name (example: `'href'`). | |
| * @param {Readonly<Element>} node | |
| * Node. | |
| * @returns {string | null | undefined} | |
| * Transformed URL (optional). | |
| */ | |
| var import_jsx_runtime = require_jsx_runtime(); | |
| var import_react = /* @__PURE__ */ __toESM(require_react(), 1); | |
| /** @type {PluggableList} */ | |
| var emptyPlugins = []; | |
| /** @type {Readonly<RemarkRehypeOptions>} */ | |
| var emptyRemarkRehypeOptions = { allowDangerousHtml: true }; | |
| var safeProtocol = /^(https?|ircs?|mailto|xmpp)$/i; | |
| /** @type {ReadonlyArray<Readonly<Deprecation>>} */ | |
| 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" | |
| } | |
| ]; | |
| /** | |
| * Component to render markdown. | |
| * | |
| * This is a synchronous component. | |
| * When using async plugins, | |
| * see {@linkcode MarkdownAsync} or {@linkcode MarkdownHooks}. | |
| * | |
| * @param {Readonly<Options>} options | |
| * Props. | |
| * @returns {ReactElement} | |
| * React element. | |
| */ | |
| function Markdown(options) { | |
| const processor = createProcessor(options); | |
| const file = createFile(options); | |
| return post(processor.runSync(processor.parse(file), file), options); | |
| } | |
| /** | |
| * Component to render markdown with support for async plugins | |
| * through async/await. | |
| * | |
| * Components returning promises are supported on the server. | |
| * For async support on the client, | |
| * see {@linkcode MarkdownHooks}. | |
| * | |
| * @param {Readonly<Options>} options | |
| * Props. | |
| * @returns {Promise<ReactElement>} | |
| * Promise to a React element. | |
| */ | |
| async function MarkdownAsync(options) { | |
| const processor = createProcessor(options); | |
| const file = createFile(options); | |
| return post(await processor.run(processor.parse(file), file), options); | |
| } | |
| /** | |
| * Component to render markdown with support for async plugins through hooks. | |
| * | |
| * This uses `useEffect` and `useState` hooks. | |
| * Hooks run on the client and do not immediately render something. | |
| * For async support on the server, | |
| * see {@linkcode MarkdownAsync}. | |
| * | |
| * @param {Readonly<HooksOptions>} options | |
| * Props. | |
| * @returns {ReactNode} | |
| * React node. | |
| */ | |
| function MarkdownHooks(options) { | |
| const processor = createProcessor(options); | |
| const [error, setError] = (0, import_react.useState)(void 0); | |
| const [tree, setTree] = (0, import_react.useState)(void 0); | |
| (0, import_react.useEffect)(function() { | |
| let cancelled = false; | |
| const file = createFile(options); | |
| processor.run(processor.parse(file), file, function(error, tree) { | |
| if (!cancelled) { | |
| setError(error); | |
| setTree(tree); | |
| } | |
| }); | |
| /** | |
| * @returns {undefined} | |
| * Nothing. | |
| */ | |
| return function() { | |
| cancelled = true; | |
| }; | |
| }, [ | |
| options.children, | |
| options.rehypePlugins, | |
| options.remarkPlugins, | |
| options.remarkRehypeOptions | |
| ]); | |
| if (error) throw error; | |
| return tree ? post(tree, options) : options.fallback; | |
| } | |
| /** | |
| * Set up the `unified` processor. | |
| * | |
| * @param {Readonly<Options>} options | |
| * Props. | |
| * @returns {Processor<MdastRoot, MdastRoot, Root, undefined, undefined>} | |
| * Result. | |
| */ | |
| function createProcessor(options) { | |
| const rehypePlugins = options.rehypePlugins || emptyPlugins; | |
| const remarkPlugins = options.remarkPlugins || emptyPlugins; | |
| const remarkRehypeOptions = options.remarkRehypeOptions ? { | |
| ...options.remarkRehypeOptions, | |
| ...emptyRemarkRehypeOptions | |
| } : emptyRemarkRehypeOptions; | |
| return unified().use(remarkParse).use(remarkPlugins).use(remarkRehype, remarkRehypeOptions).use(rehypePlugins); | |
| } | |
| /** | |
| * Set up the virtual file. | |
| * | |
| * @param {Readonly<Options>} options | |
| * Props. | |
| * @returns {VFile} | |
| * Result. | |
| */ | |
| 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; | |
| } | |
| /** | |
| * Process the result from unified some more. | |
| * | |
| * @param {Nodes} tree | |
| * Tree. | |
| * @param {Readonly<Options>} options | |
| * Props. | |
| * @returns {ReactElement} | |
| * React element. | |
| */ | |
| 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 <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#" + 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 | |
| }); | |
| /** @type {BuildVisitor<Root>} */ | |
| 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") { | |
| /** @type {string} */ | |
| 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; | |
| } | |
| } | |
| } | |
| } | |
| /** | |
| * Make a URL safe. | |
| * | |
| * @satisfies {UrlTransform} | |
| * @param {string} value | |
| * URL. | |
| * @returns {string} | |
| * Safe URL. | |
| */ | |
| function defaultUrlTransform(value) { | |
| const colon = value.indexOf(":"); | |
| const questionMark = value.indexOf("?"); | |
| const numberSign = value.indexOf("#"); | |
| const slash = value.indexOf("/"); | |
| if (colon === -1 || slash !== -1 && colon > slash || questionMark !== -1 && colon > questionMark || numberSign !== -1 && colon > numberSign || safeProtocol.test(value.slice(0, colon))) return value; | |
| return ""; | |
| } | |
| //#endregion | |
| export { MarkdownAsync, MarkdownHooks, Markdown as default, defaultUrlTransform }; | |
| //# sourceMappingURL=react-markdown.js.map |