说明

最近在写一个程序,需要Markdown支持

php 版

安装

Github: https://github.com/erusev/parsedown

composer require erusev/parsedown

Example

$Parsedown = new Parsedown();

echo $Parsedown->text('Hello _Parsedown_!'); # prints: <p>Hello <em>Parsedown</em>!</p>

You can also parse inline markdown only:

echo $Parsedown->line('Hello _Parsedown_!'); # prints: Hello <em>Parsedown</em>!

JavaScript 版

安装

Github: https://github.com/markedjs/marked

<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>

Example

<!DOCTYPE html>
<html>
<head>
    <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
</head>
<body>
<div id="content">
  
</div>
</body>
<script type="text/javascript">
  
            // 这里调用了marked框架中的marked函数实现Markdown2HTML的解析
            document.getElementById("content").innerHTML=marked('# 说明');
</script>
</html>