Tuesday, September 29, 2009

Syntaxhighlighter for Blogger

在Blog中,
為了讓程式碼看起來更整齊且好閱讀,
有許多大大們引用一些tool,
這些tool可以讓我們更方便來介紹自己post的code,
而我決定使用的是Syntaxhighlighter,
它是利用java script完成的,
以下是google code底下對於Syntaxhighlighter這個project的介紹,


The idea behind SyntaxHighlighter is to allow insertion of colored code snippets on a web page without relying on any server side scripts.


而下面的貼圖是我試著把C++程式貼上來的結果,


// read a file into memory
#include <iostream>
using namespace std;

int main () {
char first, second;

cout << "Please, enter a word: ";
first=cin.get();
cin.sync();

cout << "Please, enter another word: ";
second=cin.get();

cout << "The first word began by " << first << endl;
cout << "The second word began by " << second << endl;

return 0;
}

更清楚的教學及如何使用Syntaxhighlighter可以參考以下的Blog,我就不再贅述了:
http://sharedderrick.blogspot.com/2007/12/blogger-syntaxhighlighter.html

0 意見: