nizel-plugin-alert 0.1.11 → 0.1.13
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/dist/alert.iife.js +253 -53
- package/package.json +1 -1
package/dist/alert.iife.js
CHANGED
|
@@ -1914,9 +1914,16 @@ var NizelAlert = (() => {
|
|
|
1914
1914
|
};
|
|
1915
1915
|
|
|
1916
1916
|
// ../nizel/dist/utils.js
|
|
1917
|
+
var htmlEntities = {
|
|
1918
|
+
"&": "&",
|
|
1919
|
+
"<": "<",
|
|
1920
|
+
">": ">",
|
|
1921
|
+
'"': """
|
|
1922
|
+
};
|
|
1923
|
+
var replaceHtmlEntity = (character) => htmlEntities[character];
|
|
1917
1924
|
var escapeHtml = (value) => {
|
|
1918
1925
|
const text = String(value);
|
|
1919
|
-
return /[&<>"]/.test(text) ? text.
|
|
1926
|
+
return /[&<>"]/.test(text) ? text.replace(/[&<>"]/g, replaceHtmlEntity) : text;
|
|
1920
1927
|
};
|
|
1921
1928
|
var slugify = (value, style = "github") => {
|
|
1922
1929
|
if (style === "classic") {
|
|
@@ -2066,6 +2073,10 @@ var NizelAlert = (() => {
|
|
|
2066
2073
|
...left.variables ?? {},
|
|
2067
2074
|
...right.variables ?? {}
|
|
2068
2075
|
},
|
|
2076
|
+
meta: {
|
|
2077
|
+
...left.meta ?? {},
|
|
2078
|
+
...right.meta ?? {}
|
|
2079
|
+
},
|
|
2069
2080
|
elements: {
|
|
2070
2081
|
...left.elements ?? {},
|
|
2071
2082
|
...right.elements ?? {}
|
|
@@ -2574,36 +2585,31 @@ var NizelAlert = (() => {
|
|
|
2574
2585
|
// ../nizel/dist/parse/emphasis.js
|
|
2575
2586
|
var resolveRemainingEmphasis = (nodes) => {
|
|
2576
2587
|
const tokens = tokenizeEmphasisDelimiters(nodes);
|
|
2577
|
-
let
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2588
|
+
for (let closeIndex = 0; closeIndex < tokens.length; closeIndex += 1) {
|
|
2589
|
+
const closer = tokens[closeIndex];
|
|
2590
|
+
if (closer.type !== "delimiter" || !closer.close || closer.length === 0)
|
|
2591
|
+
continue;
|
|
2592
|
+
for (let openIndex = closeIndex - 1; openIndex >= 0; openIndex -= 1) {
|
|
2593
|
+
const opener = tokens[openIndex];
|
|
2594
|
+
if (opener.type !== "delimiter" || !opener.open || opener.char !== closer.char || opener.length === 0) {
|
|
2583
2595
|
continue;
|
|
2584
|
-
for (let openIndex = closeIndex - 1; openIndex >= 0; openIndex -= 1) {
|
|
2585
|
-
const opener = tokens[openIndex];
|
|
2586
|
-
if (opener.type !== "delimiter" || !opener.open || opener.char !== closer.char || opener.length === 0) {
|
|
2587
|
-
continue;
|
|
2588
|
-
}
|
|
2589
|
-
if (isForbiddenDelimiterMatch(opener, closer))
|
|
2590
|
-
continue;
|
|
2591
|
-
const size = opener.length >= 2 && closer.length >= 2 ? 2 : 1;
|
|
2592
|
-
const children = inlineTokensToNodes(tokens.slice(openIndex + 1, closeIndex));
|
|
2593
|
-
const wrapped = size === 2 ? { type: "strong", children: resolveRemainingEmphasis(children) } : { type: "emphasis", children: resolveRemainingEmphasis(children) };
|
|
2594
|
-
const replacement = [];
|
|
2595
|
-
if (opener.length > size) {
|
|
2596
|
-
replacement.push({ ...opener, length: opener.length - size });
|
|
2597
|
-
}
|
|
2598
|
-
replacement.push({ type: "node", node: wrapped });
|
|
2599
|
-
if (closer.length > size) {
|
|
2600
|
-
replacement.push({ ...closer, length: closer.length - size });
|
|
2601
|
-
}
|
|
2602
|
-
tokens.splice(openIndex, closeIndex - openIndex + 1, ...replacement);
|
|
2603
|
-
changed = true;
|
|
2604
|
-
closeIndex = -1;
|
|
2605
|
-
break;
|
|
2606
2596
|
}
|
|
2597
|
+
if (isForbiddenDelimiterMatch(opener, closer))
|
|
2598
|
+
continue;
|
|
2599
|
+
const size = opener.length >= 2 && closer.length >= 2 ? 2 : 1;
|
|
2600
|
+
const children = inlineTokensToNodes(tokens.slice(openIndex + 1, closeIndex));
|
|
2601
|
+
const wrapped = size === 2 ? { type: "strong", children: resolveRemainingEmphasis(children) } : { type: "emphasis", children: resolveRemainingEmphasis(children) };
|
|
2602
|
+
const replacement = [];
|
|
2603
|
+
if (opener.length > size) {
|
|
2604
|
+
replacement.push({ ...opener, length: opener.length - size });
|
|
2605
|
+
}
|
|
2606
|
+
replacement.push({ type: "node", node: wrapped });
|
|
2607
|
+
if (closer.length > size) {
|
|
2608
|
+
replacement.push({ ...closer, length: closer.length - size });
|
|
2609
|
+
}
|
|
2610
|
+
tokens.splice(openIndex, closeIndex - openIndex + 1, ...replacement);
|
|
2611
|
+
closeIndex = openIndex - 1;
|
|
2612
|
+
break;
|
|
2607
2613
|
}
|
|
2608
2614
|
}
|
|
2609
2615
|
return inlineTokensToNodes(tokens);
|
|
@@ -2972,12 +2978,19 @@ var NizelAlert = (() => {
|
|
|
2972
2978
|
};
|
|
2973
2979
|
|
|
2974
2980
|
// ../nizel/dist/parse/inline.js
|
|
2981
|
+
var inlineTokenPatternWithoutBareEmail = new RegExp("(?<inlineHtml><!-->|<!--->|<!--[\\s\\S]*?-->|<\\?[\\s\\S]*?\\?>|<![A-Z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>|<\\/?[A-Za-z][A-Za-z0-9-]*(?:\\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s\"'=<>`]+))?)*\\s*\\/?>)|(?<hardSpaces> {2,}\\n)|(?<hardBackslash>\\\\\\n)|(?<softBreak>\\n)|(?<!`)(?<codeTicks>`+)(?!`)(?<codeValue>[\\s\\S]*?)(?<!`)\\k<codeTicks>(?!`)|\\\\(?<escaped>[!\"#$%&'()*+,\\-./:;<=>?@[\\\\\\]^_`{|}~])|&(?<entity>[A-Za-z][A-Za-z0-9]+|#[0-9]+|#[xX][0-9A-Fa-f]+);|!\\[(?<refImageAlt>[^\\]]*)\\]\\[(?<refImageLabel>[^\\]]*)\\]|\\[(?<refLinkText>[^\\]`<\\[]+)\\]\\[(?<refLinkLabel>[^\\]]*)\\]|!\\[(?<inlineImageAlt>[^\\]`<]*)\\]\\([ \\t\\n]*(?<inlineImageHref><[^<>\\n\\\\]*>|(?!<)(?:\\\\.|[^() \\t\\n`\\\\]|\\([^()\\n]*(?:\\([^()\\n]*\\)[^()\\n]*)*\\))*)(?:[ \\t\\n]+(?:\"(?<inlineImageTitle>(?:\\\\.|[^\"`])*)\"|'(?<inlineImageTitleSingle>[^']*)'|\\((?<inlineImageTitleParen>[^)]*)\\)))?[ \\t\\n]*\\)|\\[(?<inlineLinkText>[^\\]`<]*)\\]\\([ \\t\\n]*(?<inlineLinkHref><[^<>\\n\\\\]*>|(?!<)(?:\\\\.|[^() \\t\\n`\\\\]|\\([^()\\n]*(?:\\([^()\\n]*\\)[^()\\n]*)*\\))*)(?:[ \\t\\n]+(?:\"(?<inlineLinkTitle>(?:\\\\.|[^\"`])*)\"|'(?<inlineLinkTitleSingle>[^']*)'|\\((?<inlineLinkTitleParen>[^)]*)\\)))?[ \\t\\n]*\\)|<(?<angleUrl>[A-Za-z][A-Za-z0-9+.-]{1,31}:[^<>\\s]*)>|<(?<angleEmail>[A-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?(?:\\.[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?)*)>|!\\[(?<shortcutImageAlt>(?:\\\\\\]|[^\\]`<\\[])+)\\]|\\[(?<shortcutLinkText>(?:\\\\\\]|[^\\]`<\\[])+)\\]|~~(?<deleteValue>[^~`]+)~~|(?<bareUrl>https?:\\/\\/[^\\s<`]+)", "giu");
|
|
2982
|
+
var bareEmailPattern = /(?<bareEmail>[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,})/giu;
|
|
2983
|
+
var inlineTokenPatternWithBareEmail = new RegExp(inlineTokenPatternWithoutBareEmail.source + "|" + bareEmailPattern.source, inlineTokenPatternWithoutBareEmail.flags);
|
|
2975
2984
|
var parseInline = (source, options = { autolinks: true }) => parseInlineWithState(source, options, { references: /* @__PURE__ */ new Map() });
|
|
2976
2985
|
var parseInlineWithState = (source, options = { autolinks: true }, state, extractNestedLinks = true) => {
|
|
2977
2986
|
const autolinks = options.autolinks !== false && getAutolinkOptions(options.autolinks).enabled !== false;
|
|
2978
2987
|
if (!hasInlineSyntax(source, autolinks)) {
|
|
2979
2988
|
return source ? [{ type: "text", value: source }] : [];
|
|
2980
2989
|
}
|
|
2990
|
+
const hasAtSign = source.includes("@");
|
|
2991
|
+
if (!hasAtSign && !hasNonEmphasisSyntax(source)) {
|
|
2992
|
+
return resolveRemainingEmphasis([{ type: "text", value: source }]);
|
|
2993
|
+
}
|
|
2981
2994
|
if (extractNestedLinks && hasBalancedLinkCandidate(source)) {
|
|
2982
2995
|
const scanned = scanBalancedInlineLinks(source, options, state);
|
|
2983
2996
|
if (scanned)
|
|
@@ -2985,10 +2998,14 @@ var NizelAlert = (() => {
|
|
|
2985
2998
|
}
|
|
2986
2999
|
const nodes = [];
|
|
2987
3000
|
const safe = options.safe !== false;
|
|
2988
|
-
const pattern =
|
|
3001
|
+
const pattern = hasAtSign ? inlineTokenPatternWithBareEmail : inlineTokenPatternWithoutBareEmail;
|
|
2989
3002
|
let lastIndex = 0;
|
|
2990
|
-
|
|
2991
|
-
|
|
3003
|
+
while (true) {
|
|
3004
|
+
pattern.lastIndex = lastIndex;
|
|
3005
|
+
const match = pattern.exec(source);
|
|
3006
|
+
if (!match)
|
|
3007
|
+
break;
|
|
3008
|
+
const end = pattern.lastIndex;
|
|
2992
3009
|
if (match.index > lastIndex) {
|
|
2993
3010
|
nodes.push({ type: "text", value: source.slice(lastIndex, match.index) });
|
|
2994
3011
|
}
|
|
@@ -3122,7 +3139,7 @@ var NizelAlert = (() => {
|
|
|
3122
3139
|
} else {
|
|
3123
3140
|
nodes.push({ type: "text", value: match[0] });
|
|
3124
3141
|
}
|
|
3125
|
-
lastIndex =
|
|
3142
|
+
lastIndex = end;
|
|
3126
3143
|
}
|
|
3127
3144
|
if (lastIndex < source.length)
|
|
3128
3145
|
nodes.push({ type: "text", value: source.slice(lastIndex) });
|
|
@@ -3135,6 +3152,9 @@ var NizelAlert = (() => {
|
|
|
3135
3152
|
return true;
|
|
3136
3153
|
return autolinks && (source.includes("http://") || source.includes("https://") || source.includes("@"));
|
|
3137
3154
|
};
|
|
3155
|
+
var hasNonEmphasisSyntax = (source) => {
|
|
3156
|
+
return /[`<&\n[~\\]|https?:\/\//i.test(source);
|
|
3157
|
+
};
|
|
3138
3158
|
var hasBalancedLinkCandidate = (source) => {
|
|
3139
3159
|
return source.includes("[");
|
|
3140
3160
|
};
|
|
@@ -3561,7 +3581,7 @@ ${line}`) !== null;
|
|
|
3561
3581
|
function parseMarkdown(markdown, options) {
|
|
3562
3582
|
const normalizedMarkdown = markdown.includes("\r") ? markdown.replace(/\r\n?/g, "\n") : markdown;
|
|
3563
3583
|
const lines = normalizedMarkdown.includes(" ") ? expandLeadingTabsToLines(normalizedMarkdown) : normalizedMarkdown.split("\n");
|
|
3564
|
-
const { contentLines, references } = normalizedMarkdown.includes("
|
|
3584
|
+
const { contentLines, references } = normalizedMarkdown.includes("]:") && hasPossibleReferenceDefinitionStart(normalizedMarkdown) ? extractReferenceDefinitions(lines) : { contentLines: lines, references: /* @__PURE__ */ new Map() };
|
|
3565
3585
|
const children = parseBlocks(contentLines, options, /* @__PURE__ */ new Map(), { references });
|
|
3566
3586
|
return { type: "root", children };
|
|
3567
3587
|
}
|
|
@@ -3572,7 +3592,8 @@ ${line}`) !== null;
|
|
|
3572
3592
|
const children = [];
|
|
3573
3593
|
for (let index = 0; index < lines.length; index += 1) {
|
|
3574
3594
|
const line = lines[index];
|
|
3575
|
-
|
|
3595
|
+
const trimmed = line.trim();
|
|
3596
|
+
if (!trimmed)
|
|
3576
3597
|
continue;
|
|
3577
3598
|
if (!options.safe) {
|
|
3578
3599
|
const htmlBlock = readHtmlBlock(lines, index);
|
|
@@ -3582,7 +3603,7 @@ ${line}`) !== null;
|
|
|
3582
3603
|
continue;
|
|
3583
3604
|
}
|
|
3584
3605
|
}
|
|
3585
|
-
const customBlock = /^::([A-Za-z][\w-]*)(?:\s+(.*))?$/.exec(
|
|
3606
|
+
const customBlock = /^::([A-Za-z][\w-]*)(?:\s+(.*))?$/.exec(trimmed);
|
|
3586
3607
|
if (customBlock) {
|
|
3587
3608
|
const parsed = readCustomBlock(lines, index);
|
|
3588
3609
|
const args = splitWords(customBlock[2] ?? "");
|
|
@@ -3667,9 +3688,8 @@ ${line}`) !== null;
|
|
|
3667
3688
|
continue;
|
|
3668
3689
|
}
|
|
3669
3690
|
const setext = lines[index + 1] && isSetextUnderline(lines[index + 1]);
|
|
3670
|
-
if (setext &&
|
|
3671
|
-
const
|
|
3672
|
-
const inlineChildren = parseInlineWithState(source, options, state);
|
|
3691
|
+
if (setext && !isBlockStart(line, options, lines, index)) {
|
|
3692
|
+
const inlineChildren = parseInlineWithState(trimmed, options, state);
|
|
3673
3693
|
const text = stripInlineNodes(inlineChildren);
|
|
3674
3694
|
const node = {
|
|
3675
3695
|
type: "heading",
|
|
@@ -4123,6 +4143,167 @@ ${body}
|
|
|
4123
4143
|
].includes(node.type);
|
|
4124
4144
|
}
|
|
4125
4145
|
|
|
4146
|
+
// ../nizel/dist/markdown.js
|
|
4147
|
+
function renderMarkdown(value, options = {}) {
|
|
4148
|
+
const document = "schema" in value ? value : void 0;
|
|
4149
|
+
const body = renderBlocks((document?.ast ?? value).children, options).trim();
|
|
4150
|
+
if (!document || options.frontmatter === false || Object.keys(document.meta).length === 0)
|
|
4151
|
+
return body;
|
|
4152
|
+
return `---
|
|
4153
|
+
${renderYaml(document.meta)}
|
|
4154
|
+
---${body ? `
|
|
4155
|
+
|
|
4156
|
+
${body}` : ""}`;
|
|
4157
|
+
}
|
|
4158
|
+
function renderBlocks(nodes, options) {
|
|
4159
|
+
return nodes.map((node) => renderBlock2(node, options)).filter(Boolean).join("\n\n");
|
|
4160
|
+
}
|
|
4161
|
+
function renderBlock2(node, options) {
|
|
4162
|
+
if (node.type === "paragraph")
|
|
4163
|
+
return renderInline2(node.children);
|
|
4164
|
+
if (node.type === "heading")
|
|
4165
|
+
return `${"#".repeat(node.depth)} ${renderInline2(node.children)}`;
|
|
4166
|
+
if (node.type === "thematicBreak")
|
|
4167
|
+
return "---";
|
|
4168
|
+
if (node.type === "html")
|
|
4169
|
+
return node.value;
|
|
4170
|
+
if (node.type === "code") {
|
|
4171
|
+
const marker = options.fence ?? "`";
|
|
4172
|
+
const length = Math.max(3, longestRun(node.code, marker) + 1);
|
|
4173
|
+
const fence = marker.repeat(length);
|
|
4174
|
+
const meta = node.meta === node.lang ? void 0 : node.meta;
|
|
4175
|
+
const info = [node.lang, meta].filter(Boolean).join(" ");
|
|
4176
|
+
return `${fence}${info}
|
|
4177
|
+
${node.code.replace(/\n$/, "")}
|
|
4178
|
+
${fence}`;
|
|
4179
|
+
}
|
|
4180
|
+
if (node.type === "blockquote")
|
|
4181
|
+
return prefixLines(renderBlocks(node.children, options), "> ");
|
|
4182
|
+
if (node.type === "list") {
|
|
4183
|
+
return node.children.map((item, index) => renderListItem(item, node.ordered ? `${(node.start ?? 1) + index}.` : options.bullet ?? "-", options)).join("\n");
|
|
4184
|
+
}
|
|
4185
|
+
if (node.type === "table")
|
|
4186
|
+
return renderTable(node.children, node.align);
|
|
4187
|
+
if (node.type === "customBlock") {
|
|
4188
|
+
const custom = options.customBlocks?.[node.name];
|
|
4189
|
+
if (custom)
|
|
4190
|
+
return custom(node, { render: (children2) => renderBlocks(children2, options) });
|
|
4191
|
+
const args = node.args?.length ? ` ${node.args.join(" ")}` : "";
|
|
4192
|
+
const props = node.props && Object.keys(node.props).length ? `
|
|
4193
|
+
${renderYaml(node.props)}
|
|
4194
|
+
::` : "";
|
|
4195
|
+
const children = node.children?.length ? `
|
|
4196
|
+
${renderBlocks(node.children, options)}` : "";
|
|
4197
|
+
return `::${node.name}${args}${props}${children}
|
|
4198
|
+
::`;
|
|
4199
|
+
}
|
|
4200
|
+
return "";
|
|
4201
|
+
}
|
|
4202
|
+
function renderInline2(nodes) {
|
|
4203
|
+
return nodes.map((node) => {
|
|
4204
|
+
if (node.type === "text")
|
|
4205
|
+
return escapeText(node.value);
|
|
4206
|
+
if (node.type === "lineBreak")
|
|
4207
|
+
return node.hard ? " \n" : "\n";
|
|
4208
|
+
if (node.type === "strong")
|
|
4209
|
+
return `**${renderInline2(node.children)}**`;
|
|
4210
|
+
if (node.type === "emphasis")
|
|
4211
|
+
return `*${renderInline2(node.children)}*`;
|
|
4212
|
+
if (node.type === "delete")
|
|
4213
|
+
return `~~${renderInline2(node.children)}~~`;
|
|
4214
|
+
if (node.type === "inlineCode")
|
|
4215
|
+
return renderCodeSpan(node.code);
|
|
4216
|
+
if (node.type === "link")
|
|
4217
|
+
return `[${renderInline2(node.children)}](${escapeDestination(node.href)}${node.title ? ` "${node.title.replaceAll('"', '\\"')}"` : ""})`;
|
|
4218
|
+
if (node.type === "image")
|
|
4219
|
+
return `}${node.title ? ` "${node.title.replaceAll('"', '\\"')}"` : ""})`;
|
|
4220
|
+
if (node.type === "inlineHtml")
|
|
4221
|
+
return node.value;
|
|
4222
|
+
return "";
|
|
4223
|
+
}).join("");
|
|
4224
|
+
}
|
|
4225
|
+
function renderListItem(item, marker, options) {
|
|
4226
|
+
const checkbox = item.checked === void 0 ? "" : `[${item.checked ? "x" : " "}] `;
|
|
4227
|
+
const body = renderBlocks(item.children, options);
|
|
4228
|
+
const lines = body.split("\n");
|
|
4229
|
+
return `${marker} ${checkbox}${lines[0] ?? ""}${lines.slice(1).map((line) => `
|
|
4230
|
+
${" ".repeat(marker.length + 1)}${line}`).join("")}`;
|
|
4231
|
+
}
|
|
4232
|
+
function renderTable(rows, align = []) {
|
|
4233
|
+
if (!rows.length)
|
|
4234
|
+
return "";
|
|
4235
|
+
const width = Math.max(...rows.map((row) => row.children.length));
|
|
4236
|
+
const line = (cells) => `| ${Array.from({ length: width }, (_, index) => escapeTable(renderInline2(cells[index]?.children ?? []))).join(" | ")} |`;
|
|
4237
|
+
const divider = `| ${Array.from({ length: width }, (_, index) => align[index] === "center" ? ":---:" : align[index] === "right" ? "---:" : align[index] === "left" ? ":---" : "---").join(" | ")} |`;
|
|
4238
|
+
return [line(rows[0].children), divider, ...rows.slice(1).map((row) => line(row.children))].join("\n");
|
|
4239
|
+
}
|
|
4240
|
+
function renderYaml(value) {
|
|
4241
|
+
return Object.entries(value).flatMap(([key, item]) => {
|
|
4242
|
+
if (Array.isArray(item))
|
|
4243
|
+
return [`${key}:`, ...item.map((entry) => ` - ${yamlScalar(entry)}`)];
|
|
4244
|
+
return [`${key}: ${yamlScalar(item)}`];
|
|
4245
|
+
}).join("\n");
|
|
4246
|
+
}
|
|
4247
|
+
function yamlScalar(value) {
|
|
4248
|
+
if (value === null)
|
|
4249
|
+
return "null";
|
|
4250
|
+
if (typeof value === "boolean" || typeof value === "number")
|
|
4251
|
+
return String(value);
|
|
4252
|
+
const text = String(value);
|
|
4253
|
+
return text === "" || /^[-?:,[\]{}#&*!|>'"%@`]|[:#]\s|\s$|^(true|false|null|-?\d+(\.\d+)?)$/i.test(text) ? JSON.stringify(text) : text;
|
|
4254
|
+
}
|
|
4255
|
+
function renderCodeSpan(code) {
|
|
4256
|
+
const fence = "`".repeat(Math.max(1, longestRun(code, "`") + 1));
|
|
4257
|
+
const padding = code.startsWith("`") || code.endsWith("`") ? " " : "";
|
|
4258
|
+
return `${fence}${padding}${code}${padding}${fence}`;
|
|
4259
|
+
}
|
|
4260
|
+
function longestRun(value, character) {
|
|
4261
|
+
return Math.max(0, ...Array.from(value.matchAll(new RegExp(`\\${character}+`, "g")), (match) => match[0].length));
|
|
4262
|
+
}
|
|
4263
|
+
function prefixLines(value, prefix) {
|
|
4264
|
+
return value.split("\n").map((line) => line ? `${prefix}${line}` : prefix.trimEnd()).join("\n");
|
|
4265
|
+
}
|
|
4266
|
+
function escapeText(value) {
|
|
4267
|
+
return value.replace(/([\\`*_[\]<>])/g, "\\$1");
|
|
4268
|
+
}
|
|
4269
|
+
function escapeLabel(value) {
|
|
4270
|
+
return value.replace(/([\\\]])/g, "\\$1");
|
|
4271
|
+
}
|
|
4272
|
+
function escapeDestination(value) {
|
|
4273
|
+
return value.replaceAll(" ", "%20").replaceAll(")", "%29");
|
|
4274
|
+
}
|
|
4275
|
+
function escapeTable(value) {
|
|
4276
|
+
return value.replaceAll("|", "\\|").replaceAll("\n", "<br>");
|
|
4277
|
+
}
|
|
4278
|
+
|
|
4279
|
+
// ../nizel/dist/document.js
|
|
4280
|
+
var NIZEL_DOCUMENT_SCHEMA = "nizel/document";
|
|
4281
|
+
var NIZEL_DOCUMENT_VERSION = 1;
|
|
4282
|
+
function createNizelDocument(value, meta) {
|
|
4283
|
+
const ast = isRoot(value) ? value : value.ast;
|
|
4284
|
+
const documentMeta = (isRoot(value) ? meta : value.meta) ?? {};
|
|
4285
|
+
assertJsonValue(ast, "ast");
|
|
4286
|
+
assertJsonValue(documentMeta, "meta");
|
|
4287
|
+
return { schema: NIZEL_DOCUMENT_SCHEMA, version: NIZEL_DOCUMENT_VERSION, ast, meta: documentMeta };
|
|
4288
|
+
}
|
|
4289
|
+
function isRoot(value) {
|
|
4290
|
+
return Boolean(value && typeof value === "object" && value.type === "root" && Array.isArray(value.children));
|
|
4291
|
+
}
|
|
4292
|
+
function assertJsonValue(value, path, seen = /* @__PURE__ */ new Set()) {
|
|
4293
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
4294
|
+
return;
|
|
4295
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
4296
|
+
return;
|
|
4297
|
+
if (typeof value !== "object")
|
|
4298
|
+
throw new TypeError(`Nizel ${path} is not JSON-serializable.`);
|
|
4299
|
+
if (seen.has(value))
|
|
4300
|
+
throw new TypeError(`Nizel ${path} contains a circular reference.`);
|
|
4301
|
+
seen.add(value);
|
|
4302
|
+
for (const [key, child] of Object.entries(value))
|
|
4303
|
+
assertJsonValue(child, `${path}.${key}`, seen);
|
|
4304
|
+
seen.delete(value);
|
|
4305
|
+
}
|
|
4306
|
+
|
|
4126
4307
|
// ../nizel/dist/template.js
|
|
4127
4308
|
var renderTemplate = (markdown, data, options) => {
|
|
4128
4309
|
const filters = options.filters ?? {};
|
|
@@ -4196,7 +4377,7 @@ ${body}
|
|
|
4196
4377
|
};
|
|
4197
4378
|
|
|
4198
4379
|
// ../nizel/dist/use-nizel.js
|
|
4199
|
-
function createNizel(options = {}) {
|
|
4380
|
+
function createNizel(options = {}, htmlBackend) {
|
|
4200
4381
|
const presetOptions = options.preset ? resolvePreset(options.preset) : {};
|
|
4201
4382
|
const effectiveOptions = { ...presetOptions, ...options, preset: void 0 };
|
|
4202
4383
|
const baseResolved = resolveOptions(effectiveOptions, {});
|
|
@@ -4225,7 +4406,12 @@ ${body}
|
|
|
4225
4406
|
}
|
|
4226
4407
|
const nizel = process;
|
|
4227
4408
|
nizel.html = async (markdown, runtimeOptions) => {
|
|
4228
|
-
const
|
|
4409
|
+
const prepared = prepareMeta(markdown, runtimeOptions);
|
|
4410
|
+
const source = prepareSource(prepared);
|
|
4411
|
+
const accelerated = htmlBackend?.(source, prepared.resolved);
|
|
4412
|
+
if (accelerated !== void 0)
|
|
4413
|
+
return applyAfterRender(accelerated, prepared.resolved);
|
|
4414
|
+
const { ast, resolved } = prepareMarkdown(markdown, runtimeOptions, prepared, source);
|
|
4229
4415
|
return renderPreparedHtml(ast, resolved);
|
|
4230
4416
|
};
|
|
4231
4417
|
nizel.text = async (markdown, runtimeOptions) => {
|
|
@@ -4238,7 +4424,7 @@ ${body}
|
|
|
4238
4424
|
nizel.meta = async (markdown, runtimeOptions) => {
|
|
4239
4425
|
return prepareMeta(markdown, runtimeOptions).meta;
|
|
4240
4426
|
};
|
|
4241
|
-
nizel.preset = (name) => createNizel(resolvePreset(name));
|
|
4427
|
+
nizel.preset = (name) => createNizel(resolvePreset(name), htmlBackend);
|
|
4242
4428
|
nizel.parse = async (markdown, runtimeOptions) => {
|
|
4243
4429
|
const resolved = resolveRuntime(runtimeOptions);
|
|
4244
4430
|
const extracted = resolved.frontmatter === false ? { markdown, frontmatter: {} } : extractFrontmatter(markdown);
|
|
@@ -4262,16 +4448,13 @@ ${body}
|
|
|
4262
4448
|
unwrapStandaloneImages: resolved.unwrapStandaloneImages === true
|
|
4263
4449
|
});
|
|
4264
4450
|
};
|
|
4451
|
+
nizel.markdown = (value, markdownOptions) => renderMarkdown(value, markdownOptions);
|
|
4452
|
+
nizel.document = async (markdown, runtimeOptions) => {
|
|
4453
|
+
const result = await process(markdown, runtimeOptions);
|
|
4454
|
+
return createNizelDocument(result);
|
|
4455
|
+
};
|
|
4265
4456
|
return nizel;
|
|
4266
|
-
function prepareMarkdown(markdown, runtimeOptions = {}) {
|
|
4267
|
-
const preparedMeta = prepareMeta(markdown, runtimeOptions);
|
|
4268
|
-
let preparedMarkdown = preparedMeta.markdown;
|
|
4269
|
-
for (const plugin of preparedMeta.resolved.plugins ?? []) {
|
|
4270
|
-
const nextMarkdown = plugin.hooks?.beforeParse?.(preparedMarkdown, preparedMeta.resolved);
|
|
4271
|
-
if (nextMarkdown !== void 0) {
|
|
4272
|
-
preparedMarkdown = nextMarkdown;
|
|
4273
|
-
}
|
|
4274
|
-
}
|
|
4457
|
+
function prepareMarkdown(markdown, runtimeOptions = {}, preparedMeta = prepareMeta(markdown, runtimeOptions), preparedMarkdown = prepareSource(preparedMeta)) {
|
|
4275
4458
|
let ast = parseMarkdown(preparedMarkdown, {
|
|
4276
4459
|
anchors: preparedMeta.resolved.anchors !== false,
|
|
4277
4460
|
autolinks: preparedMeta.resolved.autolinks,
|
|
@@ -4335,10 +4518,22 @@ ${body}
|
|
|
4335
4518
|
};
|
|
4336
4519
|
}
|
|
4337
4520
|
}
|
|
4521
|
+
function prepareSource(prepared) {
|
|
4522
|
+
let markdown = prepared.markdown;
|
|
4523
|
+
for (const plugin of prepared.resolved.plugins ?? []) {
|
|
4524
|
+
const next = plugin.hooks?.beforeParse?.(markdown, prepared.resolved);
|
|
4525
|
+
if (next !== void 0)
|
|
4526
|
+
markdown = next;
|
|
4527
|
+
}
|
|
4528
|
+
return markdown;
|
|
4529
|
+
}
|
|
4338
4530
|
function renderPreparedHtml(ast, resolved) {
|
|
4339
4531
|
const html = renderHtml(ast, withAutolinkElements(resolved.elements ?? {}, resolved.autolinks), resolved.blocks ?? {}, {
|
|
4340
4532
|
unwrapStandaloneImages: resolved.unwrapStandaloneImages === true
|
|
4341
4533
|
});
|
|
4534
|
+
return applyAfterRender(html, resolved);
|
|
4535
|
+
}
|
|
4536
|
+
function applyAfterRender(html, resolved) {
|
|
4342
4537
|
let finalHtml = html;
|
|
4343
4538
|
for (const plugin of resolved.plugins ?? []) {
|
|
4344
4539
|
const modified = plugin.hooks?.afterRender?.(finalHtml, resolved);
|
|
@@ -4359,8 +4554,13 @@ ${body}
|
|
|
4359
4554
|
function hasRuntimeOptions(runtimeOptions) {
|
|
4360
4555
|
return Boolean(runtimeOptions && Object.keys(runtimeOptions).length > 0);
|
|
4361
4556
|
}
|
|
4362
|
-
|
|
4363
|
-
|
|
4557
|
+
function createNizelFactory(htmlBackend) {
|
|
4558
|
+
const factory = (options) => createNizel(options, htmlBackend);
|
|
4559
|
+
return Object.assign(factory, {
|
|
4560
|
+
preset: (name) => createNizel(resolvePreset(name), htmlBackend)
|
|
4561
|
+
});
|
|
4562
|
+
}
|
|
4563
|
+
var useNizel = createNizelFactory();
|
|
4364
4564
|
function stringMeta(value) {
|
|
4365
4565
|
return typeof value === "string" ? value : void 0;
|
|
4366
4566
|
}
|