diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2026-01-13 20:21:16 +0100 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2026-01-13 20:21:16 +0100 |
| commit | f38a0cb8446201cd6c937d96da33b58b4427c78f (patch) | |
| tree | 20225ce0df0f95e094a01650a3f7477c5032cd2c /src/utils/markdown.ts | |
| parent | b6e440699e9fca474869bf74ce09f2310f05c620 (diff) | |
Add alt texts rendering
Diffstat (limited to 'src/utils/markdown.ts')
| -rw-r--r-- | src/utils/markdown.ts | 21 |
1 files changed, 13 insertions, 8 deletions
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); } |
