Created
August 13, 2020 20:09
-
-
Save atodorov/06f7bc5105b60d11d425bf5b5d7fb045 to your computer and use it in GitHub Desktop.
async/await demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(this.options && this.options.renderingConfig && this.options.renderingConfig.codeSyntaxHighlighting === true && window.Prism) { | |
function autoLoadLanguage(lang) { | |
return new Promise(resolve => { | |
window.Prism.plugins.autoloader.loadLanguages([lang], function () { | |
console.log('+++ success auto-load', lang); | |
resolve('resolved'); | |
}); | |
}); | |
} | |
markedOptions.highlight = async function(code, lang) { | |
console.log('calling'); | |
const result = await autoLoadLanguage(lang); | |
console.log(result); | |
var grammar = window.Prism.languages[lang]; | |
if (grammar === undefined) { | |
console.error("Undefined Prism.js grammar for", lang); | |
return code; | |
} | |
return window.Prism.highlight(code, grammar, lang); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment