KayChen

记录技术生活的点点滴滴

0%

php集成Markdown

1.php安装markdown扩展
1
composer require michelf/php-markdown
2.php转化markdown为html
1
2
use \Michelf\MarkdownExtra;
$my_html = MarkdownExtra::defaultTransform($my_text);
3.页面加入语法高亮插件highlight.js
1
2
3
<link rel="stylesheet" href="//cdn.bootcss.com/highlight.js/8.5/styles/default.min.css">
<script src="//cdn.bootcss.com/highlight.js/8.5/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

参考资料:

  1. php-markdown
  2. 语法高亮插件-highlightjs