diff --git a/src/components/MarkdownView/index.vue b/src/components/MarkdownView/index.vue index 125219cc..bf9ddd60 100644 --- a/src/components/MarkdownView/index.vue +++ b/src/components/MarkdownView/index.vue @@ -20,7 +20,12 @@ const contentRef = ref() // marked 渲染器 const renderer = { code(code, language, c) { - const highlightHtml = hljs.highlight(code, {language: language, ignoreIllegals: true}).value + let highlightHtml + try { + highlightHtml = hljs.highlight(code, {language: language, ignoreIllegals: true}).value + } catch (e) { + // skip + } const copyHtml = `
复制
` return `
${copyHtml}${highlightHtml}
` }