Skip to content

Instantly share code, notes, and snippets.

@mattjdever
Forked from zeffii/html.html.html
Created February 20, 2016 19:34
Show Gist options
  • Save mattjdever/7e717b20ef58bcc86f0c to your computer and use it in GitHub Desktop.
Save mattjdever/7e717b20ef58bcc86f0c to your computer and use it in GitHub Desktop.
jquery loading a markdown file and encoding as html
<script>
// get markdown content
var body_location = 'markdown/README.markdown';
function getText(myUrl){
var result = null;
$.ajax( { url: myUrl,
type: 'get',
dataType: 'html',
async: false,
success: function(data) { result = data; }
}
);
FileReady = true;
return result;
}
var markdown_source = getText(body_location);
// convert markdown to html
var output = markdown.toHTML( markdown_source );
document.write(output);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment