之前一直以為syntaxhighlighter2.0要付費才能下載使用,今天才在海芋大大的噗浪看到原來syntaxhighlighter2.0可以免費下載,使用blogger的網友可以參考海芋大大的這篇教學使用:
在 Blogger 中插入美觀的程式碼 ~ 使用syntaxhighlighter 2.0 實戰

而痞客邦的安裝方法基本上也是大同小異的,請參考海芋大大的教學,把整個程式碼載下來,放在自己的主機中,然後再到blog中加入程式碼,由於我不太喜歡在<body>內把Style引入,所以直接將Style在CSS中做引入,請在CSS最上方加入(其中yourhost為你的主機網址):

@import url("yourhost/styles/shCore.css");
@import url("yourhost/styles/shThemeDefault.css");
接著,在痞客邦的側邊欄位或是公告欄位中,加入以下程式碼,就完成囉!
(當然如果你不需要用到這麼多的話,不用把全部的語言都引入,引入太多檔案是會耗讀取時間的。)
<script type="text/javascript" src="yourhost/scripts/shCore.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushBash.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushCSharp.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushCss.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushDelphi.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushDiff.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushGroovy.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushJava.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushJScript.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushPhp.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushPlain.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushPython.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushRuby.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushScala.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushSql.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushVb.js"></script>
<script type="text/javascript" src="yourhost/scripts/shBrushXml.js"></script>
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = 'yourhost/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>

最後,就可使用以下語法在痞客邦中使用語法高亮效果囉(brush:語言類別)

<pre class="brush: css;">
這裡放置語法內容
</pre>
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 bshadow 的頭像
    bshadow

    發卡布洛

    bshadow 發表在 痞客邦 留言(2) 人氣()