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.

  • #401 written by Viper007Bond 
    about 2 months ago

    In Reply To colin:

    That’s not possible, although you may try wrapping the shortcodes in a div with a fixed height. That might accomplish what you’re looking for.

    If not, try the collapse code boxes option (it’s not what you want, but will avoid long blocks of text).

  • #402 written by colin 
    about 2 months ago

    thanks for the confirmation. i was hoping to avoid a div tag wrapper, but it works fairly well. it’s not perfect though, because the horizontal scroll bar is nested within the div wrapper, which looks a bit odd.

    for others facing this problem, here’s the div i used:

    code here

    to remove gaps between the code area and the parent div, I also had to update the code in shCore.css as follows:

    .syntaxhighlighter
    {
    width: 100% !important; /* 99% fixes IE8 horizontal scrollbar */
    margin: 0 0 0 0 !important;
    padding: 0 !important; /* adds a little border on top and bottom */
    position: relative !important;
    }

    in future, i would love to see an option to set the number of visible lines. e.g., if i put 200 lines into this code:

    
    

    then only 50 would show up. to see the remaining 150 lines, the user would have to scroll down with a vertical scrollbar.

    thanks for a great plugin!

  • #403 written by colin 
    about 2 months ago

    looks like the comments interpreted my sh tags. the two code examples in the previous post should read:

    <div style=”overflow:auto;height:300px;>
    [j a v a]code here[/j a v a]
    </div>

    and:

    [j a v a lines=50]
    [/j a v a]

  • #404 written by Viper007Bond 
    about 2 months ago

    In Reply To colin:

    Sorry, but I didn’t write the highlighter, only the WordPress implementation of it. You’ll need to take it up with Alex G. :)

  • #405 written by colin 
    about 2 months ago

    i see. is alex still maintaining the code? got a url?

    btw, the “copy to clipboard” feature seems to be using flash, and it’s generating lots of warnings and errors. i get:

    Warning: ‘flash’ has no property ‘prototype’
    Warning: ‘StageVideo’ has no property ‘prototype’
    Warning: ‘AsBroadcaster’ has no property ‘addListener’
    Warning: ‘AsBroadcaster’ has no property ‘removeListener’
    Warning: ‘this’ has no property ‘_visible’
    Warning: ‘this’ has no property ‘_visible’
    Warning: Reference to undeclared variable, ‘highlight_mc’
    Warning: Reference to undeclared variable, ‘highlight_mc’
    Warning: onSetFocus is not a function
    Warning: myOnSetFocus is not a function
    Warning: onKillFocus is not a function
    Warning: onSetFocus is not a function
    Warning: myOnKillFocus is not a function
    Warning: myOnSetFocus is not a function
    Warning: onKillFocus is not a function
    Warning: myOnKillFocus is not a function
    Warning: ‘flash’ has no property ‘prototype’
    Warning: ‘StageVideo’ has no property ‘prototype’
    Warning: ‘AsBroadcaster’ has no property ‘addListener’
    Warning: ‘AsBroadcaster’ has no property ‘removeListener’
    Warning: ‘flash’ has no property ‘prototype’
    Warning: ‘StageVideo’ has no property ‘prototype’
    Warning: ‘AsBroadcaster’ has no property ‘addListener’
    Warning: ‘AsBroadcaster’ has no property ‘removeListener’

    and on google chrome, under flash player 10.1.53.7 i get this error:

    Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed.

    (i run the debug version of the player. most people won’t see the error.)

    looks like it might be actionscript 2? would that be alex’s domain too?

    anyway, until this is fixed, is there any way to disable just the clipboard feature (not the entire toolbar)? is that another feature request for alex?

    colin

  • #406 written by colin 
    about 2 months ago

    p.s., here’ the page with the code examples in a scrolling div:
    http://www.unionplatform.com/?page_id=1229

  • #407 written by Viper007Bond 
    about 2 months ago

    In Reply To colin:

    Yes, all of the visitor facing stuff is him. Check out the top of this page for a link to his site. He is currently developing a new version of the highlighter.

  • #408 written by colin 
    about 2 months ago

    gotcha. i reported the issues here:
    http://bitbucket.org/alexg/syntaxhighlighter/issues

  • #409 written by Roy 
    about 2 months ago

    I’d been trying to output this statement.

    <img src='dummy.jpg' height='200' width='400' />

    But e always shows up with < > instead

  • #410 written by Viper007Bond 
    about 2 months ago

    In Reply To Roy:

    Try disabling all other plugins if it’s not working on your blog but it is on mine.

  • #411 written by Roy 
    about 2 months ago

    In Reply To Viper007Bond:

    Hi, I tried publishing the post after I saw the comment here turned out fine. And it works! However, it doesn’t render well in preview mode.

    But that’s no big issue anyway. Thanks.

  • #412 written by HowToDoWiki 
    about 2 months ago

    We installed SyntaxHighlighter Evolved plugin but still it is not showing up the PHP code. Even after uninstalling it, WordPress 3 is running PHP Codes in posts. WP3 does support code and pre functions right? Please take a look – HowToDoWiki PHP Post

  • #413 written by HowToDoWiki 
    about 2 months ago

    In Reply To HowToDoWiki:

    Update: We had to parse code in order to include it in post. Now PHP codes are showing up but not the SyntaxHighlighter. Code and Pre tags are not working on our WordPress 3 installation. Thank you in anticipation.

  • #414 written by Viper007Bond 
    about 2 months ago

    In Reply To HowToDoWiki:

    Please read the documentation. You do not use code or pre tags with this plugin.

    http://wordpress.org/extend/plugins/syntaxhighlighter/installation/

    [php]<?php echo 'Hello world!'; ?>[/php]
  • #415 written by HowToDoWiki 
    about 2 months ago

    In Reply To Viper007Bond:

    Thank you. It is working now :)

  • #416 written by Viper007Bond 
    about 2 months ago
  • #417 written by Dave 
    about 2 months ago

    I LOVE the look of this plugin, unfortunately it would not work properly on my blog. When I would preview, it looked fine. However, after saving the draft special characters were changed. Here are the images of what I’m talking about…

    http://shinytype.com/images/code-good.jpg
    http://shinytype.com/images/code-bad.jpg
    (I use the PHP shortname tags around the code)

    This does not happen when I use the CodeColorer plugin – which works, but doesn’t look nearly as good as yours and doesn’t have much functionality. Maybe it works because it utilizes the tags natively?

    I'd be elated if I just weren't doing something correctly or if there was something I could do to rectify this. Thank you for your time!

  • #418 written by Dave 
    about 2 months ago

    In Reply To Dave:

    Crap. I feel a bit embarrassed – posted this on the wrong plugin page. I thought these were the same plugins for some reason (apparently because I’m a retard?) hehe. The GOOD news, however, is that THIS plugin works brilliantly! Solved the problem. You rock, sir! :) (…still horrendously embarrassed though, haha)

  • #419 written by Viper007Bond 
    about 2 months ago

    In Reply To Dave:

    No problem and glad you like the plugin. :)

  • #420 written by PTKTheBest 
    about 2 months ago

    I have problem with publish post with SyntaxHighlighter with scribefire blog editor… Solution?

  • #421 written by Viper007Bond 
    about 2 months ago

    In Reply To PTKTheBest:

    I have no idea what that is and you haven’t said what the problem is.

  • #422 written by PTKTheBest 
    about 2 months ago

    Scribe Fire is a “Blog Editor” for Firefox. If i post php code (exemple:

     CODE PHP 

    from scribe fire or other blog editor) this have incorrect syntax.

  • #423 written by sarp 
    about 2 months ago

    hey!
    I’ve just installed this plugin to my wordpress but there aooears to be a problem, no matter what the language type is, plugin puts random newlines in codes and 3 lines of code becomes 6-7 lines of code;

    This code appears like;

    I could not figure it out, and wonder what the problem is.
    It would be appriciated if you can help me with this problem.

    p.s I’ve tried disabling all other plugins but did not work..

  • #424 written by sarp 
    about 2 months ago

    oops forget the codes

    <?php
    $connect = mysql_connect($host,$user,$pass);
    $db = mysql_select_database($database,$connect);
    ?>
    

    looks like

    <?php
    $connect
    = mysql_connect(
    $host,$user,$pass
    );
    $db
    = mysql_select_database(
    $database,$connect
    );
    ?>
    

    annoying..

  • #425 written by Viper007Bond 
    about 2 months ago

    In Reply To sarp:

    Since it’s working on my blog, then it’s very likely not my plugin at fault.

    Did you have all other plugins disabled when you wrote the post? If you edit the post, does it look correct or does it have the line breaks? (view in HTML mode to be sure)

  • #426 written by sarp 
    about 2 months ago

    I’ve tried disabling all other plugins and posting a new one but I figured out that installing the plugin to a fresh intallation of WP solves the problem. I guess one of my plugins affects syntaxhighlighter and disabling it does not work for it, anyway thanks for the fast reply if I find out which plugin makes it malfunciton I’ll post it here so that people would know what plugin to install.. :)

  • #427 written by Viper007Bond 
    about 2 months ago

    In Reply To sarp:

    It could be your theme then.

  • #428 written by sam 
    about 2 months ago

    Viper,
    Alex released a beta (http://twitter.com/syntaxhighlight) of the 3.o release at
    http://bitbucket.org/alexg/syntaxhighlighter/src . Are you planning on supporting the new options any time soon?
    Thanks for a great plugin.

    PS: Here is a small feature request for the next version. To match my site, I tweak the default syntax theme CSS file. This obviously gets overwritten with every update of yours. Is there a way that you can support picking up a user’s CSS from a different location out of the plugin dir? WPTouch does this for icons. They use /wp-content/uploads/wptouch/custom-icons/.

  • #429 written by Viper007Bond 
    about 2 months ago

    In Reply To sam:

    I will not be supporting the new version of his highlighter until it goes out of beta.

    I’m currently recoding another plugin (Video Quicktags) and when I’m done with that one, I’ll begin work on updating this one in preparation for his release.

  • #430 written by Ash Menon 
    about 1 month ago

    Hi Alex, first of all, rocking plugin. I’ve tried many others and yours is definitely the easiest to use with the best looking results. But I’ve come across a rather odd problem. I find that certain characters (or combination of them) will break the post altogether, resulting in a 404 page. Examples of characters (each enclosed in parentheses) include (/=) and (; //).

    I don’t think this has anything to do with the plugin per se, since the other syntax plugins have also shown this error on the same characters. I’ll be doing some testing tomorrow to check localhost and WP versions, but I have a stinking suspicion that it’s related to my domain. Have you heard of anything like this before?

  • #431 written by Viper007Bond 
    about 1 month ago

    In Reply To Ash Menon:

    I don’t see how what’s inside the post content would result in a 404.

    Is it a WordPress-themed 404 or a server (Apache, etc.) 404?

  • #432 written by Ash Menon 
    about 1 month ago

    In Reply To Viper007Bond:

    It’s a wordpress 404. In fact it’s the 404 page that I designed. I checked the error logs in my PHP, and it doesn’t show anything.

  • #433 written by Viper007Bond 
    about 1 month ago

    In Reply To Ash Menon:

    A WordPress 404 wouldn’t result in any PHP errors. Never heard of such an issue, but it doesn’t sound related to my plugin.

  • #434 written by Michael 
    about 1 month ago

    Hi Viper,
    I installed and activated your plugin (v2.3.8) and akismet (v2.2.7) into WordPress (v 2.9.2) and all the categories disappear in the display on my blog and in the admin category section. I then deactivated both plugins one at a time and still no resolution however when I then delete your plugin files the categories reappear in the front and backend. I am puzzled do you know of this issue or what may be causing it? I thought at first it could be my theme but the issue was in the admin also. Any help would be appreciated as I would love to use your plugin as well as akismet.

    Thanks

  • #435 written by Viper007Bond 
    about 1 month ago

    In Reply To Michael:

    I don’t see how my plugin files existing while the plugin is deactivated could cause any problems. Plus, the plugin is in use on my blog as well as all of WordPress.com and it doesn’t have any issues on either. It’s worth trying it using the default theme just incase.

  • #436 written by Michael 
    about 1 month ago

    In Reply To Viper007Bond:

    I don’t know what it was but I decided to re-install all elements and all seems well. Thanks for your reply!

  • #437 written by Mehmet 
    about 1 month ago

    Hi Alex,

    I use SyntaxHighlighter Evolved on my blog. But I have some problems.

    It puts and for new lines also some problem for double quotes.

    It is easier to understand the issue if you see the screenshots below:

    http://www.susakli.com/_temp/scr_editor.jpg

    http://www.susakli.com/_temp/scr_tmp.jpg

    Thanks for help.

  • #438 written by Viper007Bond 
    about 1 month ago

    In Reply To Mehmet:

    Switch to HTML view when editing the post. Does it look correct or are there paragraph tags there? If it looks correct, try disabling other plugins.

  • #439 written by NTD 
    about 1 month ago

    hi Viper007Bond,
    when using syntaxhighlight, it shows not properly in Avant/IE/Chrome browser but FF. The syntax box’s larger than my page’s width:
    http://www.ntd.me/cach-nhung-nut-like-cua-facebook-vao-wordpress.htm

    and how to highlight some words in a paragraph, eg: i want to highlight “http%3A%2F%2Fwww.ntd.me%2Ftieng-goi-15-nam.htm” in this codebox:

    [/code]

    thank you (:

  • #440 written by Viper007Bond 
    about 1 month ago

    In Reply To NTD:

    Something in your theme’s CSS is doing it. I’m not sure what. :(

  • #441 written by Michael Fields 
    about 1 month ago

    Hi, great plugin. I’ve been using it on my site for a while. I just noticed that it is encoding my angled brackets as html entities. Not sure if this is a bug or something that I am doing wrong. Just wanted to throw it out there regardless. Please see code posted here for example:

    http://wordpress.mfields.org/2010/getting-down-and-dirty-with-wp_query-set/

  • #442 written by angus 
    about 3 weeks ago

    please update latest core “SyntaxHighlighter 3.0.83″
    http://alexgorbatchev.com/SyntaxHighlighter/

  • #443 written by Viper007Bond 
    about 3 weeks ago

    In Reply To angus:

    It only came out a few days ago. Give me time. ;)

  • #444 written by moustafa 
    about 2 weeks ago

    thanks alot…

  • #445 written by Lari 
    about 2 weeks ago

    Hi!
    I have problems when I post plain html using the syntax highlighter.

    All the shows up with entities instead of the right code.

    I have tried to use different languages, but can’t get it to work.

  • #446 written by Crayon 
    about 1 week ago

    Hi, SyntaxHighlighter Evolved 2.3.8 is using SyntaxHighlighter 2.0.320. since July 2, version 3.0.83 is available. It really looks great and I was wondering if you were planing to update your product?

  • #447 written by Crayon 
    about 1 week ago

    Oops, sorry for the last post. I did not read your reply to angus.

    Thank :)

  • #448 written by Bill Hollings 
    about 6 days ago

    On the SyntaxHighlighter settings page, I have the “Wrap long lines” setting UNchecked. However, the scrollbar never shows up on code listings with long lines. Code listings always wrap instead.

    I’ve tried the setting switch both ways. I’ve also tried including the wraplines attribute both ways in the sourcecode element…but to no effect.

    Has anyone encountered this before?

    Could it be some kind of conflict with the CSS my WP theme (Atahualpa)? If so…I’m at a loss to see where. Naked HTML pre elements show the scroll bar properly…so any possible conflict can’t be general in nature.

    What could I be missing?

    Thanks…

    …Bill

  • #449 written by Bill Hollings 
    about 6 days ago

    Hmmm…after a bit more digging I have a bit more info about the scrollbar problem (but still no solution).

    This seems to be localized to IE (I have IE8). Firefox seems happy to display the scrollbars.

    Also…the scrollbars DO appear under IE in the SyntaxHighlighters settings page…which again made me wonder if it’s a conflict with the Atahualpa theme.

    Any help would be much appreciated.

    Thanks…

    …Bill

  • #450 written by Alex (Viper007Bond) 
    about 6 days ago

    In Reply To Bill Hollings:

    If it works on the settings page but not on your main site, then it’s gotta be some CSS in your theme doing it.

  • #451 written by Roy 
    about 6 days ago

    This plugin looks great. I’ve given it a try, and it’s exactly what I need functionally.

    Two questions:

    1) I’d like to make the line number area look different (narrower, light blue background color, and some other changes). Should I edit the appropriate shThemeX.css file or shCore.css to do that, or is there a more recommended method?

    2) I checked the “Use smart tabs” option on the settings page…but I’m not sure what it does. What I hoped it would do is allow me to use tabs in the WP code editor to align things (I never use the visual editor), but that doesn’t seem to be true. Does the option just format output nicely, or does it somehow let me insert tabs? If the former, I guess I’ll have to use a plugin like Tab Override to get code editor tab goodness.

    Thanks for a nice plugin.

  • #452 written by Alex (Viper007Bond) 
    about 5 days ago

    In Reply To Roy:

    1) Make a custom theme: http://www.viper007bond.com/wordpress-plugins/syntaxhighlighter/adding-a-new-theme/

    2) Smart tabs makes it uses variable width tabs so things line up (if you have tabs midline). It has nothing to do with the editor, only display. Most people write their code in a proper editor and then copy/paste it into their blog.

  • #453 written by Kaan 
    about 1 day ago

    Big thank you for the plugin, works great! (using WP 3.0)

1 ... 3 4 5

If you wish to post code, write it like [code]blah[/code] so it will display properly.

Page generated with 34 queries in 0.57528 seconds ( 97.49% PHP, 2.51% MySQL )