所以利用SyntaxHighlighter就可以很方便的使用了。
網站:
http://alexgorbatchev.com/wiki/SyntaxHighlighter
SyntaxHighlighter是利用JavaScript所寫成的,所以很適合使用在Blogger中。
一下是設定步驟
步驟一:
可以選擇到官網下載最新的程式碼,或是使用官網的網頁版。
兩者有好有壞,前者相較於後者是,除非你擺放程式碼的網路位置連線太慢,要不然前者的連線速度會較快,因為後者會因為太多人使用,造成速度變慢。而後者的好處是方便操作,不需要額外的空間擺放這些程式碼。
若使用前者,則先將裡面的"Scripts"與"styles"內的所有檔案,都上傳至你的網頁空間中。
步驟二:
以使用Blogger為例,到"版面配置/修改HTML/"將以下程式碼貼在"body"之間
步驟三:
可參照以下的範例操作。
#include
int main(){
printf("Hello!");
getch();
return 0;}
說明-
brush:<使用的語言>; gutter:<是否要行號(true|false)>; smart-tabs:gutter:<是否使用tab(true|false)>; table-size:
brush:
可使用的語言有
| Brush name | Brush aliases | File name |
|---|---|---|
| ActionScript3 | as3, actionscript3 | shBrushAS3.js |
| Bash/shell | bash, shell | shBrushBash.js |
| ColdFusion | cf, coldfusion | shBrushColdFusion.js |
| C# | c-sharp, csharp | shBrushCSharp.js |
| C++ | cpp, c | shBrushCpp.js |
| CSS | css | shBrushCss.js |
| Delphi | delphi, pas, pascal | shBrushDelphi.js |
| Diff | diff, patch | shBrushDiff.js |
| Erlang | erl, erlang | shBrushErlang.js |
| Groovy | groovy | shBrushGroovy.js |
| JavaScript | js, jscript, javascript | shBrushJScript.js |
| Java | java | shBrushJava.js |
| JavaFX | jfx, javafx | shBrushJavaFX.js |
| Perl | perl, pl | shBrushPerl.js |
| PHP | php | shBrushPhp.js |
| Plain Text | plain, text | shBrushPlain.js |
| PowerShell | ps, powershell | shBrushPowerShell.js |
| Python | py, python | shBrushPython.js |
| Ruby | rails, ror, ruby | shBrushRuby.js |
| Scala | scala | shBrushScala.js |
| SQL | sql | shBrushSql.js |
| Visual Basic | vb, vbnet | shBrushVb.js |
| XML | xml, xhtml, xslt, html, xhtml | shBrushXml.js |
參考文章:
http://www.inote.tw/2009/02/blogger.html
No comments:
Post a Comment