feature: just switch to discord-markdown instead

I can't be bothered to write my own parser so a billion dependencies it is
This commit is contained in:
Spectralitree
2021-12-11 14:13:39 +01:00
parent 50bbffd451
commit 615c6f3ef9
5 changed files with 70 additions and 28 deletions

View File

@@ -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], `<div class="bq">${parse[i]}</div>`);
}
return text;
}
export function parseMarkdown(text: string) {
text = blockQuote(text);
text = text.replace(/\*{3}(.*?)\*{3}/gim, '<b><i>$1</i></b>');
text = text.replace(/\*{2}(.*?)\*{2}/gim, '<b>$1</b>');
text = text.replace(/\*{1}(.*?)\*{1}/gim, '<i>$1</i>');
text = text.replace(/\n/gim, '<br />')
return text;
}

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { Modal, Card, CardHeader, CardBody, CardTitle, Image, ModalHeader, Col, Row, Button } from 'sveltestrap';
import CardsHeader from '../CardsHeader.svelte';
import { parseMarkdown } from '../../functions';
import { toHTML } from 'discord-markdown';
export let user;
$: htmlDescription = parseMarkdown(user.description);
$: htmlDescription = toHTML(user.description, {embed: true});
let bannerOpen = false;
const toggleBannerModal = () => (bannerOpen = !bannerOpen);