From 32d22bf8778dc0b09d171681bbd258da04f1f8e1 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 18 Feb 2026 10:35:12 +0200 Subject: [PATCH] feat: add markdown rendering for entry descriptions --- src/utils/markdown.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/utils/markdown.ts diff --git a/src/utils/markdown.ts b/src/utils/markdown.ts new file mode 100644 index 0000000..a845bd4 --- /dev/null +++ b/src/utils/markdown.ts @@ -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') +}