Created
March 29, 2015 21:05
-
-
Save aweigold/1e3c0e2924b8a26886a7 to your computer and use it in GitHub Desktop.
Injecting your rendered markdown into your page with marked and highlight.js
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
<script type="text/javascript"> | |
var req = new XMLHttpRequest(); | |
req.onload = function() { | |
var markdownString = this.responseText; | |
marked.setOptions({ | |
highlight: function (code, lang) { | |
if (lang == undefined){ | |
return code; | |
} | |
return hljs.highlight(lang, code).value; | |
} | |
}); | |
var readmeNode = document.getElementById('README'); | |
readmeNode.innerHTML = marked(markdownString); | |
}; | |
req.open('GET', 'README.md', false); | |
req.send(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment