feat: a whole lot of stuff

This commit is contained in:
Spectralitree 2021-12-11 12:01:36 +01:00
parent a2f22843ee
commit eba1a4543f
10 changed files with 428 additions and 36 deletions

23
src/functions.ts Normal file
View file

@ -0,0 +1,23 @@
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;
}