Prettify 代码高亮
所需 css(放网站 head 中)
<style type=text/css>.prettyprint,pre.prettyprint{white-space:pre-wrap;word-wrap:break-word;background-color:#444;border:1px solid #272822;overflow:hidden;padding:0;margin:20px 0;font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace!important;color:#666}.prettyprint.linenums,pre.prettyprint.linenums{-webkit-box-shadow:inset 40px 0 0 #39382e,inset 41px 0 0 #464741;-moz-box-shadow:inset 40px 0 0 #39382e,inset 41px 0 0 #464741;box-shadow:inset 40px 0 0 #39382e,inset 41px 0 0 #464741}.prettyprint.linenums ol,pre.prettyprint.linenums ol{margin:0 0 0 33px;padding:5px 10px}.prettyprint.linenums ol li,pre.prettyprint.linenums ol li{color:#bebec5;line-height:20px;margin-left:0;list-style:decimal}.prettyprint ol.linenums{margin-bottom:0;background-color:#272822}.prettyprint .com{color:#93a1a1}.prettyprint .lit{color:#ae81ff}.prettyprint .clo,.prettyprint .opn,.prettyprint .pun{color:#f8f8f2}.prettyprint .fun{color:#dc322f}.prettyprint .atv,.prettyprint .str{color:#e6db74}.prettyprint .kwd,.prettyprint .tag{color:#f92659}.prettyprint .atn,.prettyprint .dec,.prettyprint .typ,.prettyprint .var{color:#a6e22e}.prettyprint .pln{color:#66d9ef}
</style>
或单独写在 css 文件中,本站引用
<link rel="stylesheet" type="text/css" href="/zb_users/plugin/FY_Prettify/prettify.css" />
上述 css 本主题下代码上下有 20px 留白,遂可将上述 margin:20px 0 改为 0px
本站引用的 js
<script src=/zb_users/plugin/FY_Prettify/prettify.js type=text/javascript></script>
调用
/* 初始化 prettyPrint 这里我直接置于本站 prettify.js 末尾的 */
$(window).on('load',function(){jQuery("pre").addClass("prettyprint");
prettyPrint();})
jQuery("pre").attr("class","fy-prettyprint linenums");