mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-10 07:47:53 +00:00
feat: a whole lot of stuff
This commit is contained in:
parent
a2f22843ee
commit
eba1a4543f
10 changed files with 428 additions and 36 deletions
23
src/functions.ts
Normal file
23
src/functions.ts
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue