Skip to content

Instantly share code, notes, and snippets.

@Morabaraba
Created May 31, 2016 07:58
Show Gist options
  • Save Morabaraba/4d880b83797330641365de143d021baf to your computer and use it in GitHub Desktop.
Save Morabaraba/4d880b83797330641365de143d021baf to your computer and use it in GitHub Desktop.
20 lines with marked.js and Mithril(Hacked only using ajax)
var s = window.location.search,
mdurl = s.substr(1) !== '' ?
s.substr(s.length - 1) === '/' ?
s.substr(1, s.length - 2) : s.substr(1, s.length - 1) : "md/index.md";
var md = m.request({
method: "GET",
url: mdurl,
deserialize: function(value) {
return value;
}
}).then(function(data) {
var mdcontent = document.getElementById('mdcontent');
mdcontent.innerHTML = marked(data);
document.body.style.display = 'block';
},
function() {
var mdcontent = document.getElementById('mdcontent');
mdcontent.innerHTML = marked("# 404\n Could not find `" + mdurl + "`");
document.body.style.display = 'block';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment