1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 22:20:06 +02:00
copilot/ui/webpack/embed-markdown-loader/src/highlight.js

16 lines
281 B
JavaScript
Raw Normal View History

2016-10-23 07:27:18 +03:00
const hljs = require('highlight.js');
module.exports = (str, lang) => {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value;
} catch (err) {}
}
try {
return hljs.highlightAuto(str).value;
} catch (err) {}
return '';
};