@ijfw/install 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/ijfw.js +1324 -8
- package/docs/GUIDE.md +556 -0
- package/docs/guide/assets/README.md +11 -0
- package/docs/guide/assets/dashboard.png +0 -0
- package/docs/guide/assets/memory-recall.svg +31 -0
- package/docs/guide/assets/session-receipt.svg +30 -0
- package/docs/guide/assets/trident-demo.svg +36 -0
- package/package.json +6 -4
package/dist/ijfw.js
CHANGED
|
@@ -40,11 +40,11 @@ async function runPreflight(gates, ctx) {
|
|
|
40
40
|
${c.bold}IJFW Preflight${c.reset} -- ${gates.length} gates
|
|
41
41
|
`);
|
|
42
42
|
}
|
|
43
|
-
const parallelGates = gates.filter((
|
|
44
|
-
const serialGates = gates.filter((
|
|
43
|
+
const parallelGates = gates.filter((g2) => g2.parallel !== false);
|
|
44
|
+
const serialGates = gates.filter((g2) => g2.parallel === false);
|
|
45
45
|
if (parallelGates.length > 0) {
|
|
46
46
|
if (!ctx.json) console.log(`${c.dim} Running ${parallelGates.length} gate(s) in parallel...${c.reset}`);
|
|
47
|
-
const parallelResults = await Promise.all(parallelGates.map((
|
|
47
|
+
const parallelResults = await Promise.all(parallelGates.map((g2) => g2.run(ctx)));
|
|
48
48
|
for (let i = 0; i < parallelResults.length; i++) {
|
|
49
49
|
results.push(parallelResults[i]);
|
|
50
50
|
if (!ctx.json) printGateResult(parallelResults[i], results.length, gates.length);
|
|
@@ -65,7 +65,7 @@ ${c.bold}IJFW Preflight${c.reset} -- ${gates.length} gates
|
|
|
65
65
|
}
|
|
66
66
|
const totalMs = Date.now() - t0;
|
|
67
67
|
const blockingFailures = results.filter((r) => {
|
|
68
|
-
const gate = gates.find((
|
|
68
|
+
const gate = gates.find((g2) => g2.name === r.name);
|
|
69
69
|
return r.status === "FAIL" && gate && gate.severity === "blocking";
|
|
70
70
|
});
|
|
71
71
|
const outcome = blockingFailures.length > 0 ? "fail" : "pass";
|
|
@@ -1151,11 +1151,1270 @@ var init_preflight = __esm({
|
|
|
1151
1151
|
}
|
|
1152
1152
|
});
|
|
1153
1153
|
|
|
1154
|
+
// node_modules/marked/lib/marked.esm.js
|
|
1155
|
+
var marked_esm_exports = {};
|
|
1156
|
+
__export(marked_esm_exports, {
|
|
1157
|
+
Hooks: () => P,
|
|
1158
|
+
Lexer: () => x,
|
|
1159
|
+
Marked: () => D,
|
|
1160
|
+
Parser: () => b,
|
|
1161
|
+
Renderer: () => y,
|
|
1162
|
+
TextRenderer: () => L,
|
|
1163
|
+
Tokenizer: () => w,
|
|
1164
|
+
defaults: () => T,
|
|
1165
|
+
getDefaults: () => z,
|
|
1166
|
+
lexer: () => Vt,
|
|
1167
|
+
marked: () => g,
|
|
1168
|
+
options: () => jt,
|
|
1169
|
+
parse: () => Xt,
|
|
1170
|
+
parseInline: () => Wt,
|
|
1171
|
+
parser: () => Jt,
|
|
1172
|
+
setOptions: () => Ft,
|
|
1173
|
+
use: () => Ut,
|
|
1174
|
+
walkTokens: () => Kt
|
|
1175
|
+
});
|
|
1176
|
+
function z() {
|
|
1177
|
+
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
1178
|
+
}
|
|
1179
|
+
function G(l3) {
|
|
1180
|
+
T = l3;
|
|
1181
|
+
}
|
|
1182
|
+
function k(l3, e = "") {
|
|
1183
|
+
let t = typeof l3 == "string" ? l3 : l3.source, n = { replace: (s, r) => {
|
|
1184
|
+
let i = typeof r == "string" ? r : r.source;
|
|
1185
|
+
return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n;
|
|
1186
|
+
}, getRegex: () => new RegExp(t, e) };
|
|
1187
|
+
return n;
|
|
1188
|
+
}
|
|
1189
|
+
function O(l3, e) {
|
|
1190
|
+
if (e) {
|
|
1191
|
+
if (m.escapeTest.test(l3)) return l3.replace(m.escapeReplace, de);
|
|
1192
|
+
} else if (m.escapeTestNoEncode.test(l3)) return l3.replace(m.escapeReplaceNoEncode, de);
|
|
1193
|
+
return l3;
|
|
1194
|
+
}
|
|
1195
|
+
function J(l3) {
|
|
1196
|
+
try {
|
|
1197
|
+
l3 = encodeURI(l3).replace(m.percentDecode, "%");
|
|
1198
|
+
} catch {
|
|
1199
|
+
return null;
|
|
1200
|
+
}
|
|
1201
|
+
return l3;
|
|
1202
|
+
}
|
|
1203
|
+
function V(l3, e) {
|
|
1204
|
+
let t = l3.replace(m.findPipe, (r, i, o) => {
|
|
1205
|
+
let u = false, a = i;
|
|
1206
|
+
for (; --a >= 0 && o[a] === "\\"; ) u = !u;
|
|
1207
|
+
return u ? "|" : " |";
|
|
1208
|
+
}), n = t.split(m.splitPipe), s = 0;
|
|
1209
|
+
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);
|
|
1210
|
+
else for (; n.length < e; ) n.push("");
|
|
1211
|
+
for (; s < n.length; s++) n[s] = n[s].trim().replace(m.slashPipe, "|");
|
|
1212
|
+
return n;
|
|
1213
|
+
}
|
|
1214
|
+
function $(l3, e, t) {
|
|
1215
|
+
let n = l3.length;
|
|
1216
|
+
if (n === 0) return "";
|
|
1217
|
+
let s = 0;
|
|
1218
|
+
for (; s < n; ) {
|
|
1219
|
+
let r = l3.charAt(n - s - 1);
|
|
1220
|
+
if (r === e && !t) s++;
|
|
1221
|
+
else if (r !== e && t) s++;
|
|
1222
|
+
else break;
|
|
1223
|
+
}
|
|
1224
|
+
return l3.slice(0, n - s);
|
|
1225
|
+
}
|
|
1226
|
+
function Y(l3) {
|
|
1227
|
+
let e = l3.split(`
|
|
1228
|
+
`), t = e.length - 1;
|
|
1229
|
+
for (; t >= 0 && m.blankLine.test(e[t]); ) t--;
|
|
1230
|
+
return e.length - t <= 2 ? l3 : e.slice(0, t + 1).join(`
|
|
1231
|
+
`);
|
|
1232
|
+
}
|
|
1233
|
+
function ge(l3, e) {
|
|
1234
|
+
if (l3.indexOf(e[1]) === -1) return -1;
|
|
1235
|
+
let t = 0;
|
|
1236
|
+
for (let n = 0; n < l3.length; n++) if (l3[n] === "\\") n++;
|
|
1237
|
+
else if (l3[n] === e[0]) t++;
|
|
1238
|
+
else if (l3[n] === e[1] && (t--, t < 0)) return n;
|
|
1239
|
+
return t > 0 ? -2 : -1;
|
|
1240
|
+
}
|
|
1241
|
+
function fe(l3, e = 0) {
|
|
1242
|
+
let t = e, n = "";
|
|
1243
|
+
for (let s of l3) if (s === " ") {
|
|
1244
|
+
let r = 4 - t % 4;
|
|
1245
|
+
n += " ".repeat(r), t += r;
|
|
1246
|
+
} else n += s, t++;
|
|
1247
|
+
return n;
|
|
1248
|
+
}
|
|
1249
|
+
function me(l3, e, t, n, s) {
|
|
1250
|
+
let r = e.href, i = e.title || null, o = l3[1].replace(s.other.outputLinkReplace, "$1");
|
|
1251
|
+
n.state.inLink = true;
|
|
1252
|
+
let u = { type: l3[0].charAt(0) === "!" ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: n.inlineTokens(o) };
|
|
1253
|
+
return n.state.inLink = false, u;
|
|
1254
|
+
}
|
|
1255
|
+
function rt(l3, e, t) {
|
|
1256
|
+
let n = l3.match(t.other.indentCodeCompensation);
|
|
1257
|
+
if (n === null) return e;
|
|
1258
|
+
let s = n[1];
|
|
1259
|
+
return e.split(`
|
|
1260
|
+
`).map((r) => {
|
|
1261
|
+
let i = r.match(t.other.beginningSpace);
|
|
1262
|
+
if (i === null) return r;
|
|
1263
|
+
let [o] = i;
|
|
1264
|
+
return o.length >= s.length ? r.slice(s.length) : r;
|
|
1265
|
+
}).join(`
|
|
1266
|
+
`);
|
|
1267
|
+
}
|
|
1268
|
+
function g(l3, e) {
|
|
1269
|
+
return M.parse(l3, e);
|
|
1270
|
+
}
|
|
1271
|
+
var T, _, Re, m, Te, Oe, we, I, ye, Q, ie, oe, Pe, j, Se, F, $e, Le, v, U, _e, ae, Me, K, re, ze, Ee, Ae, Ce, le, Ie, E, H, W, Be, ue, De, qe, ve, pe, He, Ze, ce, Ge, Ne, Qe, je, Fe, Ue, Ke, We, Xe, Je, q, Ve, he, ke, Ye, se, X, et, N, tt, B, A, nt, de, w, x, y, L, b, P, D, M, jt, Ft, Ut, Kt, Wt, Xt, Jt, Vt;
|
|
1272
|
+
var init_marked_esm = __esm({
|
|
1273
|
+
"node_modules/marked/lib/marked.esm.js"() {
|
|
1274
|
+
T = z();
|
|
1275
|
+
_ = { exec: () => null };
|
|
1276
|
+
Re = ((l3 = "") => {
|
|
1277
|
+
try {
|
|
1278
|
+
return !!new RegExp("(?<=1)(?<!1)" + l3);
|
|
1279
|
+
} catch {
|
|
1280
|
+
return false;
|
|
1281
|
+
}
|
|
1282
|
+
})();
|
|
1283
|
+
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: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}#`), htmlBeginRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}<(?:[a-z].*>|!--)`, "i"), blockquoteBeginRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}>`) };
|
|
1284
|
+
Te = /^(?:[ \t]*(?:\n|$))+/;
|
|
1285
|
+
Oe = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
1286
|
+
we = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
1287
|
+
I = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
1288
|
+
ye = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
1289
|
+
Q = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
|
|
1290
|
+
ie = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
|
|
1291
|
+
oe = k(ie).replace(/bull/g, Q).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}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
|
|
1292
|
+
Pe = k(ie).replace(/bull/g, Q).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}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
|
|
1293
|
+
j = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
|
|
1294
|
+
Se = /^[^\n]+/;
|
|
1295
|
+
F = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
|
|
1296
|
+
$e = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", F).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
|
|
1297
|
+
Le = k(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, Q).getRegex();
|
|
1298
|
+
v = "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";
|
|
1299
|
+
U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
1300
|
+
_e = k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\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", U).replace("tag", v).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
1301
|
+
ae = k(j).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex();
|
|
1302
|
+
Me = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ae).getRegex();
|
|
1303
|
+
K = { blockquote: Me, code: Oe, def: $e, fences: we, heading: ye, hr: I, html: _e, lheading: oe, list: Le, newline: Te, paragraph: ae, table: _, text: Se };
|
|
1304
|
+
re = k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex();
|
|
1305
|
+
ze = { ...K, lheading: Pe, table: re, paragraph: k(j).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", re).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex() };
|
|
1306
|
+
Ee = { ...K, html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", U).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: _, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: k(j).replace("hr", I).replace("heading", ` *#{1,6} *[^
|
|
1307
|
+
]`).replace("lheading", oe).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
|
|
1308
|
+
Ae = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
1309
|
+
Ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
1310
|
+
le = /^( {2,}|\\)\n(?!\s*$)/;
|
|
1311
|
+
Ie = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
1312
|
+
E = /[\p{P}\p{S}]/u;
|
|
1313
|
+
H = /[\s\p{P}\p{S}]/u;
|
|
1314
|
+
W = /[^\s\p{P}\p{S}]/u;
|
|
1315
|
+
Be = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, H).getRegex();
|
|
1316
|
+
ue = /(?!~)[\p{P}\p{S}]/u;
|
|
1317
|
+
De = /(?!~)[\s\p{P}\p{S}]/u;
|
|
1318
|
+
qe = /(?:[^\s\p{P}\p{S}]|~)/u;
|
|
1319
|
+
ve = k(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Re ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
|
|
1320
|
+
pe = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
|
|
1321
|
+
He = k(pe, "u").replace(/punct/g, E).getRegex();
|
|
1322
|
+
Ze = k(pe, "u").replace(/punct/g, ue).getRegex();
|
|
1323
|
+
ce = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
|
|
1324
|
+
Ge = k(ce, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, E).getRegex();
|
|
1325
|
+
Ne = k(ce, "gu").replace(/notPunctSpace/g, qe).replace(/punctSpace/g, De).replace(/punct/g, ue).getRegex();
|
|
1326
|
+
Qe = k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, E).getRegex();
|
|
1327
|
+
je = k(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, E).getRegex();
|
|
1328
|
+
Fe = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
|
|
1329
|
+
Ue = k(Fe, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, E).getRegex();
|
|
1330
|
+
Ke = k(/\\(punct)/, "gu").replace(/punct/g, E).getRegex();
|
|
1331
|
+
We = 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();
|
|
1332
|
+
Xe = k(U).replace("(?:-->|$)", "-->").getRegex();
|
|
1333
|
+
Je = 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", Xe).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
|
|
1334
|
+
q = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
|
|
1335
|
+
Ve = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
|
|
1336
|
+
he = k(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", F).getRegex();
|
|
1337
|
+
ke = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", F).getRegex();
|
|
1338
|
+
Ye = k("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink", ke).getRegex();
|
|
1339
|
+
se = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
|
|
1340
|
+
X = { _backpedal: _, anyPunctuation: Ke, autolink: We, blockSkip: ve, br: le, code: Ce, del: _, delLDelim: _, delRDelim: _, emStrongLDelim: He, emStrongRDelimAst: Ge, emStrongRDelimUnd: Qe, escape: Ae, link: Ve, nolink: ke, punctuation: Be, reflink: he, reflinkSearch: Ye, tag: Je, text: Ie, url: _ };
|
|
1341
|
+
et = { ...X, link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(), reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex() };
|
|
1342
|
+
N = { ...X, emStrongRDelimAst: Ne, emStrongLDelim: Ze, delLDelim: je, delRDelim: Ue, url: k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", se).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", se).getRegex() };
|
|
1343
|
+
tt = { ...N, br: k(le).replace("{2,}", "*").getRegex(), text: k(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
|
|
1344
|
+
B = { normal: K, gfm: ze, pedantic: Ee };
|
|
1345
|
+
A = { normal: X, gfm: N, breaks: tt, pedantic: et };
|
|
1346
|
+
nt = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
1347
|
+
de = (l3) => nt[l3];
|
|
1348
|
+
w = class {
|
|
1349
|
+
options;
|
|
1350
|
+
rules;
|
|
1351
|
+
lexer;
|
|
1352
|
+
constructor(e) {
|
|
1353
|
+
this.options = e || T;
|
|
1354
|
+
}
|
|
1355
|
+
space(e) {
|
|
1356
|
+
let t = this.rules.block.newline.exec(e);
|
|
1357
|
+
if (t && t[0].length > 0) return { type: "space", raw: t[0] };
|
|
1358
|
+
}
|
|
1359
|
+
code(e) {
|
|
1360
|
+
let t = this.rules.block.code.exec(e);
|
|
1361
|
+
if (t) {
|
|
1362
|
+
let n = this.options.pedantic ? t[0] : Y(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
|
|
1363
|
+
return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
fences(e) {
|
|
1367
|
+
let t = this.rules.block.fences.exec(e);
|
|
1368
|
+
if (t) {
|
|
1369
|
+
let n = t[0], s = rt(n, t[3] || "", this.rules);
|
|
1370
|
+
return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
heading(e) {
|
|
1374
|
+
let t = this.rules.block.heading.exec(e);
|
|
1375
|
+
if (t) {
|
|
1376
|
+
let n = t[2].trim();
|
|
1377
|
+
if (this.rules.other.endingHash.test(n)) {
|
|
1378
|
+
let s = $(n, "#");
|
|
1379
|
+
(this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
|
|
1380
|
+
}
|
|
1381
|
+
return { type: "heading", raw: $(t[0], `
|
|
1382
|
+
`), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
hr(e) {
|
|
1386
|
+
let t = this.rules.block.hr.exec(e);
|
|
1387
|
+
if (t) return { type: "hr", raw: $(t[0], `
|
|
1388
|
+
`) };
|
|
1389
|
+
}
|
|
1390
|
+
blockquote(e) {
|
|
1391
|
+
let t = this.rules.block.blockquote.exec(e);
|
|
1392
|
+
if (t) {
|
|
1393
|
+
let n = $(t[0], `
|
|
1394
|
+
`).split(`
|
|
1395
|
+
`), s = "", r = "", i = [];
|
|
1396
|
+
for (; n.length > 0; ) {
|
|
1397
|
+
let o = false, u = [], a;
|
|
1398
|
+
for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) u.push(n[a]), o = true;
|
|
1399
|
+
else if (!o) u.push(n[a]);
|
|
1400
|
+
else break;
|
|
1401
|
+
n = n.slice(a);
|
|
1402
|
+
let c2 = u.join(`
|
|
1403
|
+
`), p = c2.replace(this.rules.other.blockquoteSetextReplace, `
|
|
1404
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
1405
|
+
s = s ? `${s}
|
|
1406
|
+
${c2}` : c2, r = r ? `${r}
|
|
1407
|
+
${p}` : p;
|
|
1408
|
+
let d = this.lexer.state.top;
|
|
1409
|
+
if (this.lexer.state.top = true, this.lexer.blockTokens(p, i, true), this.lexer.state.top = d, n.length === 0) break;
|
|
1410
|
+
let h = i.at(-1);
|
|
1411
|
+
if (h?.type === "code") break;
|
|
1412
|
+
if (h?.type === "blockquote") {
|
|
1413
|
+
let R = h, f = R.raw + `
|
|
1414
|
+
` + n.join(`
|
|
1415
|
+
`), S = this.blockquote(f);
|
|
1416
|
+
i[i.length - 1] = S, s = s.substring(0, s.length - R.raw.length) + S.raw, r = r.substring(0, r.length - R.text.length) + S.text;
|
|
1417
|
+
break;
|
|
1418
|
+
} else if (h?.type === "list") {
|
|
1419
|
+
let R = h, f = R.raw + `
|
|
1420
|
+
` + n.join(`
|
|
1421
|
+
`), S = this.list(f);
|
|
1422
|
+
i[i.length - 1] = S, s = s.substring(0, s.length - h.raw.length) + S.raw, r = r.substring(0, r.length - R.raw.length) + S.raw, n = f.substring(i.at(-1).raw.length).split(`
|
|
1423
|
+
`);
|
|
1424
|
+
continue;
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
return { type: "blockquote", raw: s, tokens: i, text: r };
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
list(e) {
|
|
1431
|
+
let t = this.rules.block.list.exec(e);
|
|
1432
|
+
if (t) {
|
|
1433
|
+
let n = t[1].trim(), s = n.length > 1, r = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: false, items: [] };
|
|
1434
|
+
n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
|
|
1435
|
+
let i = this.rules.other.listItemRegex(n), o = false;
|
|
1436
|
+
for (; e; ) {
|
|
1437
|
+
let a = false, c2 = "", p = "";
|
|
1438
|
+
if (!(t = i.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
1439
|
+
c2 = t[0], e = e.substring(c2.length);
|
|
1440
|
+
let d = fe(t[2].split(`
|
|
1441
|
+
`, 1)[0], t[1].length), h = e.split(`
|
|
1442
|
+
`, 1)[0], R = !d.trim(), f = 0;
|
|
1443
|
+
if (this.options.pedantic ? (f = 2, p = d.trimStart()) : R ? f = t[1].length + 1 : (f = d.search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, p = d.slice(f), f += t[1].length), R && this.rules.other.blankLine.test(h) && (c2 += h + `
|
|
1444
|
+
`, e = e.substring(h.length + 1), a = true), !a) {
|
|
1445
|
+
let S = this.rules.other.nextBulletRegex(f), ee = this.rules.other.hrRegex(f), te = this.rules.other.fencesBeginRegex(f), ne = this.rules.other.headingBeginRegex(f), xe = this.rules.other.htmlBeginRegex(f), be = this.rules.other.blockquoteBeginRegex(f);
|
|
1446
|
+
for (; e; ) {
|
|
1447
|
+
let Z = e.split(`
|
|
1448
|
+
`, 1)[0], C;
|
|
1449
|
+
if (h = Z, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), C = h) : C = h.replace(this.rules.other.tabCharGlobal, " "), te.test(h) || ne.test(h) || xe.test(h) || be.test(h) || S.test(h) || ee.test(h)) break;
|
|
1450
|
+
if (C.search(this.rules.other.nonSpaceChar) >= f || !h.trim()) p += `
|
|
1451
|
+
` + C.slice(f);
|
|
1452
|
+
else {
|
|
1453
|
+
if (R || d.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || te.test(d) || ne.test(d) || ee.test(d)) break;
|
|
1454
|
+
p += `
|
|
1455
|
+
` + h;
|
|
1456
|
+
}
|
|
1457
|
+
R = !h.trim(), c2 += Z + `
|
|
1458
|
+
`, e = e.substring(Z.length + 1), d = C.slice(f);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(c2) && (o = true)), r.items.push({ type: "list_item", raw: c2, task: !!this.options.gfm && this.rules.other.listIsTask.test(p), loose: false, text: p, tokens: [] }), r.raw += c2;
|
|
1462
|
+
}
|
|
1463
|
+
let u = r.items.at(-1);
|
|
1464
|
+
if (u) u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd();
|
|
1465
|
+
else return;
|
|
1466
|
+
r.raw = r.raw.trimEnd();
|
|
1467
|
+
for (let a of r.items) {
|
|
1468
|
+
if (this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []), a.task) {
|
|
1469
|
+
if (a.text = a.text.replace(this.rules.other.listReplaceTask, ""), a.tokens[0]?.type === "text" || a.tokens[0]?.type === "paragraph") {
|
|
1470
|
+
a.tokens[0].raw = a.tokens[0].raw.replace(this.rules.other.listReplaceTask, ""), a.tokens[0].text = a.tokens[0].text.replace(this.rules.other.listReplaceTask, "");
|
|
1471
|
+
for (let p = this.lexer.inlineQueue.length - 1; p >= 0; p--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[p].src)) {
|
|
1472
|
+
this.lexer.inlineQueue[p].src = this.lexer.inlineQueue[p].src.replace(this.rules.other.listReplaceTask, "");
|
|
1473
|
+
break;
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
let c2 = this.rules.other.listTaskCheckbox.exec(a.raw);
|
|
1477
|
+
if (c2) {
|
|
1478
|
+
let p = { type: "checkbox", raw: c2[0] + " ", checked: c2[0] !== "[ ]" };
|
|
1479
|
+
a.checked = p.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 = p.raw + a.tokens[0].raw, a.tokens[0].text = p.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(p)) : a.tokens.unshift({ type: "paragraph", raw: p.raw, text: p.raw, tokens: [p] }) : a.tokens.unshift(p);
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
if (!r.loose) {
|
|
1483
|
+
let c2 = a.tokens.filter((d) => d.type === "space"), p = c2.length > 0 && c2.some((d) => this.rules.other.anyLine.test(d.raw));
|
|
1484
|
+
r.loose = p;
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
if (r.loose) for (let a of r.items) {
|
|
1488
|
+
a.loose = true;
|
|
1489
|
+
for (let c2 of a.tokens) c2.type === "text" && (c2.type = "paragraph");
|
|
1490
|
+
}
|
|
1491
|
+
return r;
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
html(e) {
|
|
1495
|
+
let t = this.rules.block.html.exec(e);
|
|
1496
|
+
if (t) {
|
|
1497
|
+
let n = Y(t[0]);
|
|
1498
|
+
return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
def(e) {
|
|
1502
|
+
let t = this.rules.block.def.exec(e);
|
|
1503
|
+
if (t) {
|
|
1504
|
+
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];
|
|
1505
|
+
return { type: "def", tag: n, raw: $(t[0], `
|
|
1506
|
+
`), href: s, title: r };
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
table(e) {
|
|
1510
|
+
let t = this.rules.block.table.exec(e);
|
|
1511
|
+
if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
|
|
1512
|
+
let n = V(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
1513
|
+
`) : [], i = { type: "table", raw: $(t[0], `
|
|
1514
|
+
`), header: [], align: [], rows: [] };
|
|
1515
|
+
if (n.length === s.length) {
|
|
1516
|
+
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);
|
|
1517
|
+
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] });
|
|
1518
|
+
for (let o of r) i.rows.push(V(o, i.header.length).map((u, a) => ({ text: u, tokens: this.lexer.inline(u), header: false, align: i.align[a] })));
|
|
1519
|
+
return i;
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
lheading(e) {
|
|
1523
|
+
let t = this.rules.block.lheading.exec(e);
|
|
1524
|
+
if (t) {
|
|
1525
|
+
let n = t[1].trim();
|
|
1526
|
+
return { type: "heading", raw: $(t[0], `
|
|
1527
|
+
`), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
paragraph(e) {
|
|
1531
|
+
let t = this.rules.block.paragraph.exec(e);
|
|
1532
|
+
if (t) {
|
|
1533
|
+
let n = t[1].charAt(t[1].length - 1) === `
|
|
1534
|
+
` ? t[1].slice(0, -1) : t[1];
|
|
1535
|
+
return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
text(e) {
|
|
1539
|
+
let t = this.rules.block.text.exec(e);
|
|
1540
|
+
if (t) return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
|
|
1541
|
+
}
|
|
1542
|
+
escape(e) {
|
|
1543
|
+
let t = this.rules.inline.escape.exec(e);
|
|
1544
|
+
if (t) return { type: "escape", raw: t[0], text: t[1] };
|
|
1545
|
+
}
|
|
1546
|
+
tag(e) {
|
|
1547
|
+
let t = this.rules.inline.tag.exec(e);
|
|
1548
|
+
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] };
|
|
1549
|
+
}
|
|
1550
|
+
link(e) {
|
|
1551
|
+
let t = this.rules.inline.link.exec(e);
|
|
1552
|
+
if (t) {
|
|
1553
|
+
let n = t[2].trim();
|
|
1554
|
+
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
|
|
1555
|
+
if (!this.rules.other.endAngleBracket.test(n)) return;
|
|
1556
|
+
let i = $(n.slice(0, -1), "\\");
|
|
1557
|
+
if ((n.length - i.length) % 2 === 0) return;
|
|
1558
|
+
} else {
|
|
1559
|
+
let i = ge(t[2], "()");
|
|
1560
|
+
if (i === -2) return;
|
|
1561
|
+
if (i > -1) {
|
|
1562
|
+
let u = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
|
|
1563
|
+
t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, u).trim(), t[3] = "";
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
let s = t[2], r = "";
|
|
1567
|
+
if (this.options.pedantic) {
|
|
1568
|
+
let i = this.rules.other.pedanticHrefTitle.exec(s);
|
|
1569
|
+
i && (s = i[1], r = i[3]);
|
|
1570
|
+
} else r = t[3] ? t[3].slice(1, -1) : "";
|
|
1571
|
+
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)), me(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);
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
reflink(e, t) {
|
|
1575
|
+
let n;
|
|
1576
|
+
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
1577
|
+
let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
|
|
1578
|
+
if (!r) {
|
|
1579
|
+
let i = n[0].charAt(0);
|
|
1580
|
+
return { type: "text", raw: i, text: i };
|
|
1581
|
+
}
|
|
1582
|
+
return me(n, r, n[0], this.lexer, this.rules);
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
emStrong(e, t, n = "") {
|
|
1586
|
+
let s = this.rules.inline.emStrongLDelim.exec(e);
|
|
1587
|
+
if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
|
|
1588
|
+
if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
1589
|
+
let i = [...s[0]].length - 1, o, u, a = i, c2 = 0, p = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
1590
|
+
for (p.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = p.exec(t)) !== null; ) {
|
|
1591
|
+
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o) continue;
|
|
1592
|
+
if (u = [...o].length, s[3] || s[4]) {
|
|
1593
|
+
a += u;
|
|
1594
|
+
continue;
|
|
1595
|
+
} else if ((s[5] || s[6]) && i % 3 && !((i + u) % 3)) {
|
|
1596
|
+
c2 += u;
|
|
1597
|
+
continue;
|
|
1598
|
+
}
|
|
1599
|
+
if (a -= u, a > 0) continue;
|
|
1600
|
+
u = Math.min(u, u + a + c2);
|
|
1601
|
+
let d = [...s[0]][0].length, h = e.slice(0, i + s.index + d + u);
|
|
1602
|
+
if (Math.min(i, u) % 2) {
|
|
1603
|
+
let f = h.slice(1, -1);
|
|
1604
|
+
return { type: "em", raw: h, text: f, tokens: this.lexer.inlineTokens(f) };
|
|
1605
|
+
}
|
|
1606
|
+
let R = h.slice(2, -2);
|
|
1607
|
+
return { type: "strong", raw: h, text: R, tokens: this.lexer.inlineTokens(R) };
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
codespan(e) {
|
|
1612
|
+
let t = this.rules.inline.code.exec(e);
|
|
1613
|
+
if (t) {
|
|
1614
|
+
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);
|
|
1615
|
+
return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
br(e) {
|
|
1619
|
+
let t = this.rules.inline.br.exec(e);
|
|
1620
|
+
if (t) return { type: "br", raw: t[0] };
|
|
1621
|
+
}
|
|
1622
|
+
del(e, t, n = "") {
|
|
1623
|
+
let s = this.rules.inline.delLDelim.exec(e);
|
|
1624
|
+
if (!s) return;
|
|
1625
|
+
if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
1626
|
+
let i = [...s[0]].length - 1, o, u, a = i, c2 = this.rules.inline.delRDelim;
|
|
1627
|
+
for (c2.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = c2.exec(t)) !== null; ) {
|
|
1628
|
+
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (u = [...o].length, u !== i)) continue;
|
|
1629
|
+
if (s[3] || s[4]) {
|
|
1630
|
+
a += u;
|
|
1631
|
+
continue;
|
|
1632
|
+
}
|
|
1633
|
+
if (a -= u, a > 0) continue;
|
|
1634
|
+
u = Math.min(u, u + a);
|
|
1635
|
+
let p = [...s[0]][0].length, d = e.slice(0, i + s.index + p + u), h = d.slice(i, -i);
|
|
1636
|
+
return { type: "del", raw: d, text: h, tokens: this.lexer.inlineTokens(h) };
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
autolink(e) {
|
|
1641
|
+
let t = this.rules.inline.autolink.exec(e);
|
|
1642
|
+
if (t) {
|
|
1643
|
+
let n, s;
|
|
1644
|
+
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 }] };
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
url(e) {
|
|
1648
|
+
let t;
|
|
1649
|
+
if (t = this.rules.inline.url.exec(e)) {
|
|
1650
|
+
let n, s;
|
|
1651
|
+
if (t[2] === "@") n = t[0], s = "mailto:" + n;
|
|
1652
|
+
else {
|
|
1653
|
+
let r;
|
|
1654
|
+
do
|
|
1655
|
+
r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
|
|
1656
|
+
while (r !== t[0]);
|
|
1657
|
+
n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
|
|
1658
|
+
}
|
|
1659
|
+
return { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
inlineText(e) {
|
|
1663
|
+
let t = this.rules.inline.text.exec(e);
|
|
1664
|
+
if (t) {
|
|
1665
|
+
let n = this.lexer.state.inRawBlock;
|
|
1666
|
+
return { type: "text", raw: t[0], text: t[0], escaped: n };
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
x = class l {
|
|
1671
|
+
tokens;
|
|
1672
|
+
options;
|
|
1673
|
+
state;
|
|
1674
|
+
inlineQueue;
|
|
1675
|
+
tokenizer;
|
|
1676
|
+
constructor(e) {
|
|
1677
|
+
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new w(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true };
|
|
1678
|
+
let t = { other: m, block: B.normal, inline: A.normal };
|
|
1679
|
+
this.options.pedantic ? (t.block = B.pedantic, t.inline = A.pedantic) : this.options.gfm && (t.block = B.gfm, this.options.breaks ? t.inline = A.breaks : t.inline = A.gfm), this.tokenizer.rules = t;
|
|
1680
|
+
}
|
|
1681
|
+
static get rules() {
|
|
1682
|
+
return { block: B, inline: A };
|
|
1683
|
+
}
|
|
1684
|
+
static lex(e, t) {
|
|
1685
|
+
return new l(t).lex(e);
|
|
1686
|
+
}
|
|
1687
|
+
static lexInline(e, t) {
|
|
1688
|
+
return new l(t).inlineTokens(e);
|
|
1689
|
+
}
|
|
1690
|
+
lex(e) {
|
|
1691
|
+
e = e.replace(m.carriageReturn, `
|
|
1692
|
+
`), this.blockTokens(e, this.tokens);
|
|
1693
|
+
for (let t = 0; t < this.inlineQueue.length; t++) {
|
|
1694
|
+
let n = this.inlineQueue[t];
|
|
1695
|
+
this.inlineTokens(n.src, n.tokens);
|
|
1696
|
+
}
|
|
1697
|
+
return this.inlineQueue = [], this.tokens;
|
|
1698
|
+
}
|
|
1699
|
+
blockTokens(e, t = [], n = false) {
|
|
1700
|
+
this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
|
|
1701
|
+
let s = 1 / 0;
|
|
1702
|
+
for (; e; ) {
|
|
1703
|
+
if (e.length < s) s = e.length;
|
|
1704
|
+
else {
|
|
1705
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
1706
|
+
break;
|
|
1707
|
+
}
|
|
1708
|
+
let r;
|
|
1709
|
+
if (this.options.extensions?.block?.some((o) => (r = o.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false)) continue;
|
|
1710
|
+
if (r = this.tokenizer.space(e)) {
|
|
1711
|
+
e = e.substring(r.raw.length);
|
|
1712
|
+
let o = t.at(-1);
|
|
1713
|
+
r.raw.length === 1 && o !== void 0 ? o.raw += `
|
|
1714
|
+
` : t.push(r);
|
|
1715
|
+
continue;
|
|
1716
|
+
}
|
|
1717
|
+
if (r = this.tokenizer.code(e)) {
|
|
1718
|
+
e = e.substring(r.raw.length);
|
|
1719
|
+
let o = t.at(-1);
|
|
1720
|
+
o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
1721
|
+
`) ? "" : `
|
|
1722
|
+
`) + r.raw, o.text += `
|
|
1723
|
+
` + r.text, this.inlineQueue.at(-1).src = o.text) : t.push(r);
|
|
1724
|
+
continue;
|
|
1725
|
+
}
|
|
1726
|
+
if (r = this.tokenizer.fences(e)) {
|
|
1727
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1728
|
+
continue;
|
|
1729
|
+
}
|
|
1730
|
+
if (r = this.tokenizer.heading(e)) {
|
|
1731
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1732
|
+
continue;
|
|
1733
|
+
}
|
|
1734
|
+
if (r = this.tokenizer.hr(e)) {
|
|
1735
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1736
|
+
continue;
|
|
1737
|
+
}
|
|
1738
|
+
if (r = this.tokenizer.blockquote(e)) {
|
|
1739
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1740
|
+
continue;
|
|
1741
|
+
}
|
|
1742
|
+
if (r = this.tokenizer.list(e)) {
|
|
1743
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1744
|
+
continue;
|
|
1745
|
+
}
|
|
1746
|
+
if (r = this.tokenizer.html(e)) {
|
|
1747
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1748
|
+
continue;
|
|
1749
|
+
}
|
|
1750
|
+
if (r = this.tokenizer.def(e)) {
|
|
1751
|
+
e = e.substring(r.raw.length);
|
|
1752
|
+
let o = t.at(-1);
|
|
1753
|
+
o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
1754
|
+
`) ? "" : `
|
|
1755
|
+
`) + r.raw, o.text += `
|
|
1756
|
+
` + 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));
|
|
1757
|
+
continue;
|
|
1758
|
+
}
|
|
1759
|
+
if (r = this.tokenizer.table(e)) {
|
|
1760
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1761
|
+
continue;
|
|
1762
|
+
}
|
|
1763
|
+
if (r = this.tokenizer.lheading(e)) {
|
|
1764
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1765
|
+
continue;
|
|
1766
|
+
}
|
|
1767
|
+
let i = e;
|
|
1768
|
+
if (this.options.extensions?.startBlock) {
|
|
1769
|
+
let o = 1 / 0, u = e.slice(1), a;
|
|
1770
|
+
this.options.extensions.startBlock.forEach((c2) => {
|
|
1771
|
+
a = c2.call({ lexer: this }, u), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
|
|
1772
|
+
}), o < 1 / 0 && o >= 0 && (i = e.substring(0, o + 1));
|
|
1773
|
+
}
|
|
1774
|
+
if (this.state.top && (r = this.tokenizer.paragraph(i))) {
|
|
1775
|
+
let o = t.at(-1);
|
|
1776
|
+
n && o?.type === "paragraph" ? (o.raw += (o.raw.endsWith(`
|
|
1777
|
+
`) ? "" : `
|
|
1778
|
+
`) + r.raw, o.text += `
|
|
1779
|
+
` + 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);
|
|
1780
|
+
continue;
|
|
1781
|
+
}
|
|
1782
|
+
if (r = this.tokenizer.text(e)) {
|
|
1783
|
+
e = e.substring(r.raw.length);
|
|
1784
|
+
let o = t.at(-1);
|
|
1785
|
+
o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
1786
|
+
`) ? "" : `
|
|
1787
|
+
`) + r.raw, o.text += `
|
|
1788
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r);
|
|
1789
|
+
continue;
|
|
1790
|
+
}
|
|
1791
|
+
if (e) {
|
|
1792
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
1793
|
+
break;
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
return this.state.top = true, t;
|
|
1797
|
+
}
|
|
1798
|
+
inline(e, t = []) {
|
|
1799
|
+
return this.inlineQueue.push({ src: e, tokens: t }), t;
|
|
1800
|
+
}
|
|
1801
|
+
inlineTokens(e, t = []) {
|
|
1802
|
+
this.tokenizer.lexer = this;
|
|
1803
|
+
let n = e, s = null;
|
|
1804
|
+
if (this.tokens.links) {
|
|
1805
|
+
let a = Object.keys(this.tokens.links);
|
|
1806
|
+
if (a.length > 0) for (; (s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) !== null; ) a.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
|
|
1807
|
+
}
|
|
1808
|
+
for (; (s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) !== null; ) n = n.slice(0, s.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
1809
|
+
let r;
|
|
1810
|
+
for (; (s = this.tokenizer.rules.inline.blockSkip.exec(n)) !== null; ) r = s[2] ? s[2].length : 0, n = n.slice(0, s.index + r) + "[" + "a".repeat(s[0].length - r - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
1811
|
+
n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
|
|
1812
|
+
let i = false, o = "", u = 1 / 0;
|
|
1813
|
+
for (; e; ) {
|
|
1814
|
+
if (e.length < u) u = e.length;
|
|
1815
|
+
else {
|
|
1816
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
1817
|
+
break;
|
|
1818
|
+
}
|
|
1819
|
+
i || (o = ""), i = false;
|
|
1820
|
+
let a;
|
|
1821
|
+
if (this.options.extensions?.inline?.some((p) => (a = p.call({ lexer: this }, e, t)) ? (e = e.substring(a.raw.length), t.push(a), true) : false)) continue;
|
|
1822
|
+
if (a = this.tokenizer.escape(e)) {
|
|
1823
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1824
|
+
continue;
|
|
1825
|
+
}
|
|
1826
|
+
if (a = this.tokenizer.tag(e)) {
|
|
1827
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1828
|
+
continue;
|
|
1829
|
+
}
|
|
1830
|
+
if (a = this.tokenizer.link(e)) {
|
|
1831
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1832
|
+
continue;
|
|
1833
|
+
}
|
|
1834
|
+
if (a = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
1835
|
+
e = e.substring(a.raw.length);
|
|
1836
|
+
let p = t.at(-1);
|
|
1837
|
+
a.type === "text" && p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
|
|
1838
|
+
continue;
|
|
1839
|
+
}
|
|
1840
|
+
if (a = this.tokenizer.emStrong(e, n, o)) {
|
|
1841
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1842
|
+
continue;
|
|
1843
|
+
}
|
|
1844
|
+
if (a = this.tokenizer.codespan(e)) {
|
|
1845
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1846
|
+
continue;
|
|
1847
|
+
}
|
|
1848
|
+
if (a = this.tokenizer.br(e)) {
|
|
1849
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1850
|
+
continue;
|
|
1851
|
+
}
|
|
1852
|
+
if (a = this.tokenizer.del(e, n, o)) {
|
|
1853
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1854
|
+
continue;
|
|
1855
|
+
}
|
|
1856
|
+
if (a = this.tokenizer.autolink(e)) {
|
|
1857
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1858
|
+
continue;
|
|
1859
|
+
}
|
|
1860
|
+
if (!this.state.inLink && (a = this.tokenizer.url(e))) {
|
|
1861
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1862
|
+
continue;
|
|
1863
|
+
}
|
|
1864
|
+
let c2 = e;
|
|
1865
|
+
if (this.options.extensions?.startInline) {
|
|
1866
|
+
let p = 1 / 0, d = e.slice(1), h;
|
|
1867
|
+
this.options.extensions.startInline.forEach((R) => {
|
|
1868
|
+
h = R.call({ lexer: this }, d), typeof h == "number" && h >= 0 && (p = Math.min(p, h));
|
|
1869
|
+
}), p < 1 / 0 && p >= 0 && (c2 = e.substring(0, p + 1));
|
|
1870
|
+
}
|
|
1871
|
+
if (a = this.tokenizer.inlineText(c2)) {
|
|
1872
|
+
e = e.substring(a.raw.length), a.raw.slice(-1) !== "_" && (o = a.raw.slice(-1)), i = true;
|
|
1873
|
+
let p = t.at(-1);
|
|
1874
|
+
p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
|
|
1875
|
+
continue;
|
|
1876
|
+
}
|
|
1877
|
+
if (e) {
|
|
1878
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
1879
|
+
break;
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
return t;
|
|
1883
|
+
}
|
|
1884
|
+
infiniteLoopError(e) {
|
|
1885
|
+
let t = "Infinite loop on byte: " + e;
|
|
1886
|
+
if (this.options.silent) console.error(t);
|
|
1887
|
+
else throw new Error(t);
|
|
1888
|
+
}
|
|
1889
|
+
};
|
|
1890
|
+
y = class {
|
|
1891
|
+
options;
|
|
1892
|
+
parser;
|
|
1893
|
+
constructor(e) {
|
|
1894
|
+
this.options = e || T;
|
|
1895
|
+
}
|
|
1896
|
+
space(e) {
|
|
1897
|
+
return "";
|
|
1898
|
+
}
|
|
1899
|
+
code({ text: e, lang: t, escaped: n }) {
|
|
1900
|
+
let s = (t || "").match(m.notSpaceStart)?.[0], r = e.replace(m.endingNewline, "") + `
|
|
1901
|
+
`;
|
|
1902
|
+
return s ? '<pre><code class="language-' + O(s) + '">' + (n ? r : O(r, true)) + `</code></pre>
|
|
1903
|
+
` : "<pre><code>" + (n ? r : O(r, true)) + `</code></pre>
|
|
1904
|
+
`;
|
|
1905
|
+
}
|
|
1906
|
+
blockquote({ tokens: e }) {
|
|
1907
|
+
return `<blockquote>
|
|
1908
|
+
${this.parser.parse(e)}</blockquote>
|
|
1909
|
+
`;
|
|
1910
|
+
}
|
|
1911
|
+
html({ text: e }) {
|
|
1912
|
+
return e;
|
|
1913
|
+
}
|
|
1914
|
+
def(e) {
|
|
1915
|
+
return "";
|
|
1916
|
+
}
|
|
1917
|
+
heading({ tokens: e, depth: t }) {
|
|
1918
|
+
return `<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
1919
|
+
`;
|
|
1920
|
+
}
|
|
1921
|
+
hr(e) {
|
|
1922
|
+
return `<hr>
|
|
1923
|
+
`;
|
|
1924
|
+
}
|
|
1925
|
+
list(e) {
|
|
1926
|
+
let t = e.ordered, n = e.start, s = "";
|
|
1927
|
+
for (let o = 0; o < e.items.length; o++) {
|
|
1928
|
+
let u = e.items[o];
|
|
1929
|
+
s += this.listitem(u);
|
|
1930
|
+
}
|
|
1931
|
+
let r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
1932
|
+
return "<" + r + i + `>
|
|
1933
|
+
` + s + "</" + r + `>
|
|
1934
|
+
`;
|
|
1935
|
+
}
|
|
1936
|
+
listitem(e) {
|
|
1937
|
+
return `<li>${this.parser.parse(e.tokens)}</li>
|
|
1938
|
+
`;
|
|
1939
|
+
}
|
|
1940
|
+
checkbox({ checked: e }) {
|
|
1941
|
+
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
|
|
1942
|
+
}
|
|
1943
|
+
paragraph({ tokens: e }) {
|
|
1944
|
+
return `<p>${this.parser.parseInline(e)}</p>
|
|
1945
|
+
`;
|
|
1946
|
+
}
|
|
1947
|
+
table(e) {
|
|
1948
|
+
let t = "", n = "";
|
|
1949
|
+
for (let r = 0; r < e.header.length; r++) n += this.tablecell(e.header[r]);
|
|
1950
|
+
t += this.tablerow({ text: n });
|
|
1951
|
+
let s = "";
|
|
1952
|
+
for (let r = 0; r < e.rows.length; r++) {
|
|
1953
|
+
let i = e.rows[r];
|
|
1954
|
+
n = "";
|
|
1955
|
+
for (let o = 0; o < i.length; o++) n += this.tablecell(i[o]);
|
|
1956
|
+
s += this.tablerow({ text: n });
|
|
1957
|
+
}
|
|
1958
|
+
return s && (s = `<tbody>${s}</tbody>`), `<table>
|
|
1959
|
+
<thead>
|
|
1960
|
+
` + t + `</thead>
|
|
1961
|
+
` + s + `</table>
|
|
1962
|
+
`;
|
|
1963
|
+
}
|
|
1964
|
+
tablerow({ text: e }) {
|
|
1965
|
+
return `<tr>
|
|
1966
|
+
${e}</tr>
|
|
1967
|
+
`;
|
|
1968
|
+
}
|
|
1969
|
+
tablecell(e) {
|
|
1970
|
+
let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
|
|
1971
|
+
return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
|
|
1972
|
+
`;
|
|
1973
|
+
}
|
|
1974
|
+
strong({ tokens: e }) {
|
|
1975
|
+
return `<strong>${this.parser.parseInline(e)}</strong>`;
|
|
1976
|
+
}
|
|
1977
|
+
em({ tokens: e }) {
|
|
1978
|
+
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
1979
|
+
}
|
|
1980
|
+
codespan({ text: e }) {
|
|
1981
|
+
return `<code>${O(e, true)}</code>`;
|
|
1982
|
+
}
|
|
1983
|
+
br(e) {
|
|
1984
|
+
return "<br>";
|
|
1985
|
+
}
|
|
1986
|
+
del({ tokens: e }) {
|
|
1987
|
+
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
1988
|
+
}
|
|
1989
|
+
link({ href: e, title: t, tokens: n }) {
|
|
1990
|
+
let s = this.parser.parseInline(n), r = J(e);
|
|
1991
|
+
if (r === null) return s;
|
|
1992
|
+
e = r;
|
|
1993
|
+
let i = '<a href="' + e + '"';
|
|
1994
|
+
return t && (i += ' title="' + O(t) + '"'), i += ">" + s + "</a>", i;
|
|
1995
|
+
}
|
|
1996
|
+
image({ href: e, title: t, text: n, tokens: s }) {
|
|
1997
|
+
s && (n = this.parser.parseInline(s, this.parser.textRenderer));
|
|
1998
|
+
let r = J(e);
|
|
1999
|
+
if (r === null) return O(n);
|
|
2000
|
+
e = r;
|
|
2001
|
+
let i = `<img src="${e}" alt="${O(n)}"`;
|
|
2002
|
+
return t && (i += ` title="${O(t)}"`), i += ">", i;
|
|
2003
|
+
}
|
|
2004
|
+
text(e) {
|
|
2005
|
+
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : O(e.text);
|
|
2006
|
+
}
|
|
2007
|
+
};
|
|
2008
|
+
L = class {
|
|
2009
|
+
strong({ text: e }) {
|
|
2010
|
+
return e;
|
|
2011
|
+
}
|
|
2012
|
+
em({ text: e }) {
|
|
2013
|
+
return e;
|
|
2014
|
+
}
|
|
2015
|
+
codespan({ text: e }) {
|
|
2016
|
+
return e;
|
|
2017
|
+
}
|
|
2018
|
+
del({ text: e }) {
|
|
2019
|
+
return e;
|
|
2020
|
+
}
|
|
2021
|
+
html({ text: e }) {
|
|
2022
|
+
return e;
|
|
2023
|
+
}
|
|
2024
|
+
text({ text: e }) {
|
|
2025
|
+
return e;
|
|
2026
|
+
}
|
|
2027
|
+
link({ text: e }) {
|
|
2028
|
+
return "" + e;
|
|
2029
|
+
}
|
|
2030
|
+
image({ text: e }) {
|
|
2031
|
+
return "" + e;
|
|
2032
|
+
}
|
|
2033
|
+
br() {
|
|
2034
|
+
return "";
|
|
2035
|
+
}
|
|
2036
|
+
checkbox({ raw: e }) {
|
|
2037
|
+
return e;
|
|
2038
|
+
}
|
|
2039
|
+
};
|
|
2040
|
+
b = class l2 {
|
|
2041
|
+
options;
|
|
2042
|
+
renderer;
|
|
2043
|
+
textRenderer;
|
|
2044
|
+
constructor(e) {
|
|
2045
|
+
this.options = e || T, this.options.renderer = this.options.renderer || new y(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L();
|
|
2046
|
+
}
|
|
2047
|
+
static parse(e, t) {
|
|
2048
|
+
return new l2(t).parse(e);
|
|
2049
|
+
}
|
|
2050
|
+
static parseInline(e, t) {
|
|
2051
|
+
return new l2(t).parseInline(e);
|
|
2052
|
+
}
|
|
2053
|
+
parse(e) {
|
|
2054
|
+
this.renderer.parser = this;
|
|
2055
|
+
let t = "";
|
|
2056
|
+
for (let n = 0; n < e.length; n++) {
|
|
2057
|
+
let s = e[n];
|
|
2058
|
+
if (this.options.extensions?.renderers?.[s.type]) {
|
|
2059
|
+
let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
2060
|
+
if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(i.type)) {
|
|
2061
|
+
t += o || "";
|
|
2062
|
+
continue;
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
let r = s;
|
|
2066
|
+
switch (r.type) {
|
|
2067
|
+
case "space": {
|
|
2068
|
+
t += this.renderer.space(r);
|
|
2069
|
+
break;
|
|
2070
|
+
}
|
|
2071
|
+
case "hr": {
|
|
2072
|
+
t += this.renderer.hr(r);
|
|
2073
|
+
break;
|
|
2074
|
+
}
|
|
2075
|
+
case "heading": {
|
|
2076
|
+
t += this.renderer.heading(r);
|
|
2077
|
+
break;
|
|
2078
|
+
}
|
|
2079
|
+
case "code": {
|
|
2080
|
+
t += this.renderer.code(r);
|
|
2081
|
+
break;
|
|
2082
|
+
}
|
|
2083
|
+
case "table": {
|
|
2084
|
+
t += this.renderer.table(r);
|
|
2085
|
+
break;
|
|
2086
|
+
}
|
|
2087
|
+
case "blockquote": {
|
|
2088
|
+
t += this.renderer.blockquote(r);
|
|
2089
|
+
break;
|
|
2090
|
+
}
|
|
2091
|
+
case "list": {
|
|
2092
|
+
t += this.renderer.list(r);
|
|
2093
|
+
break;
|
|
2094
|
+
}
|
|
2095
|
+
case "checkbox": {
|
|
2096
|
+
t += this.renderer.checkbox(r);
|
|
2097
|
+
break;
|
|
2098
|
+
}
|
|
2099
|
+
case "html": {
|
|
2100
|
+
t += this.renderer.html(r);
|
|
2101
|
+
break;
|
|
2102
|
+
}
|
|
2103
|
+
case "def": {
|
|
2104
|
+
t += this.renderer.def(r);
|
|
2105
|
+
break;
|
|
2106
|
+
}
|
|
2107
|
+
case "paragraph": {
|
|
2108
|
+
t += this.renderer.paragraph(r);
|
|
2109
|
+
break;
|
|
2110
|
+
}
|
|
2111
|
+
case "text": {
|
|
2112
|
+
t += this.renderer.text(r);
|
|
2113
|
+
break;
|
|
2114
|
+
}
|
|
2115
|
+
default: {
|
|
2116
|
+
let i = 'Token with "' + r.type + '" type was not found.';
|
|
2117
|
+
if (this.options.silent) return console.error(i), "";
|
|
2118
|
+
throw new Error(i);
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
return t;
|
|
2123
|
+
}
|
|
2124
|
+
parseInline(e, t = this.renderer) {
|
|
2125
|
+
this.renderer.parser = this;
|
|
2126
|
+
let n = "";
|
|
2127
|
+
for (let s = 0; s < e.length; s++) {
|
|
2128
|
+
let r = e[s];
|
|
2129
|
+
if (this.options.extensions?.renderers?.[r.type]) {
|
|
2130
|
+
let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
|
|
2131
|
+
if (o !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
|
|
2132
|
+
n += o || "";
|
|
2133
|
+
continue;
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
let i = r;
|
|
2137
|
+
switch (i.type) {
|
|
2138
|
+
case "escape": {
|
|
2139
|
+
n += t.text(i);
|
|
2140
|
+
break;
|
|
2141
|
+
}
|
|
2142
|
+
case "html": {
|
|
2143
|
+
n += t.html(i);
|
|
2144
|
+
break;
|
|
2145
|
+
}
|
|
2146
|
+
case "link": {
|
|
2147
|
+
n += t.link(i);
|
|
2148
|
+
break;
|
|
2149
|
+
}
|
|
2150
|
+
case "image": {
|
|
2151
|
+
n += t.image(i);
|
|
2152
|
+
break;
|
|
2153
|
+
}
|
|
2154
|
+
case "checkbox": {
|
|
2155
|
+
n += t.checkbox(i);
|
|
2156
|
+
break;
|
|
2157
|
+
}
|
|
2158
|
+
case "strong": {
|
|
2159
|
+
n += t.strong(i);
|
|
2160
|
+
break;
|
|
2161
|
+
}
|
|
2162
|
+
case "em": {
|
|
2163
|
+
n += t.em(i);
|
|
2164
|
+
break;
|
|
2165
|
+
}
|
|
2166
|
+
case "codespan": {
|
|
2167
|
+
n += t.codespan(i);
|
|
2168
|
+
break;
|
|
2169
|
+
}
|
|
2170
|
+
case "br": {
|
|
2171
|
+
n += t.br(i);
|
|
2172
|
+
break;
|
|
2173
|
+
}
|
|
2174
|
+
case "del": {
|
|
2175
|
+
n += t.del(i);
|
|
2176
|
+
break;
|
|
2177
|
+
}
|
|
2178
|
+
case "text": {
|
|
2179
|
+
n += t.text(i);
|
|
2180
|
+
break;
|
|
2181
|
+
}
|
|
2182
|
+
default: {
|
|
2183
|
+
let o = 'Token with "' + i.type + '" type was not found.';
|
|
2184
|
+
if (this.options.silent) return console.error(o), "";
|
|
2185
|
+
throw new Error(o);
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
return n;
|
|
2190
|
+
}
|
|
2191
|
+
};
|
|
2192
|
+
P = class {
|
|
2193
|
+
options;
|
|
2194
|
+
block;
|
|
2195
|
+
constructor(e) {
|
|
2196
|
+
this.options = e || T;
|
|
2197
|
+
}
|
|
2198
|
+
static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
|
|
2199
|
+
static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
2200
|
+
preprocess(e) {
|
|
2201
|
+
return e;
|
|
2202
|
+
}
|
|
2203
|
+
postprocess(e) {
|
|
2204
|
+
return e;
|
|
2205
|
+
}
|
|
2206
|
+
processAllTokens(e) {
|
|
2207
|
+
return e;
|
|
2208
|
+
}
|
|
2209
|
+
emStrongMask(e) {
|
|
2210
|
+
return e;
|
|
2211
|
+
}
|
|
2212
|
+
provideLexer(e = this.block) {
|
|
2213
|
+
return e ? x.lex : x.lexInline;
|
|
2214
|
+
}
|
|
2215
|
+
provideParser(e = this.block) {
|
|
2216
|
+
return e ? b.parse : b.parseInline;
|
|
2217
|
+
}
|
|
2218
|
+
};
|
|
2219
|
+
D = class {
|
|
2220
|
+
defaults = z();
|
|
2221
|
+
options = this.setOptions;
|
|
2222
|
+
parse = this.parseMarkdown(true);
|
|
2223
|
+
parseInline = this.parseMarkdown(false);
|
|
2224
|
+
Parser = b;
|
|
2225
|
+
Renderer = y;
|
|
2226
|
+
TextRenderer = L;
|
|
2227
|
+
Lexer = x;
|
|
2228
|
+
Tokenizer = w;
|
|
2229
|
+
Hooks = P;
|
|
2230
|
+
constructor(...e) {
|
|
2231
|
+
this.use(...e);
|
|
2232
|
+
}
|
|
2233
|
+
walkTokens(e, t) {
|
|
2234
|
+
let n = [];
|
|
2235
|
+
for (let s of e) switch (n = n.concat(t.call(this, s)), s.type) {
|
|
2236
|
+
case "table": {
|
|
2237
|
+
let r = s;
|
|
2238
|
+
for (let i of r.header) n = n.concat(this.walkTokens(i.tokens, t));
|
|
2239
|
+
for (let i of r.rows) for (let o of i) n = n.concat(this.walkTokens(o.tokens, t));
|
|
2240
|
+
break;
|
|
2241
|
+
}
|
|
2242
|
+
case "list": {
|
|
2243
|
+
let r = s;
|
|
2244
|
+
n = n.concat(this.walkTokens(r.items, t));
|
|
2245
|
+
break;
|
|
2246
|
+
}
|
|
2247
|
+
default: {
|
|
2248
|
+
let r = s;
|
|
2249
|
+
this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((i) => {
|
|
2250
|
+
let o = r[i].flat(1 / 0);
|
|
2251
|
+
n = n.concat(this.walkTokens(o, t));
|
|
2252
|
+
}) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, t)));
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
return n;
|
|
2256
|
+
}
|
|
2257
|
+
use(...e) {
|
|
2258
|
+
let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
2259
|
+
return e.forEach((n) => {
|
|
2260
|
+
let s = { ...n };
|
|
2261
|
+
if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
|
|
2262
|
+
if (!r.name) throw new Error("extension name required");
|
|
2263
|
+
if ("renderer" in r) {
|
|
2264
|
+
let i = t.renderers[r.name];
|
|
2265
|
+
i ? t.renderers[r.name] = function(...o) {
|
|
2266
|
+
let u = r.renderer.apply(this, o);
|
|
2267
|
+
return u === false && (u = i.apply(this, o)), u;
|
|
2268
|
+
} : t.renderers[r.name] = r.renderer;
|
|
2269
|
+
}
|
|
2270
|
+
if ("tokenizer" in r) {
|
|
2271
|
+
if (!r.level || r.level !== "block" && r.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
|
|
2272
|
+
let i = t[r.level];
|
|
2273
|
+
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]));
|
|
2274
|
+
}
|
|
2275
|
+
"childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
|
|
2276
|
+
}), s.extensions = t), n.renderer) {
|
|
2277
|
+
let r = this.defaults.renderer || new y(this.defaults);
|
|
2278
|
+
for (let i in n.renderer) {
|
|
2279
|
+
if (!(i in r)) throw new Error(`renderer '${i}' does not exist`);
|
|
2280
|
+
if (["options", "parser"].includes(i)) continue;
|
|
2281
|
+
let o = i, u = n.renderer[o], a = r[o];
|
|
2282
|
+
r[o] = (...c2) => {
|
|
2283
|
+
let p = u.apply(r, c2);
|
|
2284
|
+
return p === false && (p = a.apply(r, c2)), p || "";
|
|
2285
|
+
};
|
|
2286
|
+
}
|
|
2287
|
+
s.renderer = r;
|
|
2288
|
+
}
|
|
2289
|
+
if (n.tokenizer) {
|
|
2290
|
+
let r = this.defaults.tokenizer || new w(this.defaults);
|
|
2291
|
+
for (let i in n.tokenizer) {
|
|
2292
|
+
if (!(i in r)) throw new Error(`tokenizer '${i}' does not exist`);
|
|
2293
|
+
if (["options", "rules", "lexer"].includes(i)) continue;
|
|
2294
|
+
let o = i, u = n.tokenizer[o], a = r[o];
|
|
2295
|
+
r[o] = (...c2) => {
|
|
2296
|
+
let p = u.apply(r, c2);
|
|
2297
|
+
return p === false && (p = a.apply(r, c2)), p;
|
|
2298
|
+
};
|
|
2299
|
+
}
|
|
2300
|
+
s.tokenizer = r;
|
|
2301
|
+
}
|
|
2302
|
+
if (n.hooks) {
|
|
2303
|
+
let r = this.defaults.hooks || new P();
|
|
2304
|
+
for (let i in n.hooks) {
|
|
2305
|
+
if (!(i in r)) throw new Error(`hook '${i}' does not exist`);
|
|
2306
|
+
if (["options", "block"].includes(i)) continue;
|
|
2307
|
+
let o = i, u = n.hooks[o], a = r[o];
|
|
2308
|
+
P.passThroughHooks.has(i) ? r[o] = (c2) => {
|
|
2309
|
+
if (this.defaults.async && P.passThroughHooksRespectAsync.has(i)) return (async () => {
|
|
2310
|
+
let d = await u.call(r, c2);
|
|
2311
|
+
return a.call(r, d);
|
|
2312
|
+
})();
|
|
2313
|
+
let p = u.call(r, c2);
|
|
2314
|
+
return a.call(r, p);
|
|
2315
|
+
} : r[o] = (...c2) => {
|
|
2316
|
+
if (this.defaults.async) return (async () => {
|
|
2317
|
+
let d = await u.apply(r, c2);
|
|
2318
|
+
return d === false && (d = await a.apply(r, c2)), d;
|
|
2319
|
+
})();
|
|
2320
|
+
let p = u.apply(r, c2);
|
|
2321
|
+
return p === false && (p = a.apply(r, c2)), p;
|
|
2322
|
+
};
|
|
2323
|
+
}
|
|
2324
|
+
s.hooks = r;
|
|
2325
|
+
}
|
|
2326
|
+
if (n.walkTokens) {
|
|
2327
|
+
let r = this.defaults.walkTokens, i = n.walkTokens;
|
|
2328
|
+
s.walkTokens = function(o) {
|
|
2329
|
+
let u = [];
|
|
2330
|
+
return u.push(i.call(this, o)), r && (u = u.concat(r.call(this, o))), u;
|
|
2331
|
+
};
|
|
2332
|
+
}
|
|
2333
|
+
this.defaults = { ...this.defaults, ...s };
|
|
2334
|
+
}), this;
|
|
2335
|
+
}
|
|
2336
|
+
setOptions(e) {
|
|
2337
|
+
return this.defaults = { ...this.defaults, ...e }, this;
|
|
2338
|
+
}
|
|
2339
|
+
lexer(e, t) {
|
|
2340
|
+
return x.lex(e, t ?? this.defaults);
|
|
2341
|
+
}
|
|
2342
|
+
parser(e, t) {
|
|
2343
|
+
return b.parse(e, t ?? this.defaults);
|
|
2344
|
+
}
|
|
2345
|
+
parseMarkdown(e) {
|
|
2346
|
+
return (n, s) => {
|
|
2347
|
+
let r = { ...s }, i = { ...this.defaults, ...r }, o = this.onError(!!i.silent, !!i.async);
|
|
2348
|
+
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."));
|
|
2349
|
+
if (typeof n > "u" || n === null) return o(new Error("marked(): input parameter is undefined or null"));
|
|
2350
|
+
if (typeof n != "string") return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
2351
|
+
if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
|
|
2352
|
+
let u = i.hooks ? await i.hooks.preprocess(n) : n, c2 = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(u, i), p = i.hooks ? await i.hooks.processAllTokens(c2) : c2;
|
|
2353
|
+
i.walkTokens && await Promise.all(this.walkTokens(p, i.walkTokens));
|
|
2354
|
+
let h = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(p, i);
|
|
2355
|
+
return i.hooks ? await i.hooks.postprocess(h) : h;
|
|
2356
|
+
})().catch(o);
|
|
2357
|
+
try {
|
|
2358
|
+
i.hooks && (n = i.hooks.preprocess(n));
|
|
2359
|
+
let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
|
|
2360
|
+
i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
|
|
2361
|
+
let p = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
|
|
2362
|
+
return i.hooks && (p = i.hooks.postprocess(p)), p;
|
|
2363
|
+
} catch (u) {
|
|
2364
|
+
return o(u);
|
|
2365
|
+
}
|
|
2366
|
+
};
|
|
2367
|
+
}
|
|
2368
|
+
onError(e, t) {
|
|
2369
|
+
return (n) => {
|
|
2370
|
+
if (n.message += `
|
|
2371
|
+
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
2372
|
+
let s = "<p>An error occurred:</p><pre>" + O(n.message + "", true) + "</pre>";
|
|
2373
|
+
return t ? Promise.resolve(s) : s;
|
|
2374
|
+
}
|
|
2375
|
+
if (t) return Promise.reject(n);
|
|
2376
|
+
throw n;
|
|
2377
|
+
};
|
|
2378
|
+
}
|
|
2379
|
+
};
|
|
2380
|
+
M = new D();
|
|
2381
|
+
g.options = g.setOptions = function(l3) {
|
|
2382
|
+
return M.setOptions(l3), g.defaults = M.defaults, G(g.defaults), g;
|
|
2383
|
+
};
|
|
2384
|
+
g.getDefaults = z;
|
|
2385
|
+
g.defaults = T;
|
|
2386
|
+
g.use = function(...l3) {
|
|
2387
|
+
return M.use(...l3), g.defaults = M.defaults, G(g.defaults), g;
|
|
2388
|
+
};
|
|
2389
|
+
g.walkTokens = function(l3, e) {
|
|
2390
|
+
return M.walkTokens(l3, e);
|
|
2391
|
+
};
|
|
2392
|
+
g.parseInline = M.parseInline;
|
|
2393
|
+
g.Parser = b;
|
|
2394
|
+
g.parser = b.parse;
|
|
2395
|
+
g.Renderer = y;
|
|
2396
|
+
g.TextRenderer = L;
|
|
2397
|
+
g.Lexer = x;
|
|
2398
|
+
g.lexer = x.lex;
|
|
2399
|
+
g.Tokenizer = w;
|
|
2400
|
+
g.Hooks = P;
|
|
2401
|
+
g.parse = g;
|
|
2402
|
+
jt = g.options;
|
|
2403
|
+
Ft = g.setOptions;
|
|
2404
|
+
Ut = g.use;
|
|
2405
|
+
Kt = g.walkTokens;
|
|
2406
|
+
Wt = g.parseInline;
|
|
2407
|
+
Xt = g;
|
|
2408
|
+
Jt = b.parse;
|
|
2409
|
+
Vt = x.lex;
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
|
|
1154
2413
|
// src/ijfw.js
|
|
1155
2414
|
import { dirname as dirname2, join as join9, resolve as resolve3, basename } from "node:path";
|
|
1156
2415
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
1157
|
-
import { existsSync as existsSync3, mkdirSync as mkdirSync3, copyFileSync, readdirSync as readdirSync4, rmSync as rmSync4 } from "node:fs";
|
|
1158
|
-
import { homedir } from "node:os";
|
|
2416
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, copyFileSync, readdirSync as readdirSync4, rmSync as rmSync4, readFileSync as readFileSync3, writeFileSync as writeFileSync4 } from "node:fs";
|
|
2417
|
+
import { homedir, platform as platform2 } from "node:os";
|
|
1159
2418
|
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
1160
2419
|
var __dirname2 = dirname2(fileURLToPath2(import.meta.url));
|
|
1161
2420
|
function repoRoot() {
|
|
@@ -1176,6 +2435,7 @@ USAGE
|
|
|
1176
2435
|
COMMANDS
|
|
1177
2436
|
install Install IJFW into your AI coding agents
|
|
1178
2437
|
uninstall Remove IJFW from your AI coding agents
|
|
2438
|
+
help Open the full IJFW guide (terminal, or --browser for rendered)
|
|
1179
2439
|
preflight Run 11-gate quality pipeline before publishing
|
|
1180
2440
|
dashboard Start / stop / check the local observability dashboard
|
|
1181
2441
|
design Manage the visual design companion
|
|
@@ -1198,9 +2458,9 @@ async function main() {
|
|
|
1198
2458
|
}
|
|
1199
2459
|
if (sub === "--version" || sub === "-v") {
|
|
1200
2460
|
try {
|
|
1201
|
-
const { readFileSync:
|
|
2461
|
+
const { readFileSync: readFileSync4 } = await import("node:fs");
|
|
1202
2462
|
const pkgPath = join9(__dirname2, "..", "package.json");
|
|
1203
|
-
const pkg = JSON.parse(
|
|
2463
|
+
const pkg = JSON.parse(readFileSync4(pkgPath, "utf8"));
|
|
1204
2464
|
console.log(pkg.version || "unknown");
|
|
1205
2465
|
} catch {
|
|
1206
2466
|
console.log("unknown");
|
|
@@ -1293,6 +2553,62 @@ async function main() {
|
|
|
1293
2553
|
}
|
|
1294
2554
|
break;
|
|
1295
2555
|
}
|
|
2556
|
+
case "help": {
|
|
2557
|
+
const wantsBrowser = argv.slice(3).includes("--browser");
|
|
2558
|
+
const candidates = [
|
|
2559
|
+
join9(repoRoot(), "docs", "GUIDE.md"),
|
|
2560
|
+
resolve3(__dirname2, "..", "docs", "GUIDE.md"),
|
|
2561
|
+
join9(homedir(), ".ijfw", "docs", "GUIDE.md")
|
|
2562
|
+
];
|
|
2563
|
+
const guidePath = candidates.find((p) => existsSync3(p));
|
|
2564
|
+
if (!guidePath) {
|
|
2565
|
+
console.error("[ijfw] Guide not found. Run `ijfw install` to fetch the full guide, or visit https://github.com/TheRealSeanDonahoe/ijfw/blob/main/docs/GUIDE.md");
|
|
2566
|
+
process.exit(1);
|
|
2567
|
+
}
|
|
2568
|
+
if (wantsBrowser) {
|
|
2569
|
+
const { marked } = await Promise.resolve().then(() => (init_marked_esm(), marked_esm_exports));
|
|
2570
|
+
const assetsSrc = join9(dirname2(guidePath), "guide", "assets");
|
|
2571
|
+
const outDir = join9(homedir(), ".ijfw", "guide");
|
|
2572
|
+
mkdirSync3(join9(outDir, "assets"), { recursive: true });
|
|
2573
|
+
if (existsSync3(assetsSrc)) {
|
|
2574
|
+
for (const f of readdirSync4(assetsSrc)) {
|
|
2575
|
+
copyFileSync(join9(assetsSrc, f), join9(outDir, "assets", f));
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
const md = readFileSync3(guidePath, "utf8").replace(/\(guide\/assets\//g, "(assets/");
|
|
2579
|
+
const rendered = marked.parse(md, { gfm: true, breaks: false });
|
|
2580
|
+
const html = `<!doctype html>
|
|
2581
|
+
<html lang="en"><head>
|
|
2582
|
+
<meta charset="utf-8"/>
|
|
2583
|
+
<title>IJFW Guide</title>
|
|
2584
|
+
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
|
2585
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@5.5.1/github-markdown-dark.css"/>
|
|
2586
|
+
<style>
|
|
2587
|
+
body{margin:0;background:#0d1117;color:#e6edf3;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif}
|
|
2588
|
+
.wrap{max-width:960px;margin:0 auto;padding:48px 32px}
|
|
2589
|
+
.markdown-body{background:transparent;color:#e6edf3}
|
|
2590
|
+
pre,code{font-family:ui-monospace,Menlo,Consolas,monospace}
|
|
2591
|
+
img{border-radius:8px;max-width:100%}
|
|
2592
|
+
table{display:table;width:100%}
|
|
2593
|
+
</style>
|
|
2594
|
+
</head><body><div class="wrap markdown-body">${rendered}</div></body></html>`;
|
|
2595
|
+
const outHtml = join9(outDir, "index.html");
|
|
2596
|
+
writeFileSync4(outHtml, html);
|
|
2597
|
+
const opener = platform2() === "darwin" ? "open" : platform2() === "win32" ? "start" : "xdg-open";
|
|
2598
|
+
spawnSync12(opener, [outHtml], { stdio: "ignore", detached: true });
|
|
2599
|
+
console.log(`[ijfw] Guide opened in your browser.`);
|
|
2600
|
+
console.log(` Local copy: ${outHtml}`);
|
|
2601
|
+
process.exit(0);
|
|
2602
|
+
}
|
|
2603
|
+
const hasLess = spawnSync12("less", ["-V"], { stdio: "ignore" }).status === 0;
|
|
2604
|
+
if (hasLess) {
|
|
2605
|
+
spawnSync12("less", ["-R", guidePath], { stdio: "inherit" });
|
|
2606
|
+
} else {
|
|
2607
|
+
process.stdout.write(readFileSync3(guidePath, "utf8"));
|
|
2608
|
+
}
|
|
2609
|
+
process.exit(0);
|
|
2610
|
+
break;
|
|
2611
|
+
}
|
|
1296
2612
|
case "doctor": {
|
|
1297
2613
|
console.log("\nijfw doctor\n");
|
|
1298
2614
|
console.log(" node: " + doctorCheck("node", ["--version"]));
|