Last active
November 23, 2016 09:14
-
-
Save Natumsol/eadd399d71fa266dd6f251cbe9797a39 to your computer and use it in GitHub Desktop.
markdown render function
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
function render(data) { | |
// data = data.replace(/^ {1,}/g, " "); | |
data = data.split("\n").map(function (value) { | |
return value.replace(/^[ ]{1,}/g, function (match) { | |
return (new Array(match.length * 4 + 1)).join(" "); | |
}) | |
}).join("\n") | |
var html = md.render(data).replace(/\n/g, "<br />"); | |
$("#target").html(html.replace(/&/g, "&")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment