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; }