From f38a0cb8446201cd6c937d96da33b58b4427c78f Mon Sep 17 00:00:00 2001 From: Dawid Rycerz Date: Tue, 13 Jan 2026 20:21:16 +0100 Subject: Add alt texts rendering --- src/utils/markdown.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/utils/markdown.ts') diff --git a/src/utils/markdown.ts b/src/utils/markdown.ts index 946d8d8..eaac6e7 100644 --- a/src/utils/markdown.ts +++ b/src/utils/markdown.ts @@ -1,11 +1,16 @@ -import { marked } from "marked"; - -marked.setOptions({ - breaks: true, - gfm: true, -}); +import rehypeStringify from "rehype-stringify"; +import remarkParse from "remark-parse"; +import remarkRehype from "remark-rehype"; +import { unified } from "unified"; +import { rehypeImageCaptions } from "@/plugins/rehype-image-captions"; export function markdownToHtml(markdown: string): string { - const html = marked.parse(markdown); - return typeof html === "string" ? html : ""; + const result = unified() + .use(remarkParse) + .use(remarkRehype, { allowDangerousHtml: true }) + .use(rehypeImageCaptions) + .use(rehypeStringify, { allowDangerousHtml: true }) + .processSync(markdown); + + return String(result); } -- cgit v1.2.3