From 91615dbf4768e319cf50eb347b3138724445254d Mon Sep 17 00:00:00 2001 From: plebeius Date: Fri, 6 Mar 2026 20:54:11 +0800 Subject: [PATCH] feat(markdown): use BBCode-style [spoiler][/spoiler] tags --- src/components/markdown/markdown.tsx | 2 +- src/lib/utils/post-utils.ts | 2 +- src/views/faq/faq.tsx | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/markdown/markdown.tsx b/src/components/markdown/markdown.tsx index b5bece0f..c9a4c63f 100644 --- a/src/components/markdown/markdown.tsx +++ b/src/components/markdown/markdown.tsx @@ -145,7 +145,7 @@ type Token = | { type: 'crossBoardLink'; display: string; route: string } | { type: 'spoiler'; tokens: Token[] }; -const SPOILER_REGEX = /([\s\S]*?)<\/spoiler>/; +const SPOILER_REGEX = /\[spoiler\]([\s\S]*?)\[\/spoiler\]/; const CROSSBOARD_REGEX = />>>\/((?:[a-zA-Z0-9]{1,10}\/(?:[a-zA-Z0-9]{46})?|[a-zA-Z0-9\-.]+(?:\/[a-zA-Z0-9]{46})?))[.,:;!?]*/; const QUOTE_LINK_REGEX = /(?/\w])>>(\d+)(?![\d/])/; const URL_REGEX = /https?:\/\/[^\s<\[\]]*[^\s<\[\].,;:!?\"'\)\]>]/; diff --git a/src/lib/utils/post-utils.ts b/src/lib/utils/post-utils.ts index c075d06f..773d3c48 100644 --- a/src/lib/utils/post-utils.ts +++ b/src/lib/utils/post-utils.ts @@ -23,7 +23,7 @@ export function getTextColorForBackground(rgb: string): string { export function removeMarkdown(md: string): string { return md - .replace(/(.*?)<\/spoiler>/gs, '$1') // spoiler tags - keep inner text + .replace(/\[spoiler\](.*?)\[\/spoiler\]/gs, '$1') // spoiler tags - keep inner text .replace(/\[([^\]]*?)\]\([^)]*\)/g, '$1') // [text](url) -> text .replace(/ /g, ' ') //   -> space .replace(/^>\s*/gm, '') // greentext at line start diff --git a/src/views/faq/faq.tsx b/src/views/faq/faq.tsx index dcb7caab..73cec35e 100644 --- a/src/views/faq/faq.tsx +++ b/src/views/faq/faq.tsx @@ -188,8 +188,8 @@ const FAQ = () => {
Can I mark a submission as a spoiler?
All boards allow you to mask plot-spoiling content. To mark your image as a spoiler, check the [x Spoiler?] box before submission. Spoilerizing text - makes it unreadable to others until they mouse over it. To spoilerize a comment, place {``} tags around the text you wish to hide (ex. " - {``}SPIKE DIES!{``}"). + makes it unreadable to others until they mouse over it. To spoilerize a comment, place {`[spoiler][/spoiler]`} tags around the text you wish to hide + (ex. "{`[spoiler]`}SPIKE DIES!{`[/spoiler]`}").