Last active
September 8, 2017 10:20
-
-
Save amay077/6163639 to your computer and use it in GitHub Desktop.
Marked.js で Markdown をクライアント側でパースして表示する ref: http://qiita.com/amay077/items/704d48130e5cf17e8654
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var formatted = marked(markdown_text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Markdown renderer</title> | |
<meta name="description" content="Markdown renderer"> | |
<!-- bootstrap --> | |
<link rel="stylesheet" type="text/css" href="css/bootstrap.css" rel="stylesheet"> | |
<link rel="stylesheet" type="text/css" href="css/bootstrap-responsive.css" rel="stylesheet"> | |
<!-- js libraries --> | |
<script type="text/javascript" src="js/jquery-2.0.3.js"></script> | |
<script type="text/javascript" src="js/marked.js"></script> | |
<script> | |
$(document).ready(function(){ | |
var target = $("#markdown_content"); | |
$.ajax({ | |
url: target[0].attributes["src"].value, | |
}).success(function(data){ | |
target.append(marked(data)); | |
}).error(function(data){ | |
target.append("This content failed to load."); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<!-- Content --> | |
<div class="container"> | |
<div id="markdown_content" src="./sample.markdown"> </div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment