11一/120
程序员不能没有的WordPress语法高亮插件Crayon Syntax Highlighter
尝试了几个语法高亮的插件,比如 WP-Syntax,Syntax Highlighter 都有让人很不爽的问题,
最终找到了 Crayon Syntax Highlighter, 支持的语法有:C,C#,C++,CSS,Java,JavaScript,Monkey,Objective-C,PHP,Python,Shell,Visual Basic,XHTML.
后台设置非常详细和方便,有很酷的暗色风格配色和程序员字体Consolas!
使用方法是在HTML编辑模式下,
<pre lang="c++">这里贴代码</pre>
要注意,不要切换回可视化编辑模式,否则代码中的非法html字符会发生讨厌的变化
下面是一段C++代码的例子:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#include <iostream>
using std::cout;
using std::endl;
#include <vector> // vector class-template definition
#include <algorithm> // copy algorithm
#include <iterator> // ostream_iterator iterator
#include <stdexcept> // out_of_range exception
int main()
{
int array[ 6 ] = { 1, 2, 3, 4, 5, 6 };
std::vector< int > integers( array, array + 6 );
std::ostream_iterator< int > output( cout, " " );
integers.push_back( 2 );
integers.push_back( 3 );
integers.push_back( 4 );
cout << "Vector integers contains: ";
std::copy( integers.begin(), integers.end(), output );
// insert elements from array
integers.insert( integers.begin(), array, array + 6 );
cout << "\n\nContents of vector integers before clear: ";
std::copy( integers.begin(), integers.end(), output );
return 0;
} |
有一个小瑕疵,不知道是不是Firefox的问题,在代码后面的字体变小了,Chrome下没问题。
© 2012, codename::boilingbit. 版权所有. 署名-非商业性使用-相同方式共享 (by-nc-sa)