Bootstrap

HTML显示markdown文件

在HTML展示markdown文件。

<!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 src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script>
    $(function(){
        $.ajax({
            type:"get",
            url:"html.md",
            dataType:"html",
            success:function(res){
               show(res)
            }
        })

        function show(data) {
            document.getElementById('content').innerHTML = marked.parse(data);
        }
    })
</script>
</body>
</html>
;