Skip to content

Instantly share code, notes, and snippets.

@jonasem
Last active August 29, 2015 14:17
Show Gist options
  • Save jonasem/94e5dec99102349ea7b4 to your computer and use it in GitHub Desktop.
Save jonasem/94e5dec99102349ea7b4 to your computer and use it in GitHub Desktop.
marked + mermaid + jquery.get

Leser filer fra samme mappe i .md-format.

Deps må linkes skikkelig.

<!DOCTYPE html>
<html>
<head>
<title>Endringslogg</title>
<style type="text/css">
body {
background: #efefef;
}
div.content {
margin: auto;
background: white;
width: 940px;
padding: 1em 1.5em;
font-family: Segoe UI;
}
</style>
</head>
<body>
<div id="header" class="content">
[Endringer](changelog) | [Api](api) | [Patterns & practices](patterns)
</div>
<div id="content" class="content"></div>
<script src="strapdown/jquery-2.1.3.min.js"></script>
<script src="strapdown/marked.min.js"></script>
<script src="strapdown/mermaid.full.js"></script>
<script type="text/javascript">
$(function() {
loadpage('changelog');
$("#header").html(marked($("#header").html()));
});
var attachEventHandler = function() {
$("a").click(function(event, pa) {
event.preventDefault();
url = event.target.attributes.getNamedItem('href').value;
loadpage(url);
});
}
var loadpage = function(name) {
$.get(name + '.md', function(response) {
$("#content").html(marked(response));
mermaid.init();
attachEventHandler();
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment