fix(@vant/markdown-loader): improve highlight API (#8455)

This commit is contained in:
FunkyZc 2021-04-03 19:30:06 -05:00 committed by GitHub
parent 84332ae68f
commit b80f0a4e8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,8 @@ const hljs = require('highlight.js');
module.exports = function highlight(str, lang) {
if (lang && hljs.getLanguage(lang)) {
return hljs.highlight(lang, str, true).value;
// https://github.com/highlightjs/highlight.js/issues/2277
return hljs.highlight(str, { language: lang, ignoreIllegals: true }).value;
}
return '';