IT技術(shù)網(wǎng)使用谷歌prettify.js實(shí)現(xiàn)代碼高亮功能

字號:


    目前IT技術(shù)網(wǎng)使用 google-code-prettify 來實(shí)現(xiàn)代碼的高亮顯示,以前IT技術(shù)網(wǎng)使用的是highlight.js 來實(shí)現(xiàn)文章中代碼的高亮顯示,但是highlight.js 顯得很臃腫,加載起來很慢,然而谷歌的prettify.js非常小巧且配置簡單,使用它來實(shí)現(xiàn)代碼的高亮顯示是個(gè)不錯的選擇。下邊我們簡單看看 prettify.js 的使用方法:
    <link href="/templets/css/atr.css" media="screen" type="text/css" rel="stylesheet" />
    <script src="/templets/js/prettify.js"></script>
    <body onload="prettyPrint()">
    <h2>使用prettify.js 實(shí)現(xiàn)代碼高亮</h2>
    <pre>
    <p>IT技術(shù)網(wǎng)提供</p>
    <p>使用 Google Code Prettify 實(shí)現(xiàn)代碼高亮.</p>
    </pre>
    </body>