Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(spec => {
let el = document.createElement('div');
if (!spec) {
console.log(`No CodeMirror mode: ${lang}`);
return cb(null, code);
}
try {
Mode.run(code, spec.mime, el);
return cb(null, el.innerHTML);
} catch (err) {
console.log(`Failed to highlight ${lang} code`, err);
return cb(err, code);
}
})
.catch(err => {
.then(spec => {
let el = document.createElement('div');
if (!spec) {
console.log(`No CodeMirror mode: ${lang}`);
return cb(null, code);
}
try {
Mode.run(code, spec.mime, el);
return cb(null, el.innerHTML);
} catch (err) {
console.log(`Failed to highlight ${lang} code`, err);
return cb(err, code);
}
})
.catch(err => {
.then(spec => {
let el = document.createElement('div');
if (!spec) {
console.log(`No CodeMirror mode: ${lang}`);
return cb(null, code);
}
try {
Mode.run(code, spec.mime, el);
return cb(null, el.innerHTML);
} catch (err) {
console.log(`Failed to highlight ${lang} code`, err);
return cb(err, code);
}
})
.catch(err => {
Mode.ensure(lang).then(spec => {
let el = document.createElement('div');
if (!spec) {
console.log(`No CodeMirror mode: ${lang}`);
callback(null, code);
return;
}
try {
Mode.run(code, spec.mime, el);
callback(null, el.innerHTML);
} catch (err) {
console.log(`Failed to highlight ${lang} code`, err);
callback(err, code);
}
}).catch(err => {
console.log(`No CodeMirror mode: ${lang}`);
Mode.ensure(lang).then(spec => {
let el = document.createElement('div');
if (!spec) {
console.log(`No CodeMirror mode: ${lang}`);
callback(null, code);
return;
}
try {
Mode.run(code, spec.mime, el);
callback(null, el.innerHTML);
} catch (err) {
console.log(`Failed to highlight ${lang} code`, err);
callback(err, code);
}
}).catch(err => {
console.log(`No CodeMirror mode: ${lang}`);