Problem: the hexagonal refactor churns the backend tree for nine more phases; the UI delivery stack (web/ SPA, cmd/desktop Wails wrapper, compose/web image) must move to its own repo first so doc/layout rewrites land once on a backend-only tree. Change: - New repo git.hubris.network/dtoro/oikos-web (v0.33.0): web/, desktop/ (updateURL repointed to oikos-web releases), compose/, own CI (web + desktop jobs), own deploy script (CI-green gate, TOCTOU guard, version-tagged images, prune-to-3), own webhook receiver on :9798 + launchd unit, own compose project publishing the same 8091:80. - Cutover executed on mac-mini in order: oikos stack's web service stopped+removed, oikos-web project brought up on 8091; outer Caddy untouched (targets the published port) — serving + Authentik flow + /wails 404 quirk verified post-cutover. - Stripped from oikos: web/, cmd/desktop/, compose/web/, desktop CI workflow, ci.yml web job, Makefile ui/desktop/desktop-package/install targets, the compose web service, oikos-web from deploy.sh's fallback prune list; wails + go-keyring dropped from go.mod, vendor synced. - README / CONTRIBUTING / AGENTS.md / .agents dev+operations docs now point at the new repo; mbse + mascot design docs carry a path note. Risk: production SPA serving depends on the new pipeline now; rollback is versioned-image re-up of the old web service from a pre-split checkout (port 8091). Desktop builds installed before the split still check dtoro/oikos releases — one manual reinstall, noted in the oikos-web release notes. Verification: go vet, make test (race), make generate-check, golangci (no new findings; baseline down 400→365); post-cutover curls — localhost:8091 200, /wails/runtime.js 404, outer Caddy 302 Authentik.
1286 lines
56 KiB
JavaScript
1286 lines
56 KiB
JavaScript
import {
|
|
__publicField
|
|
} from "./chunk-KWPVD4H7.js";
|
|
|
|
// node_modules/marked/lib/marked.esm.js
|
|
function C() {
|
|
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
}
|
|
var R = C();
|
|
function j(l3) {
|
|
R = l3;
|
|
}
|
|
var z = { exec: () => null };
|
|
function A(l3) {
|
|
let e = [];
|
|
return (t) => {
|
|
let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
|
|
return s || (s = l3(n), e[n] = s), s;
|
|
};
|
|
}
|
|
function k(l3, e = "") {
|
|
let t = typeof l3 == "string" ? l3 : l3.source, n = { replace: (s, r) => {
|
|
let i = typeof r == "string" ? r : r.source;
|
|
return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n;
|
|
}, getRegex: () => new RegExp(t, e) };
|
|
return n;
|
|
}
|
|
var Te = ((l3 = "") => {
|
|
try {
|
|
return !!new RegExp("(?<=1)(?<!1)" + l3);
|
|
} catch {
|
|
return false;
|
|
}
|
|
})();
|
|
var m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (l3) => new RegExp(`^( {0,3}${l3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: A((l3) => new RegExp(`^ {0,${l3}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: A((l3) => new RegExp(`^ {0,${l3}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)), fencesBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}(?:\`\`\`|~~~)`)), headingBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}#`)), htmlBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}<(?:[a-z].*>|!--)`, "i")), blockquoteBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}>`)) };
|
|
var Oe = /^(?:[ \t]*(?:\n|$))+/;
|
|
var we = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
var ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
var q = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
var Pe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
var U = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
|
|
var oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
|
|
var ae = k(oe).replace(/bull/g, U).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
|
|
var Se = k(oe).replace(/bull/g, U).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
|
|
var K = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
|
|
var _e = /^[^\n]+/;
|
|
var W = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
|
|
var $e = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", W).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
|
|
var Le = k(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, U).getRegex();
|
|
var Q = "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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
|
|
var X = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
var Me = k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", X).replace("tag", Q).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
var le = (l3) => k(K).replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list", l3).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
|
|
var ze = le(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
|
|
var Ee = le(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
|
|
var Ce = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Ee).getRegex();
|
|
var J = { blockquote: Ce, code: we, def: $e, fences: ye, heading: Pe, hr: q, html: Me, lheading: ae, list: Le, newline: Oe, paragraph: ze, table: z, text: _e };
|
|
var se = k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
|
|
var Ae = { ...J, lheading: Se, table: se, paragraph: k(K).replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex() };
|
|
var Ie = { ...J, html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", X).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: z, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: k(K).replace("hr", q).replace("heading", ` *#{1,6} *[^
|
|
]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
|
|
var Be = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
var De = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
var pe = /^( {2,}|\\)\n(?!\s*$)/;
|
|
var qe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
var _ = /[\p{P}\p{S}]/u;
|
|
var I = /[\s\p{P}\p{S}]/u;
|
|
var v = /[^\s\p{P}\p{S}]/u;
|
|
var ve = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, I).getRegex();
|
|
var He = /[\p{Pi}\p{Ps}"']/u;
|
|
var ue = /(?!~)[\p{P}\p{S}]/u;
|
|
var Ze = /(?!~)[\s\p{P}\p{S}]/u;
|
|
var Ge = /(?:[^\s\p{P}\p{S}]|~)/u;
|
|
var Qe = k(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Te ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
|
|
var ce = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
|
|
var Ne = k(ce, "u").replace(/punct/g, _).getRegex();
|
|
var je = k(ce, "u").replace(/punct/g, ue).getRegex();
|
|
var Fe = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
|
|
var Ue = k(Fe, "u").replace(/openQuote/g, He).replace(/punct/g, _).getRegex();
|
|
var he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
|
|
var Ke = k(he, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
var We = k(he, "gu").replace(/notPunctSpace/g, Ge).replace(/punctSpace/g, Ze).replace(/punct/g, ue).getRegex();
|
|
var Xe = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
|
|
var Je = k(Xe, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
var Ve = k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
var Ye = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)";
|
|
var et = k(Ye, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
var tt = k(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, _).getRegex();
|
|
var nt = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
|
|
var rt = k(nt, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
var st = k(/\\(punct)/, "gu").replace(/punct/g, _).getRegex();
|
|
var it = k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
|
|
var ot = k(X).replace("(?:-->|$)", "-->").getRegex();
|
|
var at = k("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", ot).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
|
|
var G = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
|
|
var lt = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", G).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
|
|
var de = k(/^!?\[(label)\]\[(ref)\]/).replace("label", G).replace("ref", W).getRegex();
|
|
var ke = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", W).getRegex();
|
|
var pt = k("reflink|nolink(?!\\()", "g").replace("reflink", de).replace("nolink", ke).getRegex();
|
|
var ie = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
|
|
var V = { _backpedal: z, anyPunctuation: st, autolink: it, blockSkip: Qe, br: pe, code: De, del: z, delLDelim: z, delRDelim: z, emStrongLDelim: Ne, emStrongRDelimAst: Ke, emStrongRDelimUnd: Ve, escape: Be, link: lt, nolink: ke, punctuation: ve, reflink: de, reflinkSearch: pt, tag: at, text: qe, url: z };
|
|
var ut = { ...V, emStrongLDelim: Ue, emStrongRDelimAst: Je, emStrongRDelimUnd: et, link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", G).getRegex(), reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", G).getRegex() };
|
|
var F = { ...V, emStrongRDelimAst: We, emStrongLDelim: je, delLDelim: tt, delRDelim: rt, url: k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ie).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: k(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ie).getRegex() };
|
|
var ct = { ...F, br: k(pe).replace("{2,}", "*").getRegex(), text: k(F.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
|
|
var H = { normal: J, gfm: Ae, pedantic: Ie };
|
|
var B = { normal: V, gfm: F, breaks: ct, pedantic: ut };
|
|
var ht = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
var ge = (l3) => ht[l3];
|
|
function O(l3, e) {
|
|
if (e) {
|
|
if (m.escapeTest.test(l3)) return l3.replace(m.escapeReplace, ge);
|
|
} else if (m.escapeTestNoEncode.test(l3)) return l3.replace(m.escapeReplaceNoEncode, ge);
|
|
return l3;
|
|
}
|
|
function Y(l3) {
|
|
try {
|
|
l3 = encodeURI(l3).replace(m.percentDecode, "%");
|
|
} catch {
|
|
return null;
|
|
}
|
|
return l3;
|
|
}
|
|
function ee(l3, e) {
|
|
var _a2;
|
|
let t = l3.replace(m.findPipe, (r, i, o) => {
|
|
let p = false, a = i;
|
|
for (; --a >= 0 && o[a] === "\\"; ) p = !p;
|
|
return p ? "|" : " |";
|
|
}), n = t.split(m.splitPipe), s = 0;
|
|
if (n[0].trim() || n.shift(), n.length > 0 && !((_a2 = n.at(-1)) == null ? void 0 : _a2.trim()) && n.pop(), e) if (n.length > e) n.splice(e);
|
|
else for (; n.length < e; ) n.push("");
|
|
for (; s < n.length; s++) n[s] = n[s].trim().replace(m.slashPipe, "|");
|
|
return n;
|
|
}
|
|
function $(l3, e, t) {
|
|
let n = l3.length;
|
|
if (n === 0) return "";
|
|
let s = 0;
|
|
for (; s < n; ) {
|
|
let r = l3.charAt(n - s - 1);
|
|
if (r === e && !t) s++;
|
|
else if (r !== e && t) s++;
|
|
else break;
|
|
}
|
|
return l3.slice(0, n - s);
|
|
}
|
|
function te(l3) {
|
|
let e = l3.split(`
|
|
`), t = e.length - 1;
|
|
for (; t >= 0 && m.blankLine.test(e[t]); ) t--;
|
|
return e.length - t <= 2 ? l3 : e.slice(0, t + 1).join(`
|
|
`);
|
|
}
|
|
function fe(l3, e) {
|
|
if (l3.indexOf(e[1]) === -1) return -1;
|
|
let t = 0;
|
|
for (let n = 0; n < l3.length; n++) if (l3[n] === "\\") n++;
|
|
else if (l3[n] === e[0]) t++;
|
|
else if (l3[n] === e[1] && (t--, t < 0)) return n;
|
|
return t > 0 ? -2 : -1;
|
|
}
|
|
function me(l3, e = 0) {
|
|
let t = e, n = "";
|
|
for (let s of l3) if (s === " ") {
|
|
let r = 4 - t % 4;
|
|
n += " ".repeat(r), t += r;
|
|
} else n += s, t++;
|
|
return n;
|
|
}
|
|
function xe(l3, e, t, n, s) {
|
|
let r = e.href, i = e.title || null, o = l3[1].replace(s.other.outputLinkReplace, "$1");
|
|
n.state.inLink = true;
|
|
let p = { type: l3[0].charAt(0) === "!" ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: n.inlineTokens(o) };
|
|
return n.state.inLink = false, p;
|
|
}
|
|
function dt(l3, e, t) {
|
|
let n = l3.match(t.other.indentCodeCompensation);
|
|
if (n === null) return e;
|
|
let s = n[1];
|
|
return e.split(`
|
|
`).map((r) => {
|
|
let i = r.match(t.other.beginningSpace);
|
|
if (i === null) return r;
|
|
let [o] = i;
|
|
return o.length >= s.length ? r.slice(s.length) : r;
|
|
}).join(`
|
|
`);
|
|
}
|
|
var y = class {
|
|
constructor(e) {
|
|
__publicField(this, "options");
|
|
__publicField(this, "rules");
|
|
__publicField(this, "lexer");
|
|
this.options = e || R;
|
|
}
|
|
space(e) {
|
|
let t = this.rules.block.newline.exec(e);
|
|
if (t && t[0].length > 0) return { type: "space", raw: t[0] };
|
|
}
|
|
code(e) {
|
|
let t = this.rules.block.code.exec(e);
|
|
if (t) {
|
|
let n = this.options.pedantic ? t[0] : te(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
|
|
return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
|
|
}
|
|
}
|
|
fences(e) {
|
|
let t = this.rules.block.fences.exec(e);
|
|
if (t) {
|
|
let n = t[0], s = dt(n, t[3] || "", this.rules);
|
|
return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
|
|
}
|
|
}
|
|
heading(e) {
|
|
let t = this.rules.block.heading.exec(e);
|
|
if (t) {
|
|
let n = t[2].trim();
|
|
if (this.rules.other.endingHash.test(n)) {
|
|
let s = $(n, "#");
|
|
(this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
|
|
}
|
|
return { type: "heading", raw: $(t[0], `
|
|
`), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
|
|
}
|
|
}
|
|
hr(e) {
|
|
let t = this.rules.block.hr.exec(e);
|
|
if (t) return { type: "hr", raw: $(t[0], `
|
|
`) };
|
|
}
|
|
blockquote(e) {
|
|
let t = this.rules.block.blockquote.exec(e);
|
|
if (t) {
|
|
let n = $(t[0], `
|
|
`).split(`
|
|
`), s = "", r = "", i = [];
|
|
for (; n.length > 0; ) {
|
|
let o = false, p = [], a;
|
|
for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) p.push(n[a]), o = true;
|
|
else if (!o) p.push(n[a]);
|
|
else break;
|
|
n = n.slice(a);
|
|
let u = p.join(`
|
|
`), c = u.replace(this.rules.other.blockquoteSetextReplace, `
|
|
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
s = s ? `${s}
|
|
${u}` : u, r = r ? `${r}
|
|
${c}` : c;
|
|
let h = this.lexer.state.top;
|
|
if (this.lexer.state.top = true, this.lexer.blockTokens(c, i, true), this.lexer.state.top = h, n.length === 0) break;
|
|
let d = i.at(-1);
|
|
if ((d == null ? void 0 : d.type) === "code") break;
|
|
if ((d == null ? void 0 : d.type) === "blockquote") {
|
|
let T = d, g = n.join(`
|
|
`), w = T.raw + `
|
|
` + g.replace(this.rules.other.blockquoteSetextReplace2, ""), M = this.blockquote(w);
|
|
i[i.length - 1] = M, s = `${s}
|
|
${g}`, r = r.substring(0, r.length - T.text.length) + M.text;
|
|
break;
|
|
} else if ((d == null ? void 0 : d.type) === "list") {
|
|
let T = d, g = T.raw + `
|
|
` + n.join(`
|
|
`), w = this.list(g);
|
|
i[i.length - 1] = w, s = s.substring(0, s.length - d.raw.length) + w.raw, r = r.substring(0, r.length - T.raw.length) + w.raw, n = g.substring(i.at(-1).raw.length).split(`
|
|
`);
|
|
continue;
|
|
}
|
|
}
|
|
return { type: "blockquote", raw: s, tokens: i, text: r };
|
|
}
|
|
}
|
|
list(e) {
|
|
let t = this.rules.block.list.exec(e);
|
|
if (t) {
|
|
let n = t[1].trim(), s = n.length > 1, r = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: false, items: [] };
|
|
n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
|
|
let i = this.rules.other.listItemRegex(n), o = false;
|
|
for (; e; ) {
|
|
let a = false, u = "", c = "";
|
|
if (!(t = i.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
u = t[0], e = e.substring(u.length);
|
|
let h = me(t[2].split(`
|
|
`, 1)[0], t[1].length), d = e.split(`
|
|
`, 1)[0], T = !h.trim(), g = 0;
|
|
if (this.options.pedantic ? (g = 2, c = h.trimStart()) : T ? g = t[1].length + 1 : (g = h.search(this.rules.other.nonSpaceChar), g = g > 4 ? 1 : g, c = h.slice(g), g += t[1].length), T && this.rules.other.blankLine.test(d) && (u += d + `
|
|
`, e = e.substring(d.length + 1), a = true), !a) {
|
|
let w = this.rules.other.nextBulletRegex(g), M = this.rules.other.hrRegex(g), ne = this.rules.other.fencesBeginRegex(g), re = this.rules.other.headingBeginRegex(g), be = this.rules.other.htmlBeginRegex(g), Re = this.rules.other.blockquoteBeginRegex(g);
|
|
for (; e; ) {
|
|
let N = e.split(`
|
|
`, 1)[0], D;
|
|
if (d = N, this.options.pedantic ? (d = d.replace(this.rules.other.listReplaceNesting, " "), D = d) : D = d.replace(this.rules.other.tabCharGlobal, " "), ne.test(d) || re.test(d) || be.test(d) || Re.test(d) || w.test(d) || M.test(d)) break;
|
|
if (D.search(this.rules.other.nonSpaceChar) >= g || !d.trim()) c += `
|
|
` + D.slice(g);
|
|
else {
|
|
if (T || h.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(h) || re.test(h) || M.test(h)) break;
|
|
c += `
|
|
` + d;
|
|
}
|
|
T = !d.trim(), u += N + `
|
|
`, e = e.substring(N.length + 1), h = D.slice(g);
|
|
}
|
|
}
|
|
r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(u) && (o = true)), r.items.push({ type: "list_item", raw: u, task: !!this.options.gfm && this.rules.other.listIsTask.test(c), loose: false, text: c, tokens: [] }), r.raw += u;
|
|
}
|
|
let p = r.items.at(-1);
|
|
if (p) p.raw = p.raw.trimEnd(), p.text = p.text.trimEnd();
|
|
else return;
|
|
r.raw = r.raw.trimEnd();
|
|
for (let a of r.items) {
|
|
this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []);
|
|
let u = a.tokens[0];
|
|
if (a.task && ((u == null ? void 0 : u.type) === "text" || (u == null ? void 0 : u.type) === "paragraph")) {
|
|
a.text = a.text.replace(this.rules.other.listReplaceTask, ""), u.raw = u.raw.replace(this.rules.other.listReplaceTask, ""), u.text = u.text.replace(this.rules.other.listReplaceTask, "");
|
|
for (let h = this.lexer.inlineQueue.length - 1; h >= 0; h--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)) {
|
|
this.lexer.inlineQueue[h].src = this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask, "");
|
|
break;
|
|
}
|
|
let c = this.rules.other.listTaskCheckbox.exec(a.raw);
|
|
if (c) {
|
|
let h = { type: "checkbox", raw: c[0] + " ", checked: c[0] !== "[ ]" };
|
|
a.checked = h.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = h.raw + a.tokens[0].raw, a.tokens[0].text = h.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(h)) : a.tokens.unshift({ type: "paragraph", raw: h.raw, text: h.raw, tokens: [h] }) : a.tokens.unshift(h);
|
|
}
|
|
} else a.task && (a.task = false);
|
|
if (!r.loose) {
|
|
let c = a.tokens.filter((d) => d.type === "space"), h = c.length > 0 && c.some((d) => this.rules.other.anyLine.test(d.raw));
|
|
r.loose = h;
|
|
}
|
|
}
|
|
if (r.loose) for (let a of r.items) {
|
|
a.loose = true;
|
|
for (let u of a.tokens) u.type === "text" && (u.type = "paragraph");
|
|
}
|
|
return r;
|
|
}
|
|
}
|
|
html(e) {
|
|
let t = this.rules.block.html.exec(e);
|
|
if (t) {
|
|
let n = te(t[0]);
|
|
return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
|
|
}
|
|
}
|
|
def(e) {
|
|
let t = this.rules.block.def.exec(e);
|
|
if (t) {
|
|
let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
return { type: "def", tag: n, raw: $(t[0], `
|
|
`), href: s, title: r };
|
|
}
|
|
}
|
|
table(e) {
|
|
var _a2;
|
|
let t = this.rules.block.table.exec(e);
|
|
if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
|
|
let n = ee(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = ((_a2 = t[3]) == null ? void 0 : _a2.trim()) ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
`) : [], i = { type: "table", raw: $(t[0], `
|
|
`), header: [], align: [], rows: [] };
|
|
if (n.length === s.length) {
|
|
for (let o of s) this.rules.other.tableAlignRight.test(o) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? i.align.push("left") : i.align.push(null);
|
|
for (let o = 0; o < n.length; o++) i.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header: true, align: i.align[o] });
|
|
for (let o of r) i.rows.push(ee(o, i.header.length).map((p, a) => ({ text: p, tokens: this.lexer.inline(p), header: false, align: i.align[a] })));
|
|
return i;
|
|
}
|
|
}
|
|
lheading(e) {
|
|
let t = this.rules.block.lheading.exec(e);
|
|
if (t) {
|
|
let n = t[1].trim();
|
|
return { type: "heading", raw: $(t[0], `
|
|
`), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
|
|
}
|
|
}
|
|
paragraph(e) {
|
|
let t = this.rules.block.paragraph.exec(e);
|
|
if (t) {
|
|
let n = t[1].charAt(t[1].length - 1) === `
|
|
` ? t[1].slice(0, -1) : t[1];
|
|
return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
|
|
}
|
|
}
|
|
text(e) {
|
|
let t = this.rules.block.text.exec(e);
|
|
if (t) return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
|
|
}
|
|
escape(e) {
|
|
let t = this.rules.inline.escape.exec(e);
|
|
if (t) return { type: "escape", raw: t[0], text: t[1] };
|
|
}
|
|
tag(e) {
|
|
let t = this.rules.inline.tag.exec(e);
|
|
if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t[0] };
|
|
}
|
|
link(e) {
|
|
let t = this.rules.inline.link.exec(e);
|
|
if (t) {
|
|
let n = t[2].trim();
|
|
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
|
|
if (!this.rules.other.endAngleBracket.test(n)) return;
|
|
let i = $(n.slice(0, -1), "\\");
|
|
if ((n.length - i.length) % 2 === 0) return;
|
|
} else {
|
|
let i = fe(t[2], "()");
|
|
if (i === -2) return;
|
|
if (i > -1) {
|
|
let p = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
|
|
t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, p).trim(), t[3] = "";
|
|
}
|
|
}
|
|
let s = t[2], r = "";
|
|
if (this.options.pedantic) {
|
|
let i = this.rules.other.pedanticHrefTitle.exec(s);
|
|
i && (s = i[1], r = i[3]);
|
|
} else r = t[3] ? t[3].slice(1, -1) : "";
|
|
return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), xe(t, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: r && r.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
|
|
}
|
|
}
|
|
reflink(e, t) {
|
|
let n;
|
|
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
|
|
if (!r) {
|
|
let i = n[0].charAt(0);
|
|
return { type: "text", raw: i, text: i };
|
|
}
|
|
return xe(n, r, n[0], this.lexer, this.rules);
|
|
}
|
|
}
|
|
emStrong(e, t, n = "") {
|
|
let s = this.rules.inline.emStrongLDelim.exec(e);
|
|
if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
|
|
if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
let i = [...s[0]].length - 1, o, p, a = i, u = 0, c = s[0][0], h = n === c, d = c === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
for (d.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = d.exec(t)) !== null; ) {
|
|
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o) continue;
|
|
if (p = [...o].length, s[3] || s[4]) {
|
|
a += p;
|
|
continue;
|
|
} else if (s[5] || s[6]) {
|
|
if (i % 3 && !((i + p) % 3)) {
|
|
u += p;
|
|
continue;
|
|
}
|
|
if (h) break;
|
|
}
|
|
if (a -= p, a > 0) continue;
|
|
p = Math.min(p, p + a + u);
|
|
let T = [...s[0]][0].length, g = e.slice(0, i + s.index + T + p);
|
|
if (Math.min(i, p) % 2) {
|
|
let M = g.slice(1, -1);
|
|
return { type: "em", raw: g, text: M, tokens: this.lexer.inlineTokens(M) };
|
|
}
|
|
let w = g.slice(2, -2);
|
|
return { type: "strong", raw: g, text: w, tokens: this.lexer.inlineTokens(w) };
|
|
}
|
|
}
|
|
}
|
|
codespan(e) {
|
|
let t = this.rules.inline.code.exec(e);
|
|
if (t) {
|
|
let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
|
|
return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
|
|
}
|
|
}
|
|
br(e) {
|
|
let t = this.rules.inline.br.exec(e);
|
|
if (t) return { type: "br", raw: t[0] };
|
|
}
|
|
del(e, t, n = "") {
|
|
let s = this.rules.inline.delLDelim.exec(e);
|
|
if (!s) return;
|
|
if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
let i = [...s[0]].length - 1, o, p, a = i, u = this.rules.inline.delRDelim;
|
|
for (u.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = u.exec(t)) !== null; ) {
|
|
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (p = [...o].length, p !== i)) continue;
|
|
if (s[3] || s[4]) {
|
|
a += p;
|
|
continue;
|
|
}
|
|
if (a -= p, a > 0) continue;
|
|
p = Math.min(p, p + a);
|
|
let c = [...s[0]][0].length, h = e.slice(0, i + s.index + c + p), d = h.slice(i, -i);
|
|
return { type: "del", raw: h, text: d, tokens: this.lexer.inlineTokens(d) };
|
|
}
|
|
}
|
|
}
|
|
autolink(e) {
|
|
let t = this.rules.inline.autolink.exec(e);
|
|
if (t) {
|
|
let n, s;
|
|
return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
|
|
}
|
|
}
|
|
url(e) {
|
|
var _a2;
|
|
let t;
|
|
if (t = this.rules.inline.url.exec(e)) {
|
|
let n, s;
|
|
if (t[2] === "@") n = t[0], s = "mailto:" + n;
|
|
else {
|
|
let r;
|
|
do
|
|
r = t[0], t[0] = ((_a2 = this.rules.inline._backpedal.exec(t[0])) == null ? void 0 : _a2[0]) ?? "";
|
|
while (r !== t[0]);
|
|
n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
|
|
}
|
|
return { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
|
|
}
|
|
}
|
|
inlineText(e) {
|
|
let t = this.rules.inline.text.exec(e);
|
|
if (t) {
|
|
let n = this.lexer.state.inRawBlock;
|
|
return { type: "text", raw: t[0], text: t[0], escaped: n };
|
|
}
|
|
}
|
|
};
|
|
var x = class l {
|
|
constructor(e) {
|
|
__publicField(this, "tokens");
|
|
__publicField(this, "options");
|
|
__publicField(this, "state");
|
|
__publicField(this, "inlineQueue");
|
|
__publicField(this, "tokenizer");
|
|
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || R, this.options.tokenizer = this.options.tokenizer || new y(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true };
|
|
let t = { other: m, block: H.normal, inline: B.normal };
|
|
this.options.pedantic ? (t.block = H.pedantic, t.inline = B.pedantic) : this.options.gfm && (t.block = H.gfm, this.options.breaks ? t.inline = B.breaks : t.inline = B.gfm), this.tokenizer.rules = t;
|
|
}
|
|
static get rules() {
|
|
return { block: H, inline: B };
|
|
}
|
|
static lex(e, t) {
|
|
return new l(t).lex(e);
|
|
}
|
|
static lexInline(e, t) {
|
|
return new l(t).inlineTokens(e);
|
|
}
|
|
lex(e) {
|
|
e = e.replace(m.carriageReturn, `
|
|
`), this.blockTokens(e, this.tokens);
|
|
for (let t = 0; t < this.inlineQueue.length; t++) {
|
|
let n = this.inlineQueue[t];
|
|
this.inlineTokens(n.src, n.tokens);
|
|
}
|
|
return this.inlineQueue = [], this.tokens;
|
|
}
|
|
blockTokens(e, t = [], n = false) {
|
|
var _a2, _b, _c;
|
|
this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
|
|
let s = 1 / 0;
|
|
for (; e; ) {
|
|
if (e.length < s) s = e.length;
|
|
else {
|
|
this.infiniteLoopError(e.charCodeAt(0));
|
|
break;
|
|
}
|
|
let r;
|
|
if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.block) == null ? void 0 : _b.some((o) => (r = o.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false)) continue;
|
|
if (r = this.tokenizer.space(e)) {
|
|
e = e.substring(r.raw.length);
|
|
let o = t.at(-1);
|
|
r.raw.length === 1 && o !== void 0 ? o.raw += `
|
|
` : t.push(r);
|
|
continue;
|
|
}
|
|
if (r = this.tokenizer.code(e)) {
|
|
e = e.substring(r.raw.length);
|
|
let o = t.at(-1);
|
|
(o == null ? void 0 : o.type) === "paragraph" || (o == null ? void 0 : o.type) === "text" ? (o.raw += (o.raw.endsWith(`
|
|
`) ? "" : `
|
|
`) + r.raw, o.text += `
|
|
` + r.text, this.inlineQueue.at(-1).src = o.text) : t.push(r);
|
|
continue;
|
|
}
|
|
if (r = this.tokenizer.fences(e)) {
|
|
e = e.substring(r.raw.length), t.push(r);
|
|
continue;
|
|
}
|
|
if (r = this.tokenizer.heading(e)) {
|
|
e = e.substring(r.raw.length), t.push(r);
|
|
continue;
|
|
}
|
|
if (r = this.tokenizer.hr(e)) {
|
|
e = e.substring(r.raw.length), t.push(r);
|
|
continue;
|
|
}
|
|
if (r = this.tokenizer.blockquote(e)) {
|
|
e = e.substring(r.raw.length), t.push(r);
|
|
continue;
|
|
}
|
|
if (r = this.tokenizer.list(e)) {
|
|
e = e.substring(r.raw.length), t.push(r);
|
|
continue;
|
|
}
|
|
if (r = this.tokenizer.html(e)) {
|
|
e = e.substring(r.raw.length), t.push(r);
|
|
continue;
|
|
}
|
|
if (r = this.tokenizer.def(e)) {
|
|
e = e.substring(r.raw.length);
|
|
let o = t.at(-1);
|
|
(o == null ? void 0 : o.type) === "paragraph" || (o == null ? void 0 : o.type) === "text" ? (o.raw += (o.raw.endsWith(`
|
|
`) ? "" : `
|
|
`) + r.raw, o.text += `
|
|
` + r.raw, this.inlineQueue.at(-1).src = o.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }, t.push(r));
|
|
continue;
|
|
}
|
|
if (r = this.tokenizer.table(e)) {
|
|
e = e.substring(r.raw.length), t.push(r);
|
|
continue;
|
|
}
|
|
if (r = this.tokenizer.lheading(e)) {
|
|
e = e.substring(r.raw.length), t.push(r);
|
|
continue;
|
|
}
|
|
let i = e;
|
|
if ((_c = this.options.extensions) == null ? void 0 : _c.startBlock) {
|
|
let o = 1 / 0, p = e.slice(1), a;
|
|
this.options.extensions.startBlock.forEach((u) => {
|
|
a = u.call({ lexer: this }, p), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
|
|
}), o < 1 / 0 && o >= 0 && (i = e.substring(0, o + 1));
|
|
}
|
|
if (this.state.top && (r = this.tokenizer.paragraph(i))) {
|
|
let o = t.at(-1);
|
|
n && (o == null ? void 0 : o.type) === "paragraph" ? (o.raw += (o.raw.endsWith(`
|
|
`) ? "" : `
|
|
`) + r.raw, o.text += `
|
|
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length);
|
|
continue;
|
|
}
|
|
if (r = this.tokenizer.text(e)) {
|
|
e = e.substring(r.raw.length);
|
|
let o = t.at(-1);
|
|
(o == null ? void 0 : o.type) === "text" ? (o.raw += (o.raw.endsWith(`
|
|
`) ? "" : `
|
|
`) + r.raw, o.text += `
|
|
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r);
|
|
continue;
|
|
}
|
|
if (e) {
|
|
this.infiniteLoopError(e.charCodeAt(0));
|
|
break;
|
|
}
|
|
}
|
|
return this.state.top = true, t;
|
|
}
|
|
inline(e, t = []) {
|
|
return this.inlineQueue.push({ src: e, tokens: t }), t;
|
|
}
|
|
inlineTokens(e, t = []) {
|
|
var _a2, _b, _c, _d, _e2;
|
|
this.tokenizer.lexer = this;
|
|
let n = e;
|
|
if (this.tokens.links) {
|
|
let o = Object.keys(this.tokens.links);
|
|
o.length > 0 && (n = n.replace(this.tokenizer.rules.inline.reflinkSearch, (p) => o.includes(p.slice(p.lastIndexOf("[") + 1, -1)) ? "[" + "a".repeat(p.length - 2) + "]" : p));
|
|
}
|
|
n = n.replace(this.tokenizer.rules.inline.anyPunctuation, "++"), n = n.replace(this.tokenizer.rules.inline.blockSkip, (o, p, a) => {
|
|
let u = a ? a.length : 0;
|
|
return o.slice(0, u) + "[" + "a".repeat(o.length - u - 2) + "]";
|
|
}), n = ((_b = (_a2 = this.options.hooks) == null ? void 0 : _a2.emStrongMask) == null ? void 0 : _b.call({ lexer: this }, n)) ?? n;
|
|
let s = false, r = "", i = 1 / 0;
|
|
for (; e; ) {
|
|
if (e.length < i) i = e.length;
|
|
else {
|
|
this.infiniteLoopError(e.charCodeAt(0));
|
|
break;
|
|
}
|
|
s || (r = ""), s = false;
|
|
let o;
|
|
if ((_d = (_c = this.options.extensions) == null ? void 0 : _c.inline) == null ? void 0 : _d.some((a) => (o = a.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), true) : false)) continue;
|
|
if (o = this.tokenizer.escape(e)) {
|
|
e = e.substring(o.raw.length), t.push(o);
|
|
continue;
|
|
}
|
|
if (o = this.tokenizer.tag(e)) {
|
|
e = e.substring(o.raw.length), t.push(o);
|
|
continue;
|
|
}
|
|
if (o = this.tokenizer.link(e)) {
|
|
e = e.substring(o.raw.length), t.push(o);
|
|
continue;
|
|
}
|
|
if (o = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
e = e.substring(o.raw.length);
|
|
let a = t.at(-1);
|
|
o.type === "text" && (a == null ? void 0 : a.type) === "text" ? (a.raw += o.raw, a.text += o.text) : t.push(o);
|
|
continue;
|
|
}
|
|
if (o = this.tokenizer.emStrong(e, n, r)) {
|
|
e = e.substring(o.raw.length), t.push(o);
|
|
continue;
|
|
}
|
|
if (o = this.tokenizer.codespan(e)) {
|
|
e = e.substring(o.raw.length), t.push(o);
|
|
continue;
|
|
}
|
|
if (o = this.tokenizer.br(e)) {
|
|
e = e.substring(o.raw.length), t.push(o);
|
|
continue;
|
|
}
|
|
if (o = this.tokenizer.del(e, n, r)) {
|
|
e = e.substring(o.raw.length), t.push(o);
|
|
continue;
|
|
}
|
|
if (o = this.tokenizer.autolink(e)) {
|
|
e = e.substring(o.raw.length), t.push(o);
|
|
continue;
|
|
}
|
|
if (!this.state.inLink && (o = this.tokenizer.url(e))) {
|
|
e = e.substring(o.raw.length), t.push(o);
|
|
continue;
|
|
}
|
|
let p = e;
|
|
if ((_e2 = this.options.extensions) == null ? void 0 : _e2.startInline) {
|
|
let a = 1 / 0, u = e.slice(1), c;
|
|
this.options.extensions.startInline.forEach((h) => {
|
|
c = h.call({ lexer: this }, u), typeof c == "number" && c >= 0 && (a = Math.min(a, c));
|
|
}), a < 1 / 0 && a >= 0 && (p = e.substring(0, a + 1));
|
|
}
|
|
if (o = this.tokenizer.inlineText(p)) {
|
|
e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (r = o.raw.slice(-1)), s = true;
|
|
let a = t.at(-1);
|
|
(a == null ? void 0 : a.type) === "text" ? (a.raw += o.raw, a.text += o.text) : t.push(o);
|
|
continue;
|
|
}
|
|
if (e) {
|
|
this.infiniteLoopError(e.charCodeAt(0));
|
|
break;
|
|
}
|
|
}
|
|
return t;
|
|
}
|
|
infiniteLoopError(e) {
|
|
let t = "Infinite loop on byte: " + e;
|
|
if (this.options.silent) console.error(t);
|
|
else throw new Error(t);
|
|
}
|
|
};
|
|
var P = class {
|
|
constructor(e) {
|
|
__publicField(this, "options");
|
|
__publicField(this, "parser");
|
|
this.options = e || R;
|
|
}
|
|
space(e) {
|
|
return "";
|
|
}
|
|
code({ text: e, lang: t, escaped: n }) {
|
|
var _a2;
|
|
let s = (_a2 = (t || "").match(m.notSpaceStart)) == null ? void 0 : _a2[0], r = e.replace(m.endingNewline, "") + `
|
|
`;
|
|
return s ? '<pre><code class="language-' + O(s) + '">' + (n ? r : O(r, true)) + `</code></pre>
|
|
` : "<pre><code>" + (n ? r : O(r, true)) + `</code></pre>
|
|
`;
|
|
}
|
|
blockquote({ tokens: e }) {
|
|
return `<blockquote>
|
|
${this.parser.parse(e)}</blockquote>
|
|
`;
|
|
}
|
|
html({ text: e }) {
|
|
return e;
|
|
}
|
|
def(e) {
|
|
return "";
|
|
}
|
|
heading({ tokens: e, depth: t }) {
|
|
return `<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
`;
|
|
}
|
|
hr(e) {
|
|
return `<hr>
|
|
`;
|
|
}
|
|
list(e) {
|
|
let t = e.ordered, n = e.start, s = "";
|
|
for (let o = 0; o < e.items.length; o++) {
|
|
let p = e.items[o];
|
|
s += this.listitem(p);
|
|
}
|
|
let r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
return "<" + r + i + `>
|
|
` + s + "</" + r + `>
|
|
`;
|
|
}
|
|
listitem(e) {
|
|
return `<li>${this.parser.parse(e.tokens)}</li>
|
|
`;
|
|
}
|
|
checkbox({ checked: e }) {
|
|
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
|
|
}
|
|
paragraph({ tokens: e }) {
|
|
return `<p>${this.parser.parseInline(e)}</p>
|
|
`;
|
|
}
|
|
table(e) {
|
|
let t = "", n = "";
|
|
for (let r = 0; r < e.header.length; r++) n += this.tablecell(e.header[r]);
|
|
t += this.tablerow({ text: n });
|
|
let s = "";
|
|
for (let r = 0; r < e.rows.length; r++) {
|
|
let i = e.rows[r];
|
|
n = "";
|
|
for (let o = 0; o < i.length; o++) n += this.tablecell(i[o]);
|
|
s += this.tablerow({ text: n });
|
|
}
|
|
return s && (s = `<tbody>${s}</tbody>`), `<table>
|
|
<thead>
|
|
` + t + `</thead>
|
|
` + s + `</table>
|
|
`;
|
|
}
|
|
tablerow({ text: e }) {
|
|
return `<tr>
|
|
${e}</tr>
|
|
`;
|
|
}
|
|
tablecell(e) {
|
|
let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
|
|
return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
|
|
`;
|
|
}
|
|
strong({ tokens: e }) {
|
|
return `<strong>${this.parser.parseInline(e)}</strong>`;
|
|
}
|
|
em({ tokens: e }) {
|
|
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
}
|
|
codespan({ text: e }) {
|
|
return `<code>${O(e, true)}</code>`;
|
|
}
|
|
br(e) {
|
|
return "<br>";
|
|
}
|
|
del({ tokens: e }) {
|
|
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
}
|
|
link({ href: e, title: t, tokens: n }) {
|
|
let s = this.parser.parseInline(n), r = Y(e);
|
|
if (r === null) return s;
|
|
e = r;
|
|
let i = '<a href="' + e + '"';
|
|
return t && (i += ' title="' + O(t) + '"'), i += ">" + s + "</a>", i;
|
|
}
|
|
image({ href: e, title: t, text: n, tokens: s }) {
|
|
s && (n = this.parser.parseInline(s, this.parser.textRenderer));
|
|
let r = Y(e);
|
|
if (r === null) return O(n);
|
|
e = r;
|
|
let i = `<img src="${e}" alt="${O(n)}"`;
|
|
return t && (i += ` title="${O(t)}"`), i += ">", i;
|
|
}
|
|
text(e) {
|
|
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : O(e.text);
|
|
}
|
|
};
|
|
var L = class {
|
|
strong({ text: e }) {
|
|
return e;
|
|
}
|
|
em({ text: e }) {
|
|
return e;
|
|
}
|
|
codespan({ text: e }) {
|
|
return e;
|
|
}
|
|
del({ text: e }) {
|
|
return e;
|
|
}
|
|
html({ text: e }) {
|
|
return e;
|
|
}
|
|
text({ text: e }) {
|
|
return e;
|
|
}
|
|
link({ text: e }) {
|
|
return "" + e;
|
|
}
|
|
image({ text: e }) {
|
|
return "" + e;
|
|
}
|
|
br() {
|
|
return "";
|
|
}
|
|
checkbox({ raw: e }) {
|
|
return e;
|
|
}
|
|
};
|
|
var b = class l2 {
|
|
constructor(e) {
|
|
__publicField(this, "options");
|
|
__publicField(this, "renderer");
|
|
__publicField(this, "textRenderer");
|
|
this.options = e || R, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L();
|
|
}
|
|
static parse(e, t) {
|
|
return new l2(t).parse(e);
|
|
}
|
|
static parseInline(e, t) {
|
|
return new l2(t).parseInline(e);
|
|
}
|
|
parse(e) {
|
|
var _a2, _b;
|
|
this.renderer.parser = this;
|
|
let t = "";
|
|
for (let n = 0; n < e.length; n++) {
|
|
let s = e[n];
|
|
if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b[s.type]) {
|
|
let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(i.type)) {
|
|
t += o || "";
|
|
continue;
|
|
}
|
|
}
|
|
let r = s;
|
|
switch (r.type) {
|
|
case "space": {
|
|
t += this.renderer.space(r);
|
|
break;
|
|
}
|
|
case "hr": {
|
|
t += this.renderer.hr(r);
|
|
break;
|
|
}
|
|
case "heading": {
|
|
t += this.renderer.heading(r);
|
|
break;
|
|
}
|
|
case "code": {
|
|
t += this.renderer.code(r);
|
|
break;
|
|
}
|
|
case "table": {
|
|
t += this.renderer.table(r);
|
|
break;
|
|
}
|
|
case "blockquote": {
|
|
t += this.renderer.blockquote(r);
|
|
break;
|
|
}
|
|
case "list": {
|
|
t += this.renderer.list(r);
|
|
break;
|
|
}
|
|
case "checkbox": {
|
|
t += this.renderer.checkbox(r);
|
|
break;
|
|
}
|
|
case "html": {
|
|
t += this.renderer.html(r);
|
|
break;
|
|
}
|
|
case "def": {
|
|
t += this.renderer.def(r);
|
|
break;
|
|
}
|
|
case "paragraph": {
|
|
t += this.renderer.paragraph(r);
|
|
break;
|
|
}
|
|
case "text": {
|
|
t += this.renderer.text(r);
|
|
break;
|
|
}
|
|
default: {
|
|
let i = 'Token with "' + r.type + '" type was not found.';
|
|
if (this.options.silent) return console.error(i), "";
|
|
throw new Error(i);
|
|
}
|
|
}
|
|
}
|
|
return t;
|
|
}
|
|
parseInline(e, t = this.renderer) {
|
|
var _a2, _b;
|
|
this.renderer.parser = this;
|
|
let n = "";
|
|
for (let s = 0; s < e.length; s++) {
|
|
let r = e[s];
|
|
if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b[r.type]) {
|
|
let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
|
|
if (o !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
|
|
n += o || "";
|
|
continue;
|
|
}
|
|
}
|
|
let i = r;
|
|
switch (i.type) {
|
|
case "escape": {
|
|
n += t.text(i);
|
|
break;
|
|
}
|
|
case "html": {
|
|
n += t.html(i);
|
|
break;
|
|
}
|
|
case "link": {
|
|
n += t.link(i);
|
|
break;
|
|
}
|
|
case "image": {
|
|
n += t.image(i);
|
|
break;
|
|
}
|
|
case "checkbox": {
|
|
n += t.checkbox(i);
|
|
break;
|
|
}
|
|
case "strong": {
|
|
n += t.strong(i);
|
|
break;
|
|
}
|
|
case "em": {
|
|
n += t.em(i);
|
|
break;
|
|
}
|
|
case "codespan": {
|
|
n += t.codespan(i);
|
|
break;
|
|
}
|
|
case "br": {
|
|
n += t.br(i);
|
|
break;
|
|
}
|
|
case "del": {
|
|
n += t.del(i);
|
|
break;
|
|
}
|
|
case "text": {
|
|
n += t.text(i);
|
|
break;
|
|
}
|
|
default: {
|
|
let o = 'Token with "' + i.type + '" type was not found.';
|
|
if (this.options.silent) return console.error(o), "";
|
|
throw new Error(o);
|
|
}
|
|
}
|
|
}
|
|
return n;
|
|
}
|
|
};
|
|
var _a;
|
|
var S = (_a = class {
|
|
constructor(e) {
|
|
__publicField(this, "options");
|
|
__publicField(this, "block");
|
|
this.options = e || R;
|
|
}
|
|
preprocess(e) {
|
|
return e;
|
|
}
|
|
postprocess(e) {
|
|
return e;
|
|
}
|
|
processAllTokens(e) {
|
|
return e;
|
|
}
|
|
emStrongMask(e) {
|
|
return e;
|
|
}
|
|
provideLexer(e = this.block) {
|
|
return e ? x.lex : x.lexInline;
|
|
}
|
|
provideParser(e = this.block) {
|
|
return e ? b.parse : b.parseInline;
|
|
}
|
|
}, __publicField(_a, "passThroughHooks", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"])), __publicField(_a, "passThroughHooksRespectAsync", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"])), _a);
|
|
var Z = class {
|
|
constructor(...e) {
|
|
__publicField(this, "defaults", C());
|
|
__publicField(this, "options", this.setOptions);
|
|
__publicField(this, "parse", this.parseMarkdown(true));
|
|
__publicField(this, "parseInline", this.parseMarkdown(false));
|
|
__publicField(this, "Parser", b);
|
|
__publicField(this, "Renderer", P);
|
|
__publicField(this, "TextRenderer", L);
|
|
__publicField(this, "Lexer", x);
|
|
__publicField(this, "Tokenizer", y);
|
|
__publicField(this, "Hooks", S);
|
|
this.use(...e);
|
|
}
|
|
walkTokens(e, t) {
|
|
var _a2, _b;
|
|
let n = [];
|
|
for (let s of e) switch (n = n.concat(t.call(this, s)), s.type) {
|
|
case "table": {
|
|
let r = s;
|
|
for (let i of r.header) n = n.concat(this.walkTokens(i.tokens, t));
|
|
for (let i of r.rows) for (let o of i) n = n.concat(this.walkTokens(o.tokens, t));
|
|
break;
|
|
}
|
|
case "list": {
|
|
let r = s;
|
|
n = n.concat(this.walkTokens(r.items, t));
|
|
break;
|
|
}
|
|
default: {
|
|
let r = s;
|
|
((_b = (_a2 = this.defaults.extensions) == null ? void 0 : _a2.childTokens) == null ? void 0 : _b[r.type]) ? this.defaults.extensions.childTokens[r.type].forEach((i) => {
|
|
let o = r[i].flat(1 / 0);
|
|
n = n.concat(this.walkTokens(o, t));
|
|
}) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, t)));
|
|
}
|
|
}
|
|
return n;
|
|
}
|
|
use(...e) {
|
|
let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
return e.forEach((n) => {
|
|
let s = { ...n };
|
|
if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
|
|
if (!r.name) throw new Error("extension name required");
|
|
if ("renderer" in r) {
|
|
let i = t.renderers[r.name];
|
|
i ? t.renderers[r.name] = function(...o) {
|
|
let p = r.renderer.apply(this, o);
|
|
return p === false && (p = i.apply(this, o)), p;
|
|
} : t.renderers[r.name] = r.renderer;
|
|
}
|
|
if ("tokenizer" in r) {
|
|
if (!r.level || r.level !== "block" && r.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
|
|
let i = t[r.level];
|
|
i ? i.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start]));
|
|
}
|
|
"childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
|
|
}), s.extensions = t), n.renderer) {
|
|
let r = this.defaults.renderer || new P(this.defaults);
|
|
for (let i in n.renderer) {
|
|
if (!(i in r)) throw new Error(`renderer '${i}' does not exist`);
|
|
if (["options", "parser"].includes(i)) continue;
|
|
let o = i, p = n.renderer[o], a = r[o];
|
|
r[o] = (...u) => {
|
|
let c = p.apply(r, u);
|
|
return c === false && (c = a.apply(r, u)), c || "";
|
|
};
|
|
}
|
|
s.renderer = r;
|
|
}
|
|
if (n.tokenizer) {
|
|
let r = this.defaults.tokenizer || new y(this.defaults);
|
|
for (let i in n.tokenizer) {
|
|
if (!(i in r)) throw new Error(`tokenizer '${i}' does not exist`);
|
|
if (["options", "rules", "lexer"].includes(i)) continue;
|
|
let o = i, p = n.tokenizer[o], a = r[o];
|
|
r[o] = (...u) => {
|
|
let c = p.apply(r, u);
|
|
return c === false && (c = a.apply(r, u)), c;
|
|
};
|
|
}
|
|
s.tokenizer = r;
|
|
}
|
|
if (n.hooks) {
|
|
let r = this.defaults.hooks || new S();
|
|
for (let i in n.hooks) {
|
|
if (!(i in r)) throw new Error(`hook '${i}' does not exist`);
|
|
if (["options", "block"].includes(i)) continue;
|
|
let o = i, p = n.hooks[o], a = r[o];
|
|
S.passThroughHooks.has(i) ? r[o] = (u) => {
|
|
if (this.defaults.async && S.passThroughHooksRespectAsync.has(i)) return (async () => {
|
|
let h = await p.call(r, u);
|
|
return a.call(r, h);
|
|
})();
|
|
let c = p.call(r, u);
|
|
return a.call(r, c);
|
|
} : r[o] = (...u) => {
|
|
if (this.defaults.async) return (async () => {
|
|
let h = await p.apply(r, u);
|
|
return h === false && (h = await a.apply(r, u)), h;
|
|
})();
|
|
let c = p.apply(r, u);
|
|
return c === false && (c = a.apply(r, u)), c;
|
|
};
|
|
}
|
|
s.hooks = r;
|
|
}
|
|
if (n.walkTokens) {
|
|
let r = this.defaults.walkTokens, i = n.walkTokens;
|
|
s.walkTokens = function(o) {
|
|
let p = [];
|
|
return p.push(i.call(this, o)), r && (p = p.concat(r.call(this, o))), p;
|
|
};
|
|
}
|
|
this.defaults = { ...this.defaults, ...s };
|
|
}), this;
|
|
}
|
|
setOptions(e) {
|
|
return this.defaults = { ...this.defaults, ...e }, this;
|
|
}
|
|
lexer(e, t) {
|
|
return x.lex(e, t ?? this.defaults);
|
|
}
|
|
parser(e, t) {
|
|
return b.parse(e, t ?? this.defaults);
|
|
}
|
|
parseMarkdown(e) {
|
|
return (n, s) => {
|
|
let r = { ...s }, i = { ...this.defaults, ...r }, o = this.onError(!!i.silent, !!i.async);
|
|
if (this.defaults.async === true && r.async === false) return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
|
|
if (typeof n > "u" || n === null) return o(new Error("marked(): input parameter is undefined or null"));
|
|
if (typeof n != "string") return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
|
|
let p = i.hooks ? await i.hooks.preprocess(n) : n, u = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(p, i), c = i.hooks ? await i.hooks.processAllTokens(u) : u;
|
|
i.walkTokens && await Promise.all(this.walkTokens(c, i.walkTokens));
|
|
let d = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(c, i);
|
|
return i.hooks ? await i.hooks.postprocess(d) : d;
|
|
})().catch(o);
|
|
try {
|
|
i.hooks && (n = i.hooks.preprocess(n));
|
|
let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
|
|
i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
|
|
let c = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
|
|
return i.hooks && (c = i.hooks.postprocess(c)), c;
|
|
} catch (p) {
|
|
return o(p);
|
|
}
|
|
};
|
|
}
|
|
onError(e, t) {
|
|
return (n) => {
|
|
if (n.message += `
|
|
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
let s = "<p>An error occurred:</p><pre>" + O(n.message + "", true) + "</pre>";
|
|
return t ? Promise.resolve(s) : s;
|
|
}
|
|
if (t) return Promise.reject(n);
|
|
throw n;
|
|
};
|
|
}
|
|
};
|
|
var E = new Z();
|
|
function f(l3, e) {
|
|
return E.parse(l3, e);
|
|
}
|
|
f.options = f.setOptions = function(l3) {
|
|
return E.setOptions(l3), f.defaults = E.defaults, j(f.defaults), f;
|
|
};
|
|
f.getDefaults = C;
|
|
f.defaults = R;
|
|
function kt(...l3) {
|
|
return E.use(...l3), f.defaults = E.defaults, j(f.defaults), f;
|
|
}
|
|
f.use = kt;
|
|
f.walkTokens = function(l3, e) {
|
|
return E.walkTokens(l3, e);
|
|
};
|
|
f.parseInline = E.parseInline;
|
|
f.Parser = b;
|
|
f.parser = b.parse;
|
|
f.Renderer = P;
|
|
f.TextRenderer = L;
|
|
f.Lexer = x;
|
|
f.lexer = x.lex;
|
|
f.Tokenizer = y;
|
|
f.Hooks = S;
|
|
f.parse = f;
|
|
var nn = f.options;
|
|
var rn = f.setOptions;
|
|
var sn = f.walkTokens;
|
|
var on = f.parseInline;
|
|
var an = f;
|
|
var ln = b.parse;
|
|
var pn = x.lex;
|
|
export {
|
|
S as Hooks,
|
|
x as Lexer,
|
|
Z as Marked,
|
|
b as Parser,
|
|
P as Renderer,
|
|
L as TextRenderer,
|
|
y as Tokenizer,
|
|
R as defaults,
|
|
C as getDefaults,
|
|
pn as lexer,
|
|
f as marked,
|
|
nn as options,
|
|
an as parse,
|
|
on as parseInline,
|
|
ln as parser,
|
|
rn as setOptions,
|
|
kt as use,
|
|
sn as walkTokens
|
|
};
|
|
//# sourceMappingURL=marked.js.map
|