views:

429

answers:

6

I'd like to have a good syntax highlighter for my WordPress blog. What options do I have available? I often see one which has well-colored syntax highlighting and options to copy to the clipboard. Does anyone have an idea what tool this is?

A: 

The Definitive Guide on Wordpress Syntax Highlighter Plugins. Does anyone ever try Google search?

mcandre
-1 For the bad attitude. 'Google it' and 'RTFM' are not acceptable answers on Stack Overflow. Welcome to the community. In fact, The original poster specifically said hosted on wordpress.com, which does NOT allow plugins to be installed as far as I know, so your answer does not apply.
Jorge Israel Peña
I googled it and eventually I found the answer in here.
Christy John
+1  A: 

http://wordpress.org/extend/plugins/devformatter/

WP Plugin for various syntax highlighting!

Jacob Nelson
+1  A: 

SyntaxHighlighter is a pretty good tool. It uses JavaScript with CSS classes to mark HTML elements that should be highlighted. It also allows code to be copied to the clipboard and printed.

jacksonakj
+1  A: 

If you don't want to, or can't install stuff on your blog, I suggest you use pygments to highlight your code. I described this here.

Geo
+12  A: 

On wordpress.com, you can't install plugins, so you have to use Wordpress' built-in widget.

Do it like:

[sourcecode language='python']

[/sourcecode]

Note that those tags go inside your visual editor, not the HTML editor.

You can find more information here.

samoz
This is the only correct answer so far. Everyone missed the important little detail that his blog is hosted on wordpress.com, which does not allow the installation of plugins.
Jorge Israel Peña
This seems like a great question for the new WebApps on Stack Exchange
samoz
+1  A: 

Here is an offline option (I know you are asking about online tool but just in case ...)

I use offline tools to process the blog entry with source code examples into html format and then just post the html.

It's really just:

  • offset source code by at least 4 spaces and specify language on the first line like :::html
  • run your file through:

python script:

import markdown
html = markdown.markdown(text,['codehilite'])

I setup markdown with pygments probably you could just use pygments for source code. You run the file thought the script and then copy paste the html to your blog.

You can dump css style, to highlight syntax, from pygments and then either link to it or include it in your page. I'm not sure if wordpress supports that.

Here is how to setup markdown with pygments to do syntax highlighting (for Blogger - the only specifics for Blogger is that it updates the Blogger css with the css to highlight code).

stefanB