Description:
As seen on WordPress.com.
SyntaxHighlighter Evolved allows you to easily post syntax-highlighted code to your site without having to escape the code or anything. It uses the SyntaxHighlighter JavaScript package by Alex Gorbatchev to do the highlighting and supports all of the package’s parameters via shortcode attributes.
For a list of supported languages (most widely used languages are supported), see the WordPress.com support document.
Example Code Output:
Note that there are various different color schemes available.
[php htmlscript=”true” highlight=”12″]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>PHP Code Example</title>
</head>
<body>
<h1>PHP Code Example</h1>
<p><?php echo ‘Hello World!’; ?></p>
<p>This line is highlighted.</p>
<div class="foobar">
This is an
example of smart
tabs.
</div>
<p><a href="http://wordpress.org/">WordPress</a></p>
</body>
</html>[/php]
If you prefer, you can hide the line numbering and other UI stuff with the “light” mode, for example:
[code light=”1″][[php light="true"]your code here[/php]][/code]
There are many other parameters and defaults you can control via the Settings page or the shortcode parameters. Full details and instructions are located at the bottom of the Settings page.
Download:
- Download from WordPress.org (0 downloads)
GitHub:
This plugin is available on GitHub. Issues, patches, and pull requests are welcome.
I installed this plugin for my website. Very useful for developers/programmers site!
Pingback: Code Syntax Highlighting | Pedro Pinhal
Pingback: testing syntax coloration in Wordpress « LibreData.org
Hi,
Plugin works fine for PHP but can not get it to display ASP code. Its the percent greater than and less than code delimiters that are causing the problem.
are not displaying, they are being converted into the HTML.
Dave
Thanks for the plugin, it works great almost all of the time.
One problem I have is the following:
[code]
[c]
array[c]
[/c]
[/code]
In the latest version, 3.1.2, the plugin replaces array[c][/c] with array1 which is obviously not what I want it to do, I want it to stay array[c][/c]. I believe this worked correctly in 3.1.1 though so if it could be fixed in a later version I would appreciate it very much!
Thanks again
Sorry for the above formatting, it looks like it got confused with all of the [ c ]’s, let me try wrapping it all in code tags:
[code]
One problem I have is the following:
[c]
array[c]
[/c]
In the latest version, 3.1.2, the plugin replaces array[c] with array1 which is obviously not what I want it to do, I want it to stay array[c]
[/code]
Pingback: Les extensions Wordpress du Katorz | Katorz'
Very good plugin for my blog. Thanks very much. :))
Pingback: ??????????????????????? | WEB KAY
Pingback: gep13's Blog » WordPress Plugins used on blog
Pingback: How to Start a Blog | Brent Ozar PLF
Works brilliantly with csharp and c++ code. My code listings look lovely! Thank you for creating this.
Pingback: WebBiscuit’s Wordpress Plugins » WebBiscuit
Is it possible to eliminate the execution of shortcodes within your codeblocks? I’m writing a plugin that uses shortcodes, but the difficulty of that is: displaying a how to presupposes writing shortcodes which will then get executed.
Automatically? Not really.
Escape it like you would outside of my plugin: use double brackets, like so:
[[shortcode]]or[[foobar]text[/foobar]]Ah… well, I was unaware that escaping like that was even possible, so thanks!
No problem. It’s a little known core WordPress feature.
Hi Alex,
I use Syntaxhighlighter Evolved for over a year now.
Just recently i discovered a problem with Syntaxhighlighter Evolved and the W3 Total Cache plugin: when i enable W3 Total Cache Syntaxhighlighter Evolved stops working under Firefox.
With Google Chrome this problem does not appear.
Do you have a clue?
Thank you in advance.
Best regards,
Dirk Adamsky
vbscriptblog.com
I get the same problem as Dirk with W3 Total Cache and CDN (AS3)
Pingback: La gargouille du web » Wordpress, les pluggins à posséder !
It seems is not working in FF5.
It works fine in Firefox 5: http://alexgorbatchev.com/SyntaxHighlighter/ (demo here)
You are correct however that it doesn’t work on my blog right now. I noticed that a day or two ago and I’m going to assume it’s related to me running the very, very most alpha development version of WordPress here. Bleeding edge can have it’s drawbacks.
To the best of my knowledge it works fine with the latest stable version of WordPress. I’ll track down why it’s not working with WordPress 3.3 when I have a chance.
I think there is something wrong in case of C# code with generics.
Look at the http://www.codemerlin.com/2011/07/mocking-httpcontext-httpresponse-httprequest-httpsessionstate-etc-in-asp-net/. look at the code 3rd code snippet line 44 it puts some tags there. If i disable the plugin then those tags are not there.
Pingback: Design Lunatic » Useful Wordpress Plugins
Pingback: TM's Workspace - WordPress??????????????????
Is it possible to add a flag for controlling the font size?
Thank you! This plugin works perfect on my blog ( host by Sina App Engine) compare to other syntax plugins. I’ve tried them but the toolbar or code area are still wider than the content area after I edited their CSS document.
One question. How to show code text better in feeds for really long sentences? I have a case here (http://yebin.sinaapp.com/2011/07/sae-wordpress-recaptcha-error/). The error code highlighted cannot be displayed fully in Google Reader.
Pingback: TM's Workspace -
Pingback: TM's Workspace - WordPress???????????????????????
This plugin does work, about 20% of the time. It’s quite frustrating since the bug lasts for months then suddenly works again. Reinstalling doesn’t fix it. I’ve looked through the many steps to debug these problems, and never came up with a solution. Like magic, it will suddenly work again. This is disappointing.
My plugin isn’t going to suddenly start and stop working on it’s own. Something else has to be to blame. Perhaps another plugin you’re using?
Pingback: Moving My Blog from WordPress.com to Hosted WordPress.org « Marc D Anderson's Blog
I have updated my WordPress to 3.2.1 and the plugin to 3.1.3 and now it doesn’t work in IE 9 and FF 5.
Hello, after installing WordPress 3.2.1. the plugin become broken…
somebody with same problem?
Pingback: 20 hasznos WordPress plugin
Pingback: Bon plugin de Syntax Highlighter pour WP ! « « Pierre-Luc Ayotte | Pierre-Luc Ayotte
Its good but for some reason it removes the indentation from all my code so i have to go back and put 4 spaces infront of each line to indent it!! its bloody annoying anyone else having that issue?
Yep, doesn’t work on WordPress 3.2.1
I’m using it on 3.2.1 and even in the Options page example, its not working. Sorry!
Pingback: Wordpress Yaz?lar?ndaki Kodlar? Renklendirme | Tnc Blog
Is it possible to get the plugin to work on bbpress by chance? Any help Alex?
I would love to see that, too!
I hadn’t tried that yet. What I have tried (which appears to work) is to take the same approach that has been used to make the plugin buddypress compatible, by adding these specific bbpress filters:
[code]// Display hook
add_filter(‘bbp_get_reply_content’, array( &$this,’parse_shortcodes’),7);
// Into the database
add_filter( ‘bbp_new_reply_pre_content’, array( &$this, ‘encode_shortcode_contents_slashed’ ), 1);
// Out of the database for editing
add_filter( ‘bbp_edit_reply_pre_content’, array(&$this,’decode_shortcode_contents’),1 );[/code]
Ignore my previous comment. I was confused what plugin we were talking about (I was thinking a different one than this).
Thanks for the code. I’ll confirm it works and include it in the next release! 🙂
Cool! 🙂
You’re welcome!
You probably just need to change the
post_type = 'post'part of the query.Oops! I clicked the wrong Reply button. See code in my comment above.
Pingback: 10 Code and Syntax Highlighter WordPress Plugins | fortystones
I am happy to find this post very useful for me, as it contains lot of information.I always prefer to read the quality content and this thing I found in you post. Thanks for sharing.
I found a problem with the display of VB code, but I guess I posted it in the wrong place, see https://github.com/alexgorbatchev/SyntaxHighlighter/issues/5#issuecomment-
thanks
Pingback: Getting WordPress Syntax Highlighter work | Developer Note
Hi , I just updated to WP 3.2.1 and your plugin to version 3.1.3. but it broke all the syntax highlighting. I checked on both FF and Chrome
Please help!
Just to give you guys another data point: WP 3.2.1 + SyntaxHighlighter 3.1.3 works fine in FF 3.6.18 and Opera 11.50 (Linux x86_64). I’m highlighting Arduino code with a custom brush (will publish later when the styles are done) – no code breakage, all indentations untouched. I’m pretty pleased!
Pingback: Arduino Code Syntax Highlighting Plugin for your WordPress Blog
i am struggling so hard to get this off the ground. Does this work with 3.2.1? The code i have is a unsupported code but i actually just want this for the copy and print feature. Still i can not seem to get it working. I’ve configured the options many ways. I tried [sourcecode language=”text”][/sourcecode] among many others and still nothing. any general advise maybe? I’ve read many forums and still nothing.. Thank You.
The code i am using is called thinkscript (thinkorswim) , it is code for stock charts.
It doesnt work with 3.2.1 🙁 I tried on most recent browsers
bummer, i have searched and can find no way to offer visitors a “copy to clipboard” function for code. I have found some post but none of the work… Maybe we’ll get a update..
Install the plugin. 😉
If you go into the setting page, you can select version 2 of the highlighter which has a toolbar and a copy to clipboard button.
Or you can just stick with the default version 3 of the script where you can select and copy it like any other text on a webpage. This is the best solution.
I’ve tried both ad no response, just quotes and a change in text.. I currently have it set to “2” and my parameters are [code lang=”xml”] and [/code] . I’ve tried many combinations and no response. Here’s the link, http://theinfinitygroup.us/valuescript/ , you’ll see the code beneath the picture.. Am i doing something wrong? (obviously, yes) Thanks
I also checked the footer, appears to have everything needed. I’m only decent at this stuff, a work in progress so maybe i missed something.
@justin: It’s very hard to troubleshoot another person’s code but a quick look at the raw HTML of the page at your site shows that right after the syntaxhighlighter’s code (which, BTW looks fine to me: ) you have a very strange tag with a class called “bar show”. Problem is: between words ‘bar” and “show” there are 156(!) spaces. There’s definitely something wrong in that part. Again, don’t know what that is: haven’t seen your code. but you may want to look at the code and, also, try to remove the bar. I think it’s the toolbar in “Display the toolbar” – settings for the plugin.
Good luck!
Sorry that code above was [code lang=”xml”][/code] and [slash code], also tried “text” and others.
Thanks
1) those spaces are intentional and need to remain, do you think that’s messing it up? They need to remain in order to place spaces when the code is implemented.
2) I need to have the toolbar, it’s actually what I really want plugin for. The ability to “copy to clipboard” is the most important feature to me. Thats what I can’t get working.
Thanks.
actually, im wrong, i’m unfamiliar with what is causing these spaces or what “bar show” means. i was thinking of another code..Not sure what is causing either of those..
either way, i am trying to get the copy to clipboard to work , that would be great. i cant even get the line numbers to show up ha, just quotes “”””.