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.

Download:

Example Code Output:

Note that there are various different color schemes available.

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

If you prefer, you can hide the toolbar and line numbering with the “light” mode:

[tag light="true"]your code here[/tag]

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.

  • #301 written by Viper007Bond 
    about 1 month ago

    In Reply To Gabriel Mariani:

    Thanks, but since this code is so widely used, I’d prefer to use only code that has been validated/reviewed by Alex himself. I’ll wait until he okays it. :)

  • #302 written by Jack Perry 
    about 1 month ago

    Viper, I’m curious, whenever I have PHP code and wrap it in the [/php] shortcode, the beginning “” are converted into HTML “<” and “>” in the code box. Any ideas?

  • #303 written by Giammarco Schisani 
    about 1 month ago

    Fantastic plugin.

  • #304 written by rsjs 
    about 1 month ago

    For some reason, I keep getting inserted at random when i try to paste in VB code, any idea why this happens ?

    Nice plugin, but feel the documentation could be better

  • #305 written by Viper007Bond 
    about 1 month ago

    In Reply To rsjs:

    No idea about the VB.

    Some documentation is available at the bottom of the settings page as well as here: http://en.support.wordpress.com/code/posting-source-code/

  • #306 written by chitgoks 
    about 1 month ago

    hi. does the plugin support ?
    because there is an option

    Always load all language files (for directly using tags rather than shortcodes)
    If left unchecked (default), then language files will only be loaded when needed

    i checked that but my existing code in tags doesnt get highlighted. thanks

  • #307 written by Kevin S 
    about 1 month ago
    #authorbox{
        background:#EFEFEF;
        border:1px solid #CECFD0;
        width:638px;
        margin:0 auto;
        margin-bottom:10px;
        overflow:hidden;
    }
        #authorbox h4{
            font-size:16px;
            color:#191919;
            margin:0;
            padding:10px 10px 5px 10px;
        }
    .authortext{
            padding-left:100px;
        }
    #authorbox img{
            margin:0;
            padding:10px;
            float:left;
        }
        #authorbox p{
            color:#191919;
            margin:0;
            padding:0px 10px 10px 10px;
        }
     #authorbox h4 &amp;gt; a{
            text-decoration:none;
        }
    #authorbox p{
            color:#191919;
        }
  • #308 written by Kevin S 
    about 1 month ago

    hi.. above one is my post which dosent work with my Blog.. seems its working here but it is not working for me.. :( My url is:http://annanta.com/archive/how-to-make-an-author-box-in-wordpress/

    Please help me..

  • #309 written by Viper007Bond 
    about 1 month ago
  • #310 written by Kevin S 
    about 1 month ago

    In Reply To Viper007Bond:

    Hi, thanks a lot.. was missing from footer.. :D

  • #311 written by Jimmy Burnett 
    about 1 month ago

    Hey great plugin. Today I’ve been updating and working on my template. Not sure why but my SyntaxHighlighter isn’t working now. Give me any clues? I noticed there isn’t and calls to any external CSS files when I view source. functions.php is clean……hmmmm

  • #312 written by Viper007Bond 
    about 1 month ago

    In Reply To Jimmy Burnett:

    Your theme is likely missing the required footer hook: http://wordpress.org/extend/plugins/syntaxhighlighter/faq/

  • #313 written by Jimmy Burnett 
    about 1 month ago

    Thanks that worked!!

  • #314 written by Jean-Pierre de la Croix 
    about 1 month ago

    Would it be possible to modify the plugin, such that the line numbers and code are separate? It’d be great if the line numbers were not included when one tries to highlight a portion of the code for a copy&paste (else, you have to manually delete the line numbers after the paste).

    Currently, one has to copy the code to the clipboard and then pick out the lines, but it’d be better if that could be done directly on the site instead of on the clipboard.

    P.S.: Great work on this plugin!

  • #315 written by Jimmy Burnett 
    about 1 month ago

    Jean-Pierre de la Croix,
    I see an option to disable the line numbers. You should have the same options under your dashboard.

  • #316 written by Jean-Pierre de la Croix 
    about 1 month ago

    In Reply To Jimmy Burnett:

    Yes, but unfortunately that takes away a lot of the readability.of code that is multiple lines long.

  • #317 written by Jimmy Burnett 
    about 1 month ago

    Jean-Pierre,
    You’re right.

    One idea would be to add a feature that would split the line numbers from the actual line of code. Two tables or Two divs? This way users can easily copy the code without lines numbers.

    Another feature idea is to have an option to set a line number as an “anchor” tag so that bloggers can reference that line number in their blog article. “example… If you look at line 235 of my code below…” and “235″ would link the the line number which is an html anchor.

  • #318 written by Jean-Pierre de la Croix 
    about 1 month ago

    Time to pull the code down from BitBucket and take a look at it :)

  • #319 written by Armin 
    about 1 month ago

    Great plugin, I am using it on my own blog.

  • #320 written by Viper007Bond 
    about 1 month ago

    Jean-Pierre de la Croix on January 26th, 2010 at 10:38 PM2010-01-27T06:38:58ZF jS, Y \a\t g:i A wrote:

    Would it be possible to modify the plugin, such that the line numbers and code are separate? It’d be great if the line numbers were not included when one tries to highlight a portion of the code for a copy&paste (else, you have to manually delete the line numbers after the paste).

    Currently, one has to copy the code to the clipboard and then pick out the lines, but it’d be better if that could be done directly on the site instead of on the clipboard.

    P.S.: Great work on this plugin!

    Use the toolbar in the upper-right of the code box. It’s there for a reason and allows you to see the raw code as well as one-click directly to your clipboard.

  • #321 written by TokkonoPaPa
    about 1 month ago

    Thank you for the great plug-in.
    The color ‘Midnight’ is my best favorite.

    BTW, even if a blog passes XHTML1.0 or 1.1 validation without this
    plug-in, it becomes invalid with this plug-in.

    W3C validator recommends that:
    character “;” is not allowed in the value of attribute “class”
    <pre class=”brush: php; gutter: false;>

    I think separator should be space.

    I hope many WP people like this slight modification.

  • #322 written by Viper007Bond 
    about 1 month ago

    In Reply To TokkonoPaPa:

    I did not write the highlighter, just the WordPress implementation of it. You’d need to take that up with the author of the Javascript package. :)

  • #323 written by TokkonoPaPa
    about 1 month ago

    In Reply To Viper007Bond:

    Thank you for your reply.

    I modified syntaxhighlighter.php as follows to fix my problem with plugin version 2.3.8.

    before modification:

    [/php]$params[] = "brush: $lang;";[php]

    after modification:

    [/php]$params[] = "brush: $lang";[php]

    And also line 846 and 848.

    I apologizes if I have a misunderstanding.

  • #324 written by Viper007Bond 
    about 1 month ago

    In Reply To TokkonoPaPa:

    Ah, I was unaware that it would work without semi-colons. Thanks. :)

  • #325 written by Reuben 
    about 1 month ago

    I’d like to use this plugin, but it doesn’t seem to prevent wordpress from mangling the code. For example, check out the script on http://flavor8.com/index.php/2010/01/30/how-to-rip-your-cds-for-the-lazy-geek/ (search for “The Script”). With this plugin, the # in the shebang is replaced by , quotes are html escaped, etc – and the actual HTML syntax is output.

  • #326 written by Viper007Bond 
    about 1 month ago

    In Reply To Reuben:

    Are you using an editor other than the one in your WordPress admin area by chance? You could also have other plugins that are breaking it. Works fine for me:

    #!/bin/bash
    FROM=1
    NUM=44
    DEV=/dev/powerfilecd1
    function log {
        echo `date` $1
    }
    function cleanup {
        pkill abcde
        rm -fr abcde*
        echo Rip of cd $1 failed >> error.log
    }
    function monitorrip {
        {
            while read line
                do
                    log "$line"
                    # cdparanoia keeps chundering forward even if there's a scsi_read error
                    # this slows things down unacceptably, so we'll just kill the job and move forward
                    echo "$line" | grep "scsi_read error" && cleanup $1 && break
                done
        } | tee
    }
    function ripcd {
        # look for scsi read errors
        abcde -d $DEV -NV 2>&1 | monitorrip $1
    }
    function loadcd {
        date
        # load the cd into the drive, and send the sdparm eject command to make udev notice
        mtx load $1
        sdparm -C eject $DEV
    }
    function unloadcd {
        date
        # send sdparm and eject to flush the cd devices
        sdparm -C stop $DEV
        # not strictly necessary, but your desktop environment might be automounting,
        # so this will force a umount if applicable
        eject $DEV
        sleep 7
        mtx unload $1
    }
    function rip {
       for n in `seq $FROM $NUM`
       do
            echo ____________________________________________________________
            echo RIPPING CD $n
            echo ____________________________________________________________
            date
            loadcd $n
            ripcd $n
            unloadcd $n
       done
    }
    function reset {
        echo Resetting jukebox position
        # this shouldn't be necessary but seems to fix an error condition
        mtx first
        mtx unload 1
    }
    reset
    rip | tee output.txt
  • #327 written by Reuben 
    about 1 month ago

    In Reply To Viper007Bond:

    Ah OK, I found the bug.

    Try a newline after the opening tag, i.e. #!/bin/bash on its own line. That causes the behaviour I noticed.

  • #328 written by Reuben 
    about 1 month ago

    In Reply To Reuben:

    Another interesting variation on this bug; if you change the first few lines to:

    #!/bin/bash

    # which CD to start from
    FROM=39
    # how many CDs are loaded
    NUM=200
    # how many seconds a CD rip can take before we kill it
    TIMEOUT=2400
    # the device to use for ripping
    DEV=/dev/powerfilecd1

    …then the bug kicks in. If you remove the comments, it’s fine.

  • #329 written by Mary 
    about 1 month ago

    This plugin don’t work in my blog. Nothing change. I’m using code
    In Settings works…

    =(

  • #330 written by Viper007Bond 
    about 1 month ago

    In Reply To Reuben:

    Interesting. I’ll see if I can reproduce/debug/fix.

  • #331 written by Fernando 
    about 1 month ago

    Hello,

    I have the plugin syntax highlighter activated and SEO smart links too. Is there a way to disable SEO smart links inside the code that syntax highlighter generates?

    Thank you

  • #332 written by Viper007Bond 
    about 1 month ago

    In Reply To Fernando:

    Visit the settings page. You can control the clickable URLs option there.

  • #333 written by Fernando 
    about 1 month ago

    Good point on that, but I already have clickable URLs disabled, so it shows them as

    Wordpress

    Any other ideas?

  • #334 written by Viper007Bond 
    about 1 month ago

    In Reply To Fernando:

    Oh, I see — another plugin is causing the issue. It should be modified to not touch anything inside of <pre> tags. My plugin is not at fault. :)

  • #335 written by Fernando 
    about 1 month ago

    Not possible. When I activate SEO smart links, I get this problem. When SEO smart links is disabled, no code problems with your plugin linking with stuff.

  • #336 written by Viper007Bond 
    about 1 month ago

    In Reply To Fernando:

    Exactly. This “SEO smart links” plugin is at fault.

  • #337 written by Fernando 
    about 1 month ago

    And any clues about how to fix it?

  • #338 written by Viper007Bond 
    about 1 month ago

    Fernando on February 4th, 2010 at 12:13 AM2010-02-04T08:13:42ZF jS, Y \a\t g:i A wrote:

    And any clues about how to fix it?

    That is something you’d need to take up with the plugin’s author (tell them not to touch anything inside of pre tags).

  • #339 written by Fernando 
    about 1 month ago

    I talked to the SEO smart links author and he told me he has no time to fix it. He would add a patch if I gave it to him.

    Is it too difficult to do it in Syntax Highlighter Evolved code to remove “a” tags at the same time as we disable clickable URLs?

  • #340 written by Viper007Bond 
    about 1 month ago

    In Reply To Fernando:

    Then how would someone post the source code of a link? I’m sorry, but there’s nothing that can be done on my end. :)

  • #341 written by Mark 
    about 1 month ago

    It’d be lovely if the plugin also looked at the RSS feed, ensuring that long lines were sanely wrapped.

    e.g.

    This is a very long line of code which will cause problems when formatted as pre in the RSS feed

    becomes

    This is a very long line of code which will
    + cause problems when formatted as pre
    + in the RSS feed

  • #342 written by Kristoffer 
    about 1 month ago

    I can’t get it working on my website. What do I do wrong? I write

    <?php
    phpinfo();
    ?>

    for example. And it don’t show it with the syntax highlighted.

  • #343 written by Kristoffer 
    about 1 month ago

    Is there anything I have to add anywhere? – it’s a costum template. I’m running WP 2.9.1

  • #344 written by Viper007Bond 
    about 1 month ago
  • #345 written by Kristoffer 
    about 1 month ago

    Many thank you for the quick answer. I added the code, and it works now… :)

  • #346 written by André de Mello 
    about 1 month ago

    CongratulationsS!
    The plugin is very nice!

  • #347 written by ?????? 
    about 3 weeks ago

    ??? ?????.
    Thank you, very good help!

  • #348 written by Federico 
    about 2 weeks ago

    Hi, this is a great plugin, but my theme doesn’t have on footer.php, it’s not a tipical theme, is Carrington. Is there anyway I can get Syntax Highlighter to work? Because it broke all the code and perhaps is for the missing of that line on the footer.Thanks!

  • #349 written by Viper007Bond 
    about 2 weeks ago

    In Reply To Federico:

    wp_footer() is a required WordPress theme hook. All themes need to have it. It doesn’t really matter where it is (it could be in your sidebar if you wanted), but it needs to be somewhere.

  • #350 written by BdF 
    about 5 days ago

    I had the same problem with HTML entities “suddenly” appearing instead of their actual characters (plugin version 2.2.1, WP 2.91, French locale). I traced it down to one particular plugin: WP-OPTIMIZE. Don’t know what optimisation it does on the DB but it is after running it that the entities appeared. I deleted then repasted the code in my articles and all is fine.

    I still can’t get the tabbing to show up though, even though I have the Use smart tabs option ticked. Am copying & pasting direct from Notepad++

  • #351 written by Viper007Bond 
    about 5 days ago

    In Reply To BdF:

    Try switching to HTML view if you’re using TinyMCE. TinyMCE can be buggy.

  • #352 written by Mitko 
    about 5 days ago

    First, let me thank you for a great plugin!
    I am having a problem with getting the plugin to not convert HTML entities on WordPress pages. I want to include some HTML code into one of my WP pages (not posts).
    I am using the HTML view instead of the TinyMCE editor. I added the text:

    <div>
    

    and it appeared as this:

    <div>

    The plugin works on posts just fine. Any advice?

  • #353 written by Mitko 
    about 5 days ago

    In Reply To Mitko:

    OK, the formatting messed things up. The second section was supposed to be:

    &lt;div&gt;
    

    Thanks

  • #354 written by Viper007Bond 
    about 5 days ago

    In Reply To Mitko:

    Sounds like another plugin is causing the issue as pages are literally just a type of post. My plugin doesn’t know the difference.

  • #355 written by Mitko 
    about 5 days ago

    Well, I did some more debuging and here is what I found:
    in the function maybe_output_scripts(), the array $this->usedburshes (line 502) is empty when displaying a page and non empty when displaying a post.

    Hope this gives you a hint?

  • #356 written by Mitko 
    about 5 days ago

    Nevermind, figure it out – the “lang” variable does not recognize “html”, I have to use “xml” and also the plugin content looks wrong only when doing a page preview. When I save the page, it seems to work. Odd!

    Thank you

Page generated with 38 queries in 0.58831 seconds ( 95.18% PHP, 4.82% MySQL )