fix: handle crash issue on hljs highlighting (#859)
This commit is contained in:
parent
5b76862a10
commit
848bdbc148
@ -29,7 +29,11 @@ const marked = new Marked(
|
||||
if (lang === undefined || lang === '') {
|
||||
return hljs.highlightAuto(code).value
|
||||
}
|
||||
return hljs.highlight(code, { language: lang }).value
|
||||
try {
|
||||
return hljs.highlight(code, { language: lang }).value
|
||||
} catch (err) {
|
||||
return hljs.highlight(code, { language: 'javascript' }).value
|
||||
}
|
||||
},
|
||||
}),
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user