mirror of
https://github.com/one-among-us/data.git
synced 2025-04-25 15:50:03 +08:00
[+] Handle spoilers
|| something || → <span class="spoiler"><span>something</span></span>
This commit is contained in:
parent
0d7c703dfe
commit
536c54822c
@ -22,6 +22,12 @@ function handleDeleteLine(md: string): string {
|
|||||||
return md.replace(/~~(.*?)~~/g, (match, text) => "<del>" + text + "</del>");
|
return md.replace(/~~(.*?)~~/g, (match, text) => "<del>" + text + "</del>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleSpoiler(md: string): string {
|
||||||
|
if (!md.includes("||")) return md;
|
||||||
|
|
||||||
|
return md.replace(/\|\|(.*?)\|\|/g, (match, text) => `<span class="spoiler"><span>${text}</span></span>`);
|
||||||
|
}
|
||||||
|
|
||||||
function handleNoteIcon(md: string): string {
|
function handleNoteIcon(md: string): string {
|
||||||
if (!md.includes("[!")) return md;
|
if (!md.includes("[!")) return md;
|
||||||
return md.replace(/\[\!(\w+)\](?::\s*(.*))?/g, (match, icon, _) => Icon[icon as string]);
|
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 <del>something</del>
|
// Handle Delete Line: ~~something~~ to <del>something</del>
|
||||||
md = handleDeleteLine(md)
|
md = handleDeleteLine(md)
|
||||||
|
|
||||||
|
// Handle Spoilers
|
||||||
|
md = handleSpoiler(md)
|
||||||
|
|
||||||
// Handle Icon
|
// Handle Icon
|
||||||
md = handleNoteIcon(md)
|
md = handleNoteIcon(md)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user