Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
highlight: (str, lang) => {
require('highlight.js/styles/monokai-sublime.css')
const hljs = require('highlight.js')
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value
} catch (__) {}
}
try {
return hljs.highlightAuto(str).value
} catch (__) {}
return '' // use external default escaping
}
})
highlight: (str, lang) => {
require('highlight.js/styles/github-gist.css')
const hljs = require('highlight.js')
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value
} catch (__) {}
}
try {
return hljs.highlightAuto(str).value
} catch (__) {}
return '' // use external default escaping
}
})
highlight: (code, lang) => {
code = code.trim()
const hljs = require("highlight.js")
// language is recognized by highlight.js
if (lang && hljs.getLanguage(lang)) {
return hljs.highlight(lang, code).value
}
// ...or fallback to auto
return hljs.highlightAuto(code).value
},
})
highlight: function(code, lang) {
const result =
lang && highlight.getLanguage(lang)
? highlight.highlight(lang, code)
: highlight.highlightAuto(code);
return `<div class="hljs">${result.value}</div>`;
},
});
checkValue(config, _res, 'highlight', function(str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return '<pre class="' + pre_class + '"><code class="' + lang + '">' + hljs.highlight(lang, str, true).value + '</code></pre>';
} catch (__) {}
}
return '<pre class="' + pre_class + '"><code class="' + lang + '">' + utils.escapeHtml(str) + '</code></pre>';
}, function(str, lang) {
return '<pre class="' + pre_class + '"><code class="' + lang + '">' + utils.escapeHtml(str) + '</code></pre>';