经常需要粘贴源代码，就这样显示还真不好看，就找了个插件 Code Snippet ，在同类插件中感觉这个比较好点，支持很多代码：C,html,java,php… 下面是他的介绍：
First off, Code Snippet 2.0 is not mine. I didn’t make it, I won’t take any credit for it. The original creator was the person who hosted a blog at http://blog.enargi.com/codesnippet/ (which no longer works and is apparently down for good; however, it is GPL.). I came across the plugin awhile ago and and I’ve decided that I couldn’t just let it be lost to the ages and I’ll let it live here as long as I’m able.
Straight from the readme.txt, Code Snippet 2.0 is is a WordPress plugin for displaying code with highlighting in blog posts. The plugin uses GeSHi syntax highlighter engine. I’ve seen others, but they’ve gone the way of the dodo and most of them didn’t have as many supported languages at Code Snippet 2.0. I also think that Code Snippet does a better job than the Code Auto-escape plugin.
- Download the plugin here.
- Copy archive to wp-content/plugins directory
- Extract the zip file
- When extracted properly you should have following directory structure: /wp-content/plugins/codesnippet
- Since I’ve not tore through the code, the plugin will probably not work if extracted/copied in diffrenet directory.
- Enable the Plugin
The original author recommended always wrapping your code in a tag; however, I’ve found that you generally don’t need to. To use it, simply surround your code with as such and specify your language type:
And you get this:
Or you could do something like:
If you find a bug in it, drop a comment or an email to wyatt dot neal at gmail and I’ll try my best to fix it for you.
Also, if you have find that your language isn’t here and you write your own GeSHi hack to work with it, let me know and I’ll drop a link on this page so that people can find you. Heck, I’ll even put it in the archive so the world can share it if you want. Here’s the list of supported languages: