Commit 762c52ba authored by tyyin lan's avatar tyyin lan

fix: markdown-render渲染代码块出错

parent 5b8ffb5a
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref, watchEffect } from 'vue' import { computed, ref, watchEffect } from 'vue'
import { marked } from 'marked' import { Marked } from 'marked'
import { markedHighlight } from 'marked-highlight' import { markedHighlight } from 'marked-highlight'
import { throttle } from 'lodash-es' import { throttle } from 'lodash-es'
import DOMPurify from 'dompurify' import DOMPurify from 'dompurify'
...@@ -20,7 +20,7 @@ const props = withDefaults(defineProps<Props>(), { ...@@ -20,7 +20,7 @@ const props = withDefaults(defineProps<Props>(), {
color: '#333', color: '#333',
}) })
marked.use({ gfm: true, async: true }).use( const marked = new Marked(
markedHighlight({ markedHighlight({
emptyLangClass: 'hljs', emptyLangClass: 'hljs',
langPrefix: 'hljs language-', langPrefix: 'hljs language-',
...@@ -30,7 +30,7 @@ marked.use({ gfm: true, async: true }).use( ...@@ -30,7 +30,7 @@ marked.use({ gfm: true, async: true }).use(
return hljs.highlight(code, { language }).value return hljs.highlight(code, { language }).value
}, },
}), }),
) ).use({ gfm: true, async: true })
const renderTextContent = ref('') const renderTextContent = ref('')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment