diff options
Diffstat (limited to 'src/lib/utility')
| -rw-r--r-- | src/lib/utility/markdown.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/utility/markdown.ts b/src/lib/utility/markdown.ts new file mode 100644 index 0000000..3d086f0 --- /dev/null +++ b/src/lib/utility/markdown.ts @@ -0,0 +1,20 @@ + + + +/*** EXPORT ------------------------------------------- ***/ + +export default (input: string): string => { + return input + .replace(/(\*\*|__)(.*?)\1/g, `<strong>$2</strong>`) /*** bold ***/ + .replace(/(\*|_)(.*?)\1/g, "<em>$2</em>") /*** italic ***/ + .replace(/(\~~)(.*?)\1/g, "<del>$2</del>") /*** strikethrough ***/ + .replace(/'/g, "’") /*** fancy apostrophe ***/ + .replace(/(:nbhyp:)/g, "‑") /*** non‑breaking hyphen ***/ + .replace(/(:nbsp:)/g, " ") /*** non‑breaking space ***/ + .replace(/(\.\.\.)/g, "…") /*** ellipsis ***/ + // .replace(/---/g, "<hr/>") + .replace(/\[([^\]]+)\]\(([^)]+)\)/g, `<a href="$2" target="_blank">$1</a>`); /*** link ***/ + + // TODO + // : check if link is local and if not, add `target="_blank"` +} |