Skip to content

Instantly share code, notes, and snippets.

@kristopherjohnson
Created June 1, 2012 13:48
Show Gist options
  • Save kristopherjohnson/2852290 to your computer and use it in GitHub Desktop.
Save kristopherjohnson/2852290 to your computer and use it in GitHub Desktop.
Web page with dynamic loading and conversion of Markdown to HTML
<!DOCTYPE html>
<html>
<head>
<title>My Markdown Content</title>
<meta name="viewport" content="width=device-width" >
<style>
#status {
font-style: italic;
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<!-- Obtain Markdown.Converter.js from http://code.google.com/p/pagedown/ -->
<script src="Markdown.Converter.js"></script>
<script>
$(document).ready(function() {
$("#status").html("<p>Loading page content...</p>");
// Load the Markdown file and convert it to HTML for display
var markdownURL = "mycontent.markdown";
$.get(markdownURL, function(markdownContent) {
var converter = new Markdown.Converter();
var htmlContent = converter.makeHtml(markdownContent);
$("div#content").html(htmlContent);
});
});
</script>
</head>
<body>
<div id="content">
<div id="status">
<p>JavaScript must be enabled in your browser to view this page.</p>
</div>
</div>
</body>
</html>
@seanvosler
Copy link

omg thank you

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