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.
Pingback: SHOCOLAT DESIGN | BLOG
Pingback: Blog atualizado! « bruno Kenj on System.Web
Pingback: SyntaxHighlighter Evolved WordPress Plugin
Pingback: ??????????? ????????????? ????? – ????? 1
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++
Try switching to HTML view if you’re using TinyMCE. TinyMCE can be buggy.
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:
[code lang=”html”]
<div>
[/code]
and it appeared as this:
<div>
The plugin works on posts just fine. Any advice?
OK, the formatting messed things up. The second section was supposed to be:
[code lang=”html”]
<div>
[/code]
Thanks
Sounds like another plugin is causing the issue as pages are literally just a type of post. My plugin doesn’t know the difference.
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?
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
Pingback: SyntaxHighlighter – Evidenziatore sintassi di Codice - GiaffaBlog
Pingback: Kod ?ród?owy w Wordpress’ie « Notatnik
Pingback: SyntaxHighlighter ou gist.github ? Comparaison de ces solutions pour partager du code avec Wordpress | AbriCoCotier.fr
Awesome job, Alex
Pingback: Ménage de printemps sur Tym-Project.fr | ? Tym-Project
Pingback: SyntaxHighlighter Evolved | wordpres hacking
This looks like a fantastic plugin, Alex, and just what I’m after. I’m very impressed by the amount of support you’ve provided in the comments above.
The plugin does not appear to be working on my test page (see two examples at bottom):
http://www.aintyomamasblog.com/badge/
The first example shows my test with escaped code. The code is being converted and displayed non-escaped, without executing the html BUT without the plugin doing its thing.
The second example shows my test with non-escaped code. The html is being executed and the graphic is displaying.
The “wp_footer ()” code does exist in footer.php.
Any help appreciated. Thanks!
Nevermind the immediately above post. I got it figured out. Long story, best interred. However, there is one funky thing going on. When I hover, the box with the view/copy/print/? options displays the last function (?) differently than in all the demos — with a big rectangle around it.
http://i936.photobucket.com/albums/ad206/aintyomamasblog/highlight.png
Any suggests appreciated!
Weird. Likely it’s something in your theme’s CSS.
EDIT: it’s
.custom .aboutPingback: ???543???wordpress??????????? 2010/3/22?? | ???543
Jackpot — Now I need to track down why I had a .custom .about style. Thanks for the quick response and fantastic tool.
Pingback: 101 Killer WordPress Plugins that Kick Ass - Montana Programmer
Pingback: 101 Killer WordPress Plugins that Kick Ass | MyWebNow.com
Pingback: Wordpress’te Php,Asp,Html kod ekleme (Editörü) eklentisi
is this automatic i mean, is it really automatic..
i mean do i just have to put the codes on a div or element then it automatically render the deisgn for it?
Wrap your code in the shortcodes (or even just [code]) and you’re done. That’s all there is to it.
How does COLLAPSE attribute work?
I’ve just tried to set it to a number, collapse=”15″
But it doesn’t work!!
I need it because I have to post long codes.
Maybe it isn’t the right attribute.. What is the right attribute to truncate the code??
Ciao!
It’s a boolean (true/false). It’s all or nothing.
Ok thanks.
Pingback: Implementing ‘Show Your Google Analytics Top Content in Wordpress’ | Okada Design Blog
Okay, i have been trying to get your Plugin to work with my WordPress installation but i cant. I have already included the text into the footer.php file.’
Whenever i use plain text as the language it will convert my ” into " you can see it on my blog for now. Any idea how to resolve this issue?
[text]This is a test of "quotes" using the [ text ] shortcode (with no spaces).[/text]
^ Works fine for me as you can see. Try disabling all other plugins. Perhaps one of them is causing it.
Pingback: SyntaxHighlighter Evolved | kairos
Pingback: Posting Source Code in Wordpress « Skrakes.com
quick note… anytime i paste in php source code which has midstream becomes => and so forth)
(BP1.2.3 + WP2.9.2)
err sorry, comments munched the code if [php]<?php[/php] is inserted midstream then everything is converted
Pingback: Adaug? butoane personalizate în editorul HTML | WP Tuts
does this work with objc ?
[objc]
– (void)loadView {
CPLayerHostingView * newView = [[CPLayerHostingView alloc]initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view = newView;
[newView release];
}
[/objc]
First off I want to say that this is a great plugin and I think it’s one of the best wp syntax highlighters out there. The problem I have though is that it seems to add an extra href whenever there is a link in my code. It also adds span tags to the beginning and end. Is there any way to get rid of these two things? Sorry if this is a stupid question.
This sounds like another plugin is causing this issue. Disable all other plugins and then write a fresh new post as a test.
Thanks for the reply. I had no other plugins installed. I tried a new post though and still got the same problem. I have gone through many highlighters so maybe one of them left some unwanted code? I’m also using the same wp them you are, mystique I believe it’s called. Here’s a sample of what happens to me:
[html]
<span><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</a>">
<html xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
</head>
</span>
[/html]
Also when I look at your example code up top I see the same effect. Is that just me?
Oh, that is indeed a bug, but it should only apply to comments I think. WordPress has a function that automatically makes URLs in comments clickable. I need to replace it with a version that doesn’t do it inside of SyntaxHighlighter code blocks.
Pingback: Jack Altiere » Blog Archive » Blog Setup
Pingback: ????????? ??????? PHP+JavaScript+HTML+CSS » ??????? ??? ????????? ???? ? WordPress’?
Any ETA on a release date to fix that bug? To the best of my recollection it is the first real bug in a long time.
I’m super busy, but I’ll try and fix it when I get a chance (and figure out how to do it). It shouldn’t affect code in posts though (which is where the vast majority of users use this plugin).
Pingback: A Wordpress Plug-in to display Code « Jake Belfry's Internet Marketing Blog
Pingback: ??? / ???????????????WordPress???????????? « ????????
Sorry… can anyone help me?
http://www.consorziocreativo.com/blog/tutorial/wordpress/crea-un-campo-sottotitolo-in-wordpress.php
Wordpress editor replaces my line breaks in preformatted text. I disabled html editor, I use visual editor only and TinyMce Advanced…
P.S.: excuse me for my bad english
Ah, ok… note please the other problem too, like: <? instend of < and
Thanks!
Awesome plugin!
But could you add the Lua code highlight to this plugin?
I really like your plugin,it’s pretty,so I won’t change to use other syntax highlight plugins.
Any way,thank you all the same.
Hello !
First of all, I want to say, that your plugin is awesome. I tried a lot, and your’s my favourite
But, there is always a “but” ^_^
I would like to know if there is a possibility to modify the width of the highlighted text
I know that it is possible to modify it in shCore.css, but it is for all code
I want to modify width for only some blocks of code, not for all
I had a look to the Shortcode Parameters, but, no ‘width’ one
I hope that you can help me 😀
Lord, from France (so I apologize for the rusty english !)
You can probably wrap it in a div with a fixed width.
Thank you for the quick reply and the advice !
It works fine with some div
Lord,
Great plugin. Just one thing.
For a very short while before the page is fully loaded, the initial aspect my theme gives to tags will appear, and then be replaced by the correct format.
Is there any solution to that ?
No because the highlighting is done client-side (in the user’s browser). The Javascript has to wait for the page to finish loading before it can go and find all of the code blocks and spruce them up.
Pingback: Scott's Blog - Installed the SyntaxHighlighter Evolved plugin
Pingback: ???????? ????????? ??????????? ? WordPress
Pingback: Railscast style syntax highlighting redux | David Peterson
Does this work for wpmu? I have it working on regular wp, just not wpmu. thanks.
It’s running on WordPress.com right now which is WPMU powered, so yes. 🙂
Thanks, I found the problem. My custom theme in wpmu was blocking all shortcodes:
http://wordpress.org/support/topic/320635?replies=2
It’s working now, looks good.
Pingback: Wordpress Plugins I Can’t Live Without « Josh Nunn's Geekorium
Pingback: Nephandus » Blog Archive » Teaching An Old Dog New Tricks
Hi,
This Plugin Is Very Useful.
Thanks For It.
Good Luck.
Thanks dude for the wonderful plugin, works really fine.
Question: I woul dlike to manipulate the margin-top, is that to be done on the plugin or on the environment through css.sty – any pointers?
Greetings,
DS
You’d have to edit the plugin’s stylesheet unfortunately. It’s on my todo list to create a better solution.
Hi Viper,
Is it possible to display shortcodes with this plugin e.g.
[code][button link="#"]Insert text here[/button][/code]
As you can see I want to show the user how to type short codes, but not actually generate them. At the moment the short codes are parsed and this is displaying instead in the syntax highlighter:
Click Here
That’s because my plugin has to cheat a bit and run it’s shortcode a bit earlier than normal to avoid stuff going bad.
However WordPress has a built-in way to avoid shortcodes being rendered: double-wrap them like so: [[shortcode]] (at least that worked last I tried it)