Skip to content

Instantly share code, notes, and snippets.

@Natumsol
Last active November 23, 2016 09:14
Show Gist options
  • Save Natumsol/eadd399d71fa266dd6f251cbe9797a39 to your computer and use it in GitHub Desktop.
Save Natumsol/eadd399d71fa266dd6f251cbe9797a39 to your computer and use it in GitHub Desktop.
markdown render function
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(/&amp;/g, "&"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment