扫码关注官方订阅号
小伙看你根骨奇佳,潜力无限,来学PHP伐。
我用过一个库,不知道能帮你吗https://github.com/chjj/marked
我用这个库做了简单markdown阅读器,可以自己下下来玩玩https://github.com/hjzheng/markdown-reader
语法和代码高亮建议结合 https://github.com/google/code-prettify 一块使用
这个我没试过,但是 marked 将
例如下面的代码用 ' 代替 ` 显示
'''css .class { background: url(data:image/gif;base64,R0lGODl ... ) no-repeat left center; } '''
转成了
<pre> <code class="lang-css"> .class { background: url(data:image/gif;base64,R0lGODl ... ) no-repeat left center; } </code> </pre>
结合 code-prettify ,你只需要在 pre 元素上加上 class=“prettyprint”, 你可以在node中添加,也可以在html用js动态添加
markdownJS
var fs = require('fs'), markdown = require("./markdown"), fileContent; // 读入 Markdown 源文件 fileContent = fs.readFileSync('test.md', 'utf8'); // 使用 MarkdownJS 模块把源文件转换为 HTML 源代码 fileContent = markdown.toHTML(fileContent); // 保存 fs.writeFileSync('test.html', fileContent);
http://www.cnblogs.com/sanshi/archive/2011/03/16/1986468.html
Hexo 中使用的是 marked。
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
我用过一个库,不知道能帮你吗
https://github.com/chjj/marked
我用这个库做了简单markdown阅读器,可以自己下下来玩玩
https://github.com/hjzheng/markdown-reader
语法和代码高亮建议结合 https://github.com/google/code-prettify 一块使用
这个我没试过,但是 marked 将
例如下面的代码
用 ' 代替 ` 显示
转成了
结合 code-prettify ,你只需要在 pre 元素上加上 class=“prettyprint”, 你可以在node中添加,也可以在html用js动态添加
markdownJS
http://www.cnblogs.com/sanshi/archive/2011/03/16/1986468.html
Hexo 中使用的是 marked。