1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-01-17 13:28:35 +01:00

avoid triggering error if hljs is not loaded (fixed #107)

This commit is contained in:
maximebf 2014-03-24 10:34:20 -04:00
parent d142729574
commit 57403a83fd

View File

@ -47,14 +47,20 @@ if (typeof(PhpDebugBar) == 'undefined') {
* @return {String}
*/
var highlight = PhpDebugBar.Widgets.highlight = function(code, lang) {
if (typeof(code) == 'string') {
if (typeof(code) === 'string') {
if (!hljs) {
return htmlize(code);
}
if (lang) {
return hljs.highlight(lang, code).value;
}
return hljs.highlightAuto(code).value;
}
code.each(function(i, e) { hljs.highlightBlock(e); });
if (hljs) {
code.each(function(i, e) { hljs.highlightBlock(e); });
}
return code;
};
/**