[WordPress] 如何在文章中分享美美的程式碼區塊?

參考網址:理查の學習筆記

使用方法: 把你的程式碼用下方的 tag 包起來, 並在 language 屬性中, 填上程式碼使用的語言.

[sourcecode language="cpp"]
your source code
[/sourcecode]

另外, 如果想特別標記程式碼的某幾行, 可以加入 highlight 屬性.

1
2
3
4
5
6
7
#include
using namespace std;
int main() {
    cout << "Hello World!\n";
    return 0;
}

使用方法如下:

[sourcecode language="cpp" highlight="5,6"]
your source code
[/sourcecode]

關於 sourcecode tag 的細部設定, 請參考 WordPress 官方文件: Posting Source Code
Note: 如果使用上有問題, 請在 HTML view 中檢查上述 tag 是否有被更動. (WordPress 線上編輯器沒有問題)

發表於 程式設計 | 發表迴響

test

test

中文

發表於 程式設計 | 發表迴響

Hello world! 哈囉!

歡迎來到 WordPress。這是你的第一篇文章。編輯或者刪除本篇文章,然後開始你的部落客生活!

發表於 未分類 | 1 則迴響

PHP統計圖

功能強大的統計圖程式

使用PHP與SWF技術

http://www.maani.us/charts/index.php

發表於 未分類 | 1 則迴響