'use strict'; function heading(text, level) { if (!level || level < 1) { level = 1; } else if (level > 6) { level = 6; } return ` ${"#".repeat(level)} ${text} `; } function link(url, text, opts) { if (opts?.external) { return `${text}`; } return `[${text || url}](${url || "#"}${opts?.title ? ` "${opts.title}"` : ""})`; } function image(url, text, opts) { return `![${text || ""}](${url || "#"}${opts?.title ? ` "${opts.title}"` : ""})`; } function codeBlock(code, lang, opts) { return `\`\`\`${lang || ""}${opts?.ext ? ` ${opts.ext}` : ""} ${code} \`\`\``; } function table(table2) { const header = `| ${table2.columns.join(" | ")} |`; const separator = `| ${table2.columns.map(() => "---").join(" | ")} |`; const body = table2.rows.map((row) => `| ${row.join(" | ")} |`).join("\n"); return `${header} ${separator} ${body}`; } function bold(text) { return `**${text}**`; } function italic(text) { return `_${text}_`; } function boldAndItalic(text) { return `***${text}***`; } function blockquote(text) { const lines = text.split("\n"); const quotedLines = lines.map((line) => `> ${line}`); return quotedLines.join("\n"); } function strikethrough(text) { return `~~${text}~~`; } function hr(length) { return "-".repeat(length || 3); } function list(items, opts = {}) { return items.map( (item, index) => `${opts.ordered ? `${index + 1}.` : opts.char || "-"} ${item}` ).join("\n"); } const render = { __proto__: null, blockquote: blockquote, bold: bold, boldAndItalic: boldAndItalic, codeBlock: codeBlock, heading: heading, hr: hr, image: image, italic: italic, link: link, list: list, strikethrough: strikethrough, table: table }; exports.blockquote = blockquote; exports.bold = bold; exports.boldAndItalic = boldAndItalic; exports.codeBlock = codeBlock; exports.heading = heading; exports.hr = hr; exports.image = image; exports.italic = italic; exports.link = link; exports.list = list; exports.md = render; exports.strikethrough = strikethrough; exports.table = table;