【优化】try mkardown 组件异常,因为 stream 模型可能返回的信息不全
This commit is contained in:
parent
a96a2ec9ec
commit
63638ce4a1
@ -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 = `<div id="copy" data-copy='${code}' style="position: absolute; right: 10px; top: 5px; color: #fff;cursor: pointer;">复制</div>`
|
||||
return `<pre style="position: relative;">${copyHtml}<code class="hljs">${highlightHtml}</code></pre>`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user