2013/09/29

如何在Blogger內幫程式碼上色

像這樣美美的Code大家都愛


#include <stdio.h>

int main() {
    printf("Hello, %s", "Inndy");
}

問題是到底要怎麼做呢?

我使用的是Google開發的 google-code-prettify 這個JavaScript Library
還好Blogger很好心的提供了自訂HTML Template的功能



所以我們可以在裡面塞自己的JavaScript / CSS進去,當然如果你想塞在文章內也可以 XD
主要的 Code 在 http://google-code-prettify.googlecode.com/svn/trunk/src/
而且有提供幾種 Style http://google-code-prettify.googlecode.com/svn/trunk/styles/index.html
我用的 Style 是從 Doxy 這款,再稍微小修改

廢話不說了,我們來動手吧