feat: some shit

This commit is contained in:
2024-04-03 14:27:48 +02:00
parent fa5d08e549
commit 195d7dab5d
67 changed files with 2400 additions and 582 deletions

View File

@@ -1,3 +1,25 @@
import MarkdownIt from 'markdown-it';
const parser = new MarkdownIt();
export default function markdownToText(markdown: string): string {
return markdown.replace(/#|`|\*|_|~/g, '');
return parser
.render(markdown)
.split('\n')
.map((str) => str.trim())
.map((str) => {
return str.replace(/<\/?[^>]+(>|$)/g, '').split('\n');
})
.flat()
.filter((str) => !str.startsWith("import")
&& !str.startsWith("export")
&& !str.startsWith("#")
&& !str.startsWith("const")
&& !str.startsWith("function")
&& !str.startsWith("export")
&& !str.startsWith("import")
&& !str.startsWith("&lt;")
&& !str.startsWith("let")
&& str.length > 0
)
.join(' ');
}