mirror of
https://github.com/yldio/copilot.git
synced 2024-12-04 17:10:05 +02:00
16 lines
281 B
JavaScript
16 lines
281 B
JavaScript
|
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 '';
|
||
|
};
|