Created
July 9, 2019 08:51
-
-
Save wuzhefang/acb916631ed8e9b68ba1656ebbdb5f47 to your computer and use it in GitHub Desktop.
marked + mermaid demo html
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> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Marked in the browser</title> | |
</head> | |
<body> | |
<div id="content"></div> | |
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> | |
<script> | |
var renderer = new marked.Renderer(); | |
renderer.code = function (code, language) { | |
if(code.match(/^sequenceDiagram/)||code.match(/^graph/)){ | |
return '<div class="mermaid">'+code+'</div>'; | |
} else { | |
return '<pre><code>' + code + '</code></pre>' | |
} | |
}; | |
document.getElementById('content').innerHTML = | |
marked('## demo \n\n```\ngraph LR\nA-->B\nB-->C\nC-->A\nD-->C\n```\n Hello **world!**', { renderer: renderer }); | |
</script> | |
<script src="https://unpkg.com/mermaid@7.1.0/dist/mermaid.min.js"></script> | |
<script> | |
mermaid.initialize({startOnLoad:true}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment