推荐一个好东西:代码发芽网
彻底放弃类似于 SyntaxHighlighter之类的代码高亮插件,
效果如下:
PHP语言: Codee#8786
<?php
function colorCloud($text) {
$text = preg_replace_callback(‘|<a (.+?)>|i’, ‘colorCloudCallback’, $text);
return $text;
}
function colorCloudCallback($matches) {
$text = $matches[1];
$color = dechex(rand(0,16777215));
$pattern = ‘/style=(\’|\”)(.*)(\’|\”)/i’;
$text = preg_replace($pattern, “style=\”color:#{$color};$2;\”“, $text);
return “<a $text>”;
}
add_filter(‘wp_tag_cloud’, ‘colorCloud’, 1);
?>
function colorCloud($text) {
$text = preg_replace_callback(‘|<a (.+?)>|i’, ‘colorCloudCallback’, $text);
return $text;
}
function colorCloudCallback($matches) {
$text = $matches[1];
$color = dechex(rand(0,16777215));
$pattern = ‘/style=(\’|\”)(.*)(\’|\”)/i’;
$text = preg_replace($pattern, “style=\”color:#{$color};$2;\”“, $text);
return “<a $text>”;
}
add_filter(‘wp_tag_cloud’, ‘colorCloud’, 1);
?>
可以直接粘贴HTML代码到文章里,省去了插件的麻烦和开销。。
另:此PHP代码为不用插件实现wordpress标签云
特点如下:
-
无需插件支持blog代码高亮
- 只需复制粘贴即可
- 120多种编程语言
- 30多个流行的高亮主题
- 高亮代码在RSS中依然有效
-
稳定支持各种blog、论坛、邮箱
-
代码收集与共享
- 代码版本管理支持
- 评论、收藏等功能
No related posts.

关键是之前的已经有很多博文使用了SyntaxHighlighter
现在想更换时一件很困难的事情!
[回复]
小烂 回复:
四月 6th, 2010 at 1:34 下午
@Ludou, 我现在也不哟哦你个了。呵呵
[回复]
Ludou 回复:
四月 6th, 2010 at 6:03 下午
@小烂,
也不哟哦你个了???
[回复]
小烂 回复:
四月 7th, 2010 at 10:45 上午
@Ludou, 也不用了。。。-_______________-
发芽网有个缺点,一旦你把代码用他的高亮那么一下,代码就会被他公开展示出来。。。
[回复]
小烂 回复:
一月 26th, 2010 at 8:26 下午
@nobird,
没关系吧 哈哈。。反正需要高亮的 都是要发表的
[回复]
好玩啊!!
[回复]
用vim没有syntax不会把你的眼睛给看坏啊?
[回复]
小烂 回复:
一月 12th, 2010 at 4:57 下午
@littlebear, -__________- 汗。。很可惜时VIM有。。哈哈
[回复]
没看懂,
你的top IE 不喜欢,你也不管了!等你哪?
[回复]
小烂 回复:
一月 12th, 2010 at 10:56 上午
@TT, 我回学校了。。这两天倒腾毕业设计那。。。没功夫弄。。哈哈
抓紧抓紧。一定抓紧。。。。
[回复]