1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-12-02 20:22:52 +00:00

cleanup js files

This commit is contained in:
Laura
2025-11-04 21:08:59 +01:00
parent d0eec05469
commit f3686c23df
3 changed files with 107 additions and 82 deletions

View File

@@ -21,7 +21,8 @@
token.text = escapeHtml(token.text);
return;
} else if (type !== "code") {
}
if (type !== "code") {
return;
}
@@ -43,15 +44,13 @@
},
renderer: {
code(code) {
code: code => {
const header = `<div class="pre-header">${escapeHtml(code.lang)}<button class="pre-copy" title="Copy code contents"></button></div>`;
return `<pre class="l-${escapeHtml(code.lang)}">${header}<code>${code.text}</code></pre>`;
},
link(link) {
return `<a href="${link.href}" target="_blank">${escapeHtml(link.text || link.href)}</a>`;
},
link: link => `<a href="${link.href}" target="_blank">${escapeHtml(link.text || link.href)}</a>`,
},
hooks: {
@@ -238,7 +237,7 @@
// Remove headings
.replace(/^#+\s*/gm, "")
// Remove links, keeping the link text
.replace(/\[([^\]]+)\]\([^\)]+\)/g, "$1")
.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1")
// Remove bold/italics, keeping the text
.replace(/(\*\*|__|\*|_|~~|`)(.*?)\1/g, "$2")
// Remove images