fix: some stuff
Some checks failed
Deploy to SFTP Server / build (push) Has been cancelled

This commit is contained in:
Max Richter
2025-10-22 12:58:18 +02:00
parent 5ba54fee6e
commit a27e9046c0
6 changed files with 39 additions and 47 deletions

View File

@@ -1,25 +1,26 @@
import MarkdownIt from 'markdown-it';
import MarkdownIt from "markdown-it";
const parser = new MarkdownIt();
export default function markdownToText(markdown: string): string {
export default function markdownToText(markdown: string = "<empty>"): string {
return parser
.render(markdown)
.split('\n')
.split("\n")
.map((str) => str.trim())
.map((str) => {
return str.replace(/<\/?[^>]+(>|$)/g, '').split('\n');
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
.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(' ');
.join(" ");
}