feat: add markdown rendering for entry descriptions

This commit is contained in:
Your Name
2026-02-18 10:35:12 +02:00
parent ba185a1ac9
commit 32d22bf877

19
src/utils/markdown.ts Normal file
View File

@@ -0,0 +1,19 @@
import { marked } from 'marked'
marked.setOptions({
breaks: true,
gfm: true,
})
export function renderMarkdown(text: string): string {
if (!text) return ''
return marked.parseInline(text) as string
}
export function stripMarkdown(text: string): string {
if (!text) return ''
return text
.replace(/[*_~`#]/g, '')
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')
.replace(/!\[([^\]]*)\]\([^)]+\)/g, '$1')
}