From 536c54822c2a19f1964b784caba9530eb2543a58 Mon Sep 17 00:00:00 2001 From: Elihuso Quigley Date: Mon, 31 Mar 2025 18:14:13 +0800 Subject: [PATCH] [+] Handle spoilers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit || something || → something --- scripts/feature.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/feature.ts b/scripts/feature.ts index 4a9e2288..7e33f8aa 100644 --- a/scripts/feature.ts +++ b/scripts/feature.ts @@ -22,6 +22,12 @@ function handleDeleteLine(md: string): string { return md.replace(/~~(.*?)~~/g, (match, text) => "" + text + ""); } +function handleSpoiler(md: string): string { + if (!md.includes("||")) return md; + + return md.replace(/\|\|(.*?)\|\|/g, (match, text) => `${text}`); +} + function handleNoteIcon(md: string): string { if (!md.includes("[!")) return md; return md.replace(/\[\!(\w+)\](?::\s*(.*))?/g, (match, icon, _) => Icon[icon as string]); @@ -34,6 +40,9 @@ export function handleFeatures(markdown: string): string { // Handle Delete Line: ~~something~~ to something md = handleDeleteLine(md) + // Handle Spoilers + md = handleSpoiler(md) + // Handle Icon md = handleNoteIcon(md)