I5TING_TOC转成的HTML,怎样高亮代码

玫瑰小妖 2020-05-10

找到安装位置
全局安装一般在默认位置
C:\Users\administrator\AppData\Roaming\npm\node_modules\i5ting_toc

修改marked.js
i5ting_toc\node_modules\marked\lib\marked.js
将第804行修改如下

if (!lang) {
    return ‘<pre class="prettyprint linenums:0"><code>‘

修改templete.html
i5ting_toc\vendor\template.html
引入google的高亮插件code-prettify

<script type="text/javascript" src="toc/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="toc/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="toc/js/ztree_toc.js"></script>
<script type="text/javascript" src="toc_conf.js"></script>
<script src="https://cdn.jsdelivr.net/gh/google//loader/run_prettify.js"></script> /** 增加这一行 **/
<SCRIPT type="text/javascript" >
$(document).ready(function(){
    var css_conf = eval(markdown_panel_style);
    $(‘#readme‘).css(css_conf)
    
    var conf = eval(jquery_ztree_toc_opts);
        $(‘#tree‘).ztree_toc(conf);
});
</SCRIPT>

再执行编译html命令

i5ting_toc -f sample.md -o

相关推荐