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