1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-14 15:20:06 +02:00
copilot/ui/docs/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 '';
};