Skip to content

Commit

Permalink
feat(lib): create markdown-to-html converter
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfg7 committed Jun 15, 2023
1 parent dd12303 commit 1d815c4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/app/(blog)/feed/markdown-to-html.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { unified } from 'unified'

import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypeStringify from 'rehype-stringify'
import remarkGfm from 'remark-gfm'
import remarkMath from 'remark-math'
import remarkBreaks from 'remark-breaks'
import remarkHint from 'remark-hint'
import rehypeKatex from 'rehype-katex'

export function markdownToHtml(markdown: string) {
const file = unified()
.use(remarkParse)
.use(remarkGfm)
.use(remarkMath)
.use(remarkBreaks)
.use(remarkHint)
.use(remarkRehype)
.use(rehypeKatex)
.use(rehypeStringify)
.processSync(markdown)

return String(file)
}

0 comments on commit 1d815c4

Please sign in to comment.