mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
11 lines
292 B
JavaScript
11 lines
292 B
JavaScript
const hljs = require('highlight.js');
|
|
|
|
module.exports = function highlight(str, lang) {
|
|
if (lang && hljs.getLanguage(lang)) {
|
|
// https://github.com/highlightjs/highlight.js/issues/2277
|
|
return hljs.highlight(str, { language: lang, ignoreIllegals: true }).value;
|
|
}
|
|
|
|
return '';
|
|
};
|