From 615c6f3ef99932c48b87448ab4eeba89bc5d8949 Mon Sep 17 00:00:00 2001 From: Spectralitree <72747870+Spectralitree@users.noreply.github.com> Date: Sat, 11 Dec 2021 14:13:39 +0100 Subject: [PATCH] feature: just switch to discord-markdown instead I can't be bothered to write my own parser so a billion dependencies it is --- package.json | 1 + src/functions.ts | 23 ------------------- src/lib/cards/System.svelte | 4 ++-- style.css | 26 +++++++++++++++++++--- yarn.lock | 44 +++++++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 28 deletions(-) delete mode 100644 src/functions.ts diff --git a/package.json b/package.json index d0f3ca5c..82654d0b 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ }, "dependencies": { "axios": "^0.24.0", + "discord-markdown": "^2.5.1", "svelte-icons": "^2.1.0", "svelte-navigator": "^3.1.5", "sveltestrap": "^5.6.3" diff --git a/src/functions.ts b/src/functions.ts deleted file mode 100644 index dd21fc51..00000000 --- a/src/functions.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { currentUser, loggedIn } from "./stores"; -import PKAPI from "./api"; -import type Sys from './api/system'; - - -function blockQuote(text: string) { - let match = text.match(/(?<=\n|^)(> [^\n]*(?:\n>[^\n]*)*)/gim); - let parse: string[] = []; - for (let i = 0; i < match.length; i++) { - parse[i] = match[i].replace(/(?<=\n|^)> ?/gim, ""); - text = text.replace(match[i], `
${parse[i]}
`); - } - return text; -} - -export function parseMarkdown(text: string) { - text = blockQuote(text); - text = text.replace(/\*{3}(.*?)\*{3}/gim, '$1'); - text = text.replace(/\*{2}(.*?)\*{2}/gim, '$1'); - text = text.replace(/\*{1}(.*?)\*{1}/gim, '$1'); - text = text.replace(/\n/gim, '
') - return text; -} \ No newline at end of file diff --git a/src/lib/cards/System.svelte b/src/lib/cards/System.svelte index 80580ed3..deeadf92 100644 --- a/src/lib/cards/System.svelte +++ b/src/lib/cards/System.svelte @@ -1,10 +1,10 @@