feat(markdown): make spoiler tags case-insensitive like BBCode

This commit is contained in:
plebeius
2026-03-09 15:31:53 +08:00
parent c3cfc7d63a
commit cf55eaa781
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -145,7 +145,7 @@ type Token =
| { type: 'crossBoardLink'; display: string; route: string }
| { type: 'spoiler'; tokens: Token[] };
const SPOILER_REGEX = /\[spoiler\]([\s\S]*?)\[\/spoiler\]/;
const SPOILER_REGEX = /\[[sS][pP][oO][iI][lL][eE][rR]\]([\s\S]*?)\[\/[sS][pP][oO][iI][lL][eE][rR]\]/;
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<\[\].,;:!?\"'\)\]>]/;
+1 -1
View File
@@ -23,7 +23,7 @@ export function getTextColorForBackground(rgb: string): string {
export function removeMarkdown(md: string): string {
return md
.replace(/\[spoiler\](.*?)\[\/spoiler\]/gs, '$1') // spoiler tags - keep inner text
.replace(/\[spoiler\](.*?)\[\/spoiler\]/gis, '$1') // spoiler tags - keep inner text
.replace(/\[([^\]]*?)\]\([^)]*\)/g, '$1') // [text](url) -> text
.replace(/&nbsp;/g, ' ') // &nbsp; -> space
.replace(/^>\s*/gm, '') // greentext at line start