SyntaxHighlighter Evolved

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:

GitHub:

This plugin is available on GitHub. Issues, patches, and pull requests are welcome.

https://github.com/Viper007Bond/syntaxhighlighter

1,818 thoughts on “SyntaxHighlighter Evolved

  1. Pingback: Code Syntax Highlighting | Pedro Pinhal

  2. Pingback: testing syntax coloration in Wordpress « LibreData.org

  3. 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

  4. 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]

  5. Pingback: Les extensions Wordpress du Katorz | Katorz'

  6. Pingback: ??????????????????????? | WEB KAY

  7. Pingback: gep13's Blog » WordPress Plugins used on blog

  8. Pingback: How to Start a Blog | Brent Ozar PLF

  9. Pingback: WebBiscuit’s Wordpress Plugins » WebBiscuit

  10. 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.

  11. 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

  12. Pingback: La gargouille du web » Wordpress, les pluggins à posséder !

    • 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.

  13. Pingback: Design Lunatic » Useful Wordpress Plugins

  14. Pingback: TM's Workspace - WordPress??????????????????

  15. 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.

  16. Pingback: TM's Workspace -

  17. Pingback: TM's Workspace - WordPress???????????????????????

  18. 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.

  19. Pingback: Moving My Blog from WordPress.com to Hosted WordPress.org « Marc D Anderson's Blog

  20. 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.

  21. Pingback: 20 hasznos WordPress plugin

  22. Pingback: Bon plugin de Syntax Highlighter pour WP ! « « Pierre-Luc Ayotte | Pierre-Luc Ayotte

  23. 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?

  24. Pingback: Wordpress Yaz?lar?ndaki Kodlar? Renklendirme | Tnc Blog

      • 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]

  25. Pingback: 10 Code and Syntax Highlighter WordPress Plugins | fortystones

  26. Pingback: Getting WordPress Syntax Highlighter work | Developer Note

  27. 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!

  28. 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!

  29. Pingback: Arduino Code Syntax Highlighting Plugin for your WordPress Blog

  30. 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.

  31. 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.

  32. 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

  33. 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.

  34. @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!

  35. Sorry that code above was [code lang=”xml”][/code] and [slash code], also tried “text” and others.

  36. 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.

  37. 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..

  38. 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 “”””.

Comments are closed.