Skip to content

Instantly share code, notes, and snippets.

@ntrepid8
Last active December 23, 2015 00:18
Show Gist options
  • Save ntrepid8/6552247 to your computer and use it in GitHub Desktop.
Save ntrepid8/6552247 to your computer and use it in GitHub Desktop.
A function to pull markdown documents down (from Dropbox in my case) and convert them to HTML and return the HTML text. It requires the excellent markdown.converter.js (https://code.google.com/p/pagedown/) library.
/**
* Created with PyCharm.
* User: ntrepid8
* Date: 9/9/13
* Time: 4:55 PM
*/
// Markdown Converter get it at https://code.google.com/p/pagedown/
var converter = new Markdown.Converter();
var md2html = (function(){
var m = {};
m.get = function(url, success, error){
$.ajax({
url: url,
type: 'GET',
success: function(data){
if (success){
success(converter.makeHtml(data))
}
},
error: function(jqxhr, textStatus, error){
if (error){error(jqxhr, textStatus, error)}
}
})
};
return m
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment