1
0
mirror of https://github.com/one-among-us/data.git synced 2024-11-10 13:24:50 +08:00

[PR] Merge pull request #219 from LS-KR/main

[+] handle strikethrough
This commit is contained in:
Elihuso Quigley 2024-05-08 23:57:05 +08:00 committed by GitHub
commit 2f3236075e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -153,6 +153,9 @@ function buildPeoplePages() {
// Handle Footnote
markdown = handleFootnote(markdown)
// Handle Delete Line: ~~something~~ to <del>something</del>
markdown = handleDeleteLine(markdown)
// Handle Icon
markdown = handleNoteIcon(markdown)
@ -184,6 +187,12 @@ function handleFootnote(md: string) {
.replace(/(<li id="footnote.*<\/li>)/gs, '<ol>\n$1\n</ol>')
}
function handleDeleteLine(md: string): string {
if (!md.includes('~~')) return md;
return md.replace(/~~(.*?)~~/g, (match, text) => ("<del>" + text + "</del>"));
}
function handleNoteIcon(md: string): string {
if (!md.includes('[!')) return md;
return md.replace(/\[\!(\w+)\](?::\s*(.*))?/g, (match, icon, _) => (Icon[icon as string]));