Created
May 31, 2016 07:58
-
-
Save Morabaraba/4d880b83797330641365de143d021baf to your computer and use it in GitHub Desktop.
20 lines with marked.js and Mithril(Hacked only using ajax)
This file contains 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
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