new functions and js v=

This commit is contained in:
Mateusz Gruszczyński
2026-07-25 17:15:54 +02:00
parent d1d8bb0259
commit 0a02a0880e
31 changed files with 1035 additions and 610 deletions
+7 -11
View File
@@ -1,5 +1,7 @@
import { EMOJI_SHORTCODES } from "@rustpad/emoji-data";
function escapeHtml(value) {
return String(value).replace(/[&<>"']/g, c => ({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"}[c]));
return String(value).replace(/[&<>"']/g, c => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#039;" }[c]));
}
function safeUrl(value) {
@@ -8,13 +10,7 @@ function safeUrl(value) {
return "#";
}
const emoji = {
smile:"😄", joy:"😂", heart:"❤️", thumbs_up:"👍", thumbsup:"👍", thumbs_down:"👎",
fire:"🔥", rocket:"🚀", tada:"🎉", warning:"⚠️", white_check_mark:"✅", x:"❌",
eyes:"👀", bulb:"💡", memo:"📝", pushpin:"📌", bug:"🐛", sparkles:"✨",
thinking:"🤔", clap:"👏", ok_hand:"👌", pray:"🙏", muscle:"💪", coffee:"☕",
tent:"⛺", star:"⭐", checkered_flag:"🏁"
};
const emoji = EMOJI_SHORTCODES;
function inline(value) {
const tokens = [];
@@ -146,7 +142,7 @@ function renderList(lines, start, lineOffset = 0, baseIndent = null, forcedType
}
const classAttr = hasTask ? ` class="contains-task-items"` : "";
return {html: `<${type}${classAttr}>${body}</${type}>`, end: index};
return { html: `<${type}${classAttr}>${body}</${type}>`, end: index };
}
function splitTableRow(line) {
@@ -190,7 +186,7 @@ function collectHeadings(lines) {
const count = used.get(base) || 0;
used.set(base, count + 1);
const id = count ? `${base}-${count + 1}` : base;
headings.push({level: match[1].length, text: match[2], id, index});
headings.push({ level: match[1].length, text: match[2], id, index });
});
return headings;
}
@@ -228,7 +224,7 @@ export function renderMarkdown(source, lineOffset = 0) {
lines[i] = "";
}
const closeList = () => {};
const closeList = () => { };
const closeCode = () => {
const body = escapeHtml(code.join("\n"));
const lang = normalizeLanguage(language);