Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created June 24, 2012 14:11
Show Gist options
  • Save zeffii/2983357 to your computer and use it in GitHub Desktop.
Save zeffii/2983357 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>
@AndersonChoi
Copy link

Thank you~

@Chamane
Copy link

Chamane commented Nov 15, 2019

If I don't know the name of the markdown file. Can I use its extension to import it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment