[+] handle strikethrough

pull/219/head
Elihuso 2024-05-06 08:27:44 +08:00
parent b87584b147
commit 1381aca260
1 changed files with 9 additions and 0 deletions

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]));