Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function initializeMarked(): void {
if (initialized) {
return;
}
initialized = true;
marked.setOptions({
gfm: true,
sanitize: false,
tables: true,
// breaks: true; We can't use GFM breaks as it causes problems with tables
langPrefix: `cm-s-${CodeMirrorEditor.DEFAULT_THEME} language-`,
highlight: (code, lang, callback) => {
if (!lang) {
// no language, no highlight
if (callback) {
callback(null, code);
return;
} else {
return code;
}
}
Mode.ensure(lang).then(spec => {
let el = document.createElement('div');
if (!spec) {
console.log(`No CodeMirror mode: ${lang}`);
callback(null, code);
return;