Release: [WordPress Plugin] SyntaxHighlighter Plus
Posted by Fred Wu
This plugin is no longer being maintained, please check out Viper007Bond’s SyntaxHighlighter Evolved instead.
Latest version: v1.0b2 [2009-03-02]
As part of the ‘house-warming party’ (for the (re)launching of the website) gift, I now announce the immediate availability of SyntaxHighlighter Plus. :-)
The official WordPress plugin page is located here: http://wordpress.org/extend/plugins/syntaxhighlighter-plus/
What is SyntaxHighlighter Plus?
SyntaxHighlighter Plus is a WordPress plugin for code syntax highlighting. It is an enhanced version of the original SyntaxHighlighter by Matt, Viper007Bond and mdawaffe. Please give them a big applause for making such a great plugin!
Features of SyntaxHighlighter
SyntaxHighlighter allows you to easily post syntax highlighted code all without loosing it’s formatting or making an manual changes.
It supports the following languages (the alias for use in the post is listed next to the name):
- Bash — bash, sh
- C++ — cpp, c, c++
- C# — c#, c-sharp, csharp
- CSS — css
- Delphi — delphi, pascal
- Diff — diff
- Groovy — groovy
- Java — java
- JavaScript — js, jscript, javascript
- Perl — perl, pl
- PHP — php
- Plain text — plain, text
- Python — py, python
- Ruby — rb, ruby, rails, ror
- Scala — scala
- SQL — sql
- VB — vb, vb.net
- XML/HTML — xml, html, xhtml, xslt
This plugin uses the SyntaxHighlighter JavaScript package by Alex Gorbatchev.
What is the difference between SyntaxHighlighter and SyntaxHighlighter Plus (prior to v1.0)?
SyntaxHighlighter Plus is built upon SyntaxHighlighter with extra features and bug fixes. In addition to the original version, SyntaxHighlighter Plus has the following extra goodies:
- Valid XHTML markup (courtesy of mhavila)
- Background expand fix (partially courtesy of brucknerite)
- Corrected Overflow issues
- More syntax variants
New in SyntaxHighlighter Plus v1.0 !
Starting from SyntaxHighlighter Plus v1.0, the core engine is upgraded to
Alex Gorbatchev’s SyntaxHighlighter 2.0!
New features since the 1.5 engine:
- CSS Themes
- Line highlighting
- HTML with script tags
- Smart line wrapping
- No-CSS fallback
- Strict & XHTML compliant
- Inline URL detection
Click here to view the complete version matrix.
Is SyntaxHighlighter Plus backward compatible?
Yes! Simply replace the original SyntaxHighlighter files and that’s it! Start from version 0.13, the plugin folder was renamed to ‘syntaxhighlighter-plus’.
How to install and use this plugin?
Please refer to SyntaxHighlighter’s project page.
Examples
The examples are using the RDark theme.
PHP
function BBCodeToHTML( $content ) { if ( !$this->CheckForBBCode( $content ) ) return $content; $matches = $this->GetBBCode( $content ); if ( empty($matches) ) return $content; // No BBCode found, we can stop here // Loop through each match and replace the BBCode with HTML foreach ( (array) $matches as $match ) { $language = strtolower( $match[4] ); $content = str_replace( $match[0], '<pre class="syntax-highlight:' . $language . "\">" . htmlspecialchars( $match[5] ) . "</pre>", $content ); $this->jsfiles2load[$this->languages[$language]] = TRUE; } return $content; }
CSS
.dp-highlighter { font-family: "Consolas", "Courier New", Courier, mono; font-size: 12px; background-color: #E7E5DC; width: 530px; margin: 18px 0 18px 0; padding-top: 1px;/* adds a little border on top when controls are hidden */ overflow: auto; /* fixes for IE: "overflow: auto" causes unnecessary vertical bar */ /* corrects bottom scroll bar overlapping */ overflow-y: hidden; padding-bottom: expression(this.scrollWidth > this.offsetWidth ? 15 : 0); }
Syntax
Bold ones are exclusive to SyntaxHighlighter Plus. Furthermore, quotation marks around the language can be omitted.
- [source language=’css’] … [/source]
- [code language=’css’] … [/code]
- [sourcecode lang=’css’] … [/sourcecode]
- [source lang=’css’] … [/source]
- [code lang=’css’] … [/code]
- [sourcecode=’css’] … [/sourcecode]
- [source=’css’] … [/source]
- [code=’css’] … [/code]
- [lang=’css’] … [/lang]
- [css] … [/css]
License
GNU Lesser General Public License (LGPL)
Changelog
v1.0b2 [2009-03-02]
- Upgraded SyntaxHighlighter to 2.0.296
- Added automatic SSL detection (thanks to g30rg3_x)
- Added anti-XSS and XSRF (thanks to g30rg3_x)
- Language aliases fix
- Code clean up
v1.0b1 [2009-02-07]
- Upgraded the core engine to SyntaxHighlighter 2.0
- Added configuration: themes
- Default language changed from PHP to plain text
v0.18 [2008-07-19]
- Added PHP as the default language if no language is specified (e.g. [ code ][ /code ])
v0.17 [2008-06-28]
- Fixed a bug in the Bash highlighting code which caused conflicts between keywords and variables highlights
v0.16 [2008-06-02]
- Ported SyntaxHighlighter 1.1.1 changes: ‘Encode single quotes so wptexturize() doesn’t transform them into fancy quotes and screw up code.’
v0.15b [2008-05-07]
- CSS fixes for IE6
v0.15a [2008-05-07]
- Enhanced CSS
v0.15 [2008-05-01]
- Fixed the IE scroll bar issue (backup your CSS file before upgrade!)
v0.14 [2008-04-22]
- Added support for Bash (thanks to Nick Anderson)
- Now supports WordPress MU (thanks to Tim)
v0.13 [2007-12-19]
- Changed plugin folder to ‘syntaxhighlighter-plus’.
v0.12 [2007-12-18] – Broken!
- Appeared on the WordPress plugins site.
- Fixed readme.txt.
- Cleaned up the files.
v0.11 [2007-12-16]
- Added more syntax variants.
v0.10 [2007-12-16]
- Initial release.
Download
v1.0b2 WordPress Official Mirror
v1.0b1 WordPress Official Mirror
v0.18 WordPress Official Mirror
v0.17 WordPress Official Mirror
v0.16 WordPress Official Mirror
v0.15b WordPress Official Mirror
v0.15a WordPress Official Mirror
v0.15 WordPress Official Mirror
v0.14 WordPress Official Mirror
v0.13 WordPress Official Mirror
v0.12 WordPress Official Mirror
v0.11 WordPress Official Mirror
v0.10 WordPress Official Mirror
Hello Fred,
First off, thanks for updation, I hope this’ll work with WordPress 2.3.x. As, the original SyntaxHighlighter plugin didn’t worked for me.
Well, I’m using Amit’s IG-SyntaxHighlighter for the past 2+ years. And has alot of code, just wanna ask you, can you add an additional syntax variant:
[lang][/lang] e.g.
. This will help in migrating from ig-Syntax to SyntaxHighlighter without loosing previously saved codes.Expecting some response at the earliest possible.
DG…
Hi DG,
Interesting, because I used the original SyntaxHighlighter with 2.3.1 and it was fine. Perhaps you have some other plugins that conflict with it?
As for more variants, I’ll see what I can do. :)
Cheers
Hi Fred,
Thanks for the prompt reply. Eagerly waiting for your input on the requested variant.
2. I’ve notice your blog loading quite fast, even with lots of JS. Are you using any server side cache?
Also, very important, you plugins directory is open for public view, just disable it.
DG…
DG, I have updated the plugin, it now supports [lang] and ,etc. :)
Regarding the loading speed, yes I’m using WP Super Cache.
In the next few days I’ll compose an overview of some of the ‘essential’ plugins.
Cheers
P.S. Thanks for the heads up on the directory security concern. :)
Hi Fred,
Thanks once again, just dowloaded upgraded version.
2. I saw Super Cache initially, Donnacha has done a fantastic work.
3. Re. essential plugins, I hope, you’ve your compilation, incase if you want, you can check this post of mine.
Thanks again for the help and prompt reply’s.
I’ll tag your post tomorrow on my blog.
DG…
You’re welcome DG. Wow you have a big list there, I’ll ‘study’ it soon. :)
How do you do it with whitespace? Mine seems to be eaten by WordPress the whole time (everytime the post is saved). Is there any trick to this?
Adam, do you have any other plugins installed that may cause this? Some text formating plugins might trim the whitespaces.
LOL, good stuff ! Love reading your blogs.
Nope, nothing like that. Are you editing your posts in HTML or in the “WYSIWYG” editor?
Adam, I do all posts using the good ol’ raw, plain editor. ;) Never used the WYSIWYG editor, now that I think of it, it might be a cause if you use that in combination with the syntax highlither. I will do some tests later. :)
Admin I just tested it and unfortunately the WYSIWYG editor doesn’t like the plugin. There is no way around it I’m afraid…
Well, maybe I’ll just use that too. Never trusted the WYSIWIG editor completely anyway. It’s just that I always think that it’s a nice feature and I always try to use nice features naively hoping they make things better. And sometimes these features aren’t exactly what I need/want, as in this case.
Thanks for all the help!
really a great plugin. I do a change that the “files” folder to “shlfiles” for wordpress mu edition. because the “files” conflicts with the user-upload-file-folder in wordpress mu . please review my article http://tim.diary.tw/2008/03/05.....hter-plus/
please give some advise and merge to your version for wordpress mu version. thanks a lot!
Thanks Tim, I will merge this feature in the next few days. :)
you’re welcome, thanks for your reply and enhance this plugin…
Hi Fred,
can your plugin be used to highlight code posted in the comments?
@Claudio: Yes you certainly can! :) At around line 58 of syntaxhighlighter.php, you will see the following comment:
// Uncomment these next lines to allow commenters to post code
Just uncomment the three lines after that to allow syntax highlighting in comments! :)
Thanks Fred, this plugin is awesome!
really a great plugin.
Automatic newline ?
Any chances to make it work with 2.5?
Thanks!
Hi Moshu, did you find any particular function broken in 2.5? I am running 2.5 here and the plugin appears to be working fine.
v1.3,v1.4 still have problem on WP 2.5
it convert line break to “” text and it convert on each line……
for example:
http://blog.miawork.com/?p=654
@Ming: Did you use the WYSIWYG editor? If so that is the reason why it converts line breaks, there is currently no workaround unfortunately.
Re: Fred Wu
Yes, i using the WYSIWYG editor come with WordPress.
@Ming: Unfortunately WYSIWYG messes up the syntax highlighter code, your only option is to switch to the plain editor for the time being.
Hello,
Thanks for your great plugin. I’ve been using it for months. Now the syntax on my blog shows twice when I use this plugin, but it’s normal without [lang]. I just find this probelm and it may caused by the compatibility with WP 2.5. I had no probelms before.
Thx
@Greenmoon55: I cannot reproduce the problem. Are you saying that the code will appear twice if you use the [lang=php] format?
I use [lang='pascal'][/lang]. It looks like this: http://greenmoon55.cn/blog/broken-necklace/
I guess that it’s not caused by [lang='pascal'][/lang]. I tried to use format but problem was not solved.
Sorry for my English. I’m learning English now. Thx.
@Greenmoon55: It works fine here, could you please provide me a list of your activated plugins? Maybe one of your plugins is interfering with it.
I use common plugins. I tried to deactive all and keep this one actived, nothing changed. I’ve updated to 0.15.
@Greenmoon55: I just re-analysed your page source and noticed that the SyntaxHighlighter Javascript has been inserted twice.
Search for ‘SyntaxHighlighter Stuff’ in your HTML source and you’ll see what I mean. Please double check your templates to make sure that only one instance of the script is included.
Thanks for your help. I changed to another theme, then it has no problem. But I don’t know why. I don’t want to change the theme.
Could you tell me more about how to find the problem in the theme files?
I suspect the SyntaxHighlighter scripts are somehow hard coded into your theme. If that’s the case then please search and remove it. Otherwise you could email me the theme files to canglan [AT] gmail.com and I’ll take a look at it for you. Cheers
I’m having a bit of trouble with the syntax highlighter; it works great, except comments have a large, visible box around each line. See the code near the bottom of http://www.coriolinus.net/2008.....thats-why/ . I suspect that this is due to a CSS conflict, but I’m new to WordPress and I have no idea how to begin debugging this.
I have some problems with your highlighter code, I am running WP 2.5, and using Mandigo theme. I have installed the latest version of you app, but the output looks funny:
http://www.xipher.dk/WordPress/?page_id=170
It seems to indent some lines, and not others.
I have tried switching to the WordPress default 1.6, but it still has issues, do you have an idea what could be happening here ?
Claus, the page you linked is empty.
Sorry I had accidently marked it as private, and FF had kept my login credentials… So I could see it…
It should work now, and sorry for the trouble :)
Claus and coriolinus, please upgrade to version 0.15b, it should fix both of your CSS problems.
Thank you for your quick reply.
It seems to have fixed most of the problems.. Now every other line of code is indented.
http://www.xipher.dk/WordPress/?p=168
PS I know it is “unsupported” code (PowerShell), but that should not cause the problem should it ?
Claus: I’ve fixed this in SVN trunk. You may get the file directly at: http://svn.wp-plugins.org/synt.....ighter.css
Thank you, that’s fixed it. Good plugin!
Thank you very much it works now :)
I’ve send the theme files to you. Thank you.
Problem solved. Thx for your help.
I am trying to post some actionscript code that contains what wordpress thinks are invalid XHTML. I have tried to work around this by replacing the angle brackets with entity references but they don’t render correctly. What is the solution for using entity references within SyntaxHighlighter?
Brett, would you mind posting a link or some samples here?
Since I update to wp v2.5.1, my highlighter broke, among other things. Installed your plugin and for some reason the js isn’t loading, so I end up with the tags printing on screen. I’m kinda desperate, because all the highlighter plugins I’ve tried so far don’t seem to work.
link: redivide.com[...]vhost
Using [lang=’xml’]…
Hi, Thanks for this wonderful plugin, however I am experiencing one tiny error. The output print double if , as you can see in http://tajidyakub.com/2008/06/.....n-the-fly/ , but if we copy to clipboard the double if disappeared. I wonder where it went wrong?, I use sourcecode lang bash and bash /bash, same thing happen. Thanks again.
Hi Tajid, I have updated the script to 0.17 which should fix this problem. Please give it a try. :)
Hi Fred, Thanks for the update, it works .. :)
Anyone has the problem where the spaces/tabs gets “eaten” up? I am loosing all my indentations. I typed in spaces but after hitting “Save”, the spaces gets “eaten”.
Hi Fred,
We talked during the inital release of Syntaxhighlighter Plus. May I request you add a Syntax
, because I’ve lots of codes wrapped in the above noted syntax variant during my “IG-SyntaxHighlighter” usage, now those code are broken.
Hope for an early reply.
Thanks,
DG…
not work for me :(
http://toplez.textdriven.com/?p=3
thx.. it work now :)
Excuse me, I have to trouble you again.
I’ve just changed a new theme but found that the first line of my code isn’t shown correctly while the other lines work well.
Can I send you my theme and you help me? This theme author is popular in China. He has made many good themes. Many people use this one.
Thank you!
For example http://greenmoon55.cn/blog/the-castle/
Luckily, this is not a serious problem like last time.
thank you ^_^
i have problem with Arabic language – right to left language -
and the code appear in right to left
see here
http://www.islamcg.com/blender/?p=65
@Derick: What version of WordPress and SyntaxHighlighter Plus are you using? And are you using the WYSIWYG editor?
@DG: This feature is now included in 0.18. :)
@Greenmoon55: In your main CSS file, the definition of .comment is conflicting with the SyntaxHighlighter CSS. You could either make that definition more specific, or manually set the .comment in the SyntaxHighlighter CSS to have no float, etc.
@ibnyassen: You blog is showing the WordPress error page.
Right now I’ m using WordPress 2.6 but it didn’ t work either with 2.3.x nor with 2.5.1, and yes, I’ m using the visual editor…
As regards SyntaxHighlighter Plus I’m using 0.18, but neither 0.17 worked, in every kind of combination with WordPress versions.
Another problem is the conversion of special chars, such as: “&”, “>”, “<” and ” “…they just appear in the article like “ ”, “>”, “<” and so on…I really need this fantastic plugin to work properly!
Bye, Derick
Hi Fred,
first of all I want to thank you for this awesome plugin, very very useful..
I’ ve got the SAME, IDENTICAL problem Derick has:
1) Indentation not working properly
Moreover, I’ ve got an issue with “”, ” ” and “&” chars decoding; they don’ t appear as they should.
I’ m using latest versions both of SHP and WordPress (2.6) with a visual editor. It seems everyone knows the problem is in the WYSIWYG editor, but noone knows how to fix it!
Hope you have a solution for both my problems!
Goodbye, Nicola
Ok, I think you’ ve understood which are the chars I meant..your comment editor just converted them!
(They are “greater than”, “less than”, “space” and “ampersand”)
I suggest that change ‘width: 530px;’ in line 6 of css file to ‘width: 100%’ to adapt various width of theme.
Hey Fred,
Great plugin just one problem when i use the & in a piece of bash code it gets changed to & and every edit an amp; gets added very anojing also the & shows up as & instead of &….
[mad]Berry
Found another little problem wit the following post
http://madberry.org/2008/08/do.....with-wget/
The line:
wget –wait=20 –limit-rate=20K -r -p -U Mozilla http://myhdwallpaper.com
In the highlighter became:
wget –waitwait=20 –limit-rate=20K -r -p -U Mozilla http://myhdwallpaper.come
For some reason there is an extra “wait” in it the tags used are
[/bash]
Can’t seem to figure out why this is happening. Do you know?
[mad]Berry
Works great with one problem. If I use a line of code that begins with < ? p h p (without spaces of course), the entire line disappears.
Thanks for this. I was looking for a plugin which can make the syntax highlighting in wordpress posts easier.
This is indeed a nice plugin. However, it does not currently pass a W3C CSS validation test. http://jigsaw.w3.org/css-validator/
Could you please correct the CSS errors.
Have you guys tried “EDITING” a previous post only to find your code got all messed up… the site converts certain characters, and when you edit and or manage a post , those weird characters appear..
will be converted into
any help is appreciated.
Hi,
I installed it and activated it just like you told on the wp plugin page.
BUT: it only works right for HMTL.
When i type in some php code to display it doesn’t post the Post but brings me to a 404 Error page.
Do you know how to solve this?
Regards,
Marcel doornbos
http://www.marceldoornbos.com/.....-php-site/
Hi,
So i found out:
When i do this code it works:
And when i do this one with a little line extra it doesn’t work:
Tell me what’s wrong?
Hi, what a great plugin. I just miss one thing. Is it possible if i like to publish just a part of the source code, that i can set the start of the line number?
I tried Syntax Highlighter plus, but it is not working. what may be the problem
http://www.codemator.com/2008/.....-response/
I agree with post #65, the width in the CSS should be changed to 100% for people who don’t use the standard wordpress width.
hi, how to change the SyntaxHighlighter window size to a smaller?
Hi I m glad to your post “: [WordPress Plugin] SyntaxHighlighter Plus | Beyond Coding” so well that I like to ask you whether I should translate into German and linking back. Please answer. Greetings Detektiv
How i chage initial line values ? using the code:
example, source code start at line 30, how i show this ?
Thanks!, i´am using SyntaxHighlighter Plus
How do i change the initial line value of codes ?
Example using
start at line 30…
I´am using SyntaxHighlighter Plus and my homepage is http://www.thiagomedeiros.com
Thanks
Great plugin!
But I got a problem: There are no line numbers in my code snippets, instead small circles are displayed. Whats wrong here?
I wrote a plugin that allows code editing in wordpress’s visual editor. http://www.webveteran.com/blog.....de-editor/
Works great with syntax highlighter plus. But what I cannot figure out is, how do we start the code block on any line number? For instance 742 instead of 1. Any help is appreciated!
Two bugs:
Copy to clipboard copies nothing to the clipboard.
Secondly..if we copy manually, line number also gets copied…which should not be the case.
This problem occurs both with WordPress 2.6.5 and WordPress 2.7 final also.
As Navjot Singh said, the copy to clipboard doesn’t work. Not on my site, nor this one. Is it a browser setting or something?
I really love this plugin, but it would be so much better if there was a tinymce button in the wysiwyg editor.
You should add this CSS to make it compatible with certain themes (like inove):
.dp-highlighter ol li
{
list-style-position:outside !important;
}
I’m loving the plug-in, but I’m having a bit of trouble with the width. It’s just a bit too wide.
Also, being able to start line numbering at a different number would definitely be nice.
You may want to get in contact with the developer of the “visual-code-editor” plugin. This plugin resolves the character modification issues that result from using the visual text editor. However, when using this plugin alongside your plugin you are required to make one small modification to your plugin. You must remove the call to htmlspecialchars() on line 331 in order to prevent the special characters from being displayed as their equivalent character codes when viewing the published post.
Hey, i’m used your plugin , it’s ok. But when I published an article with php code (for example) I have a space between < and ?php. Why? A solution? Thank you
As soon :)
I created an AS3 (Flash 10) brush for use with this plugin for anyone interested
http://blog.coursevector.com/a.....ghlighting
Hello Fred,
Thank you for posting this version of the SyntaxHighlighter. While the plugin does what it is supposed to do (highlight code), I find that WordPress insists in displaying the output in just one line. I have tried many different highlighters and the result is the same for me each time. All of my code displays on one single line instead of preserving the formatting of the pasted code into the post editor in WordPress. I am about to go crazy with it. Please, please, please! Let me know how I can get passed this issue. This seems to be working for everyone else and I, for the life of me cannot understand why I get the same result over and over, and over again!
Thank you in advanced,
Ramon E. Tristani
Hi guys, just thought I’d let you know that all of your comments have been looked at and I will be releasing a new version of the plugin soon to address all the issues reported. On a side note, Alex has just released version 2.0 of SyntaxHighlighter. A new version of the plugin based on 2.0 will be released soon unless the ‘donationware’ status prohibits me from releasing it. Thanks guys.
Hey Fred, for some reason, this plugin doesn’t fully work in my theme. It will change the entities, but it won’t put the code into a list and won’t like the dp-highlighter wrapper. It worked in the classic theme, but not mine. I disabled all my other plugins, but that didn’t seem to help. Any ideas?
Is it possible to add syntax highlighting for Perl? I put together a Perl brush file and modified version .18 of the plugin to use it, but I’d rather not have to keep making the modification for every new version. I’d be happy to submit the brush file if that helps (though I didn’t spend much time on it). Thanks!
Hi
I’ve yet upgraded to latest version but there is something wrong
1 – the copy feature is not present
2 – buttons overlay the code
You can view this here: http://engelium.netsons.org/bl.....i-css.html
Is this a bug or is there something wrong on my installation?
Great work by you and Alex, thanks!
I seem to be getting extra glimpses of the new line wrap icon: http://garyjones.co.uk/blog/pluralization/ – am I doing something wrong?
Hi Fred – nice work.
How do enable support for older-style brushes, like ColdFusion? The syntax in the new brush files looks different. And I see a file called ‘shLegacy.js’. But I can’t figure out this puzzle.
Thanks,
Jules
@Stephen: The default set of CSS files don’t reset all of the elements hence why they are not compatible with some themes. Could you please send me a link to the theme or the theme files? Thanks.
@David: The new 2.0 engine uses slightly different brushes. Would you be able to update your brush to be compatible with 2.0?
@Engelium: This is the expected behaviour of the new 2.0 engine. I will contact Alex and see if this is something he is going to fix. If not then I will be looking into it. :)
@Gary: Could be a CSS issue, I will look into this.
@Jules: Unfortunately all old brushes need to be upgraded to work with the new engine. The shLegacy.js file is for migrating old ‘pre’ tags to the new ones, which is irrelevant to us because the tags are generated by SyntaxHighlighter Plus.
I misremembered: I had made some other brushes, but the Perl brush was by Marty Kube. I found it here. I will happily update it to work with 2.0, if you like. How should I get it to you?
Ah dang. That means I cannot even update or test my plugin with yours… I’m all CF.
I guess I’ll have to update that CF brush eventually :)
Great Plugin! I just installed it and it looks great!
I had spent a few hours about a week ago trying to come up with styles to make code look ok — this helps SO much.
One little question, is I can’t figure out to actually highlight a section of code. Does anyone know how to highlight an entire line, and/or a section inside a line? I like to show readers exactly what part of the code was updated when I can.
Thanks!
If also got some problems with the new version and my theme. Look at http://www.kilrathy.net/sites/.....d-new.html and you see what’s the problem… :(
Hope there is a fix
Alright, I converted Marty Kube’s Perl brush, and also wrote one for OCaml. They’re here: Perl brush, OCaml brush. For those who want to use them (if Fred doesn’t decide to add them to the default set), you should put the brush files in the scripts directory with the other brushes, and then add the following 2 lines to syntaxhighlighter.php, where it defines $this->aliases in SetVariables:
‘OCaml’ => array(‘ocaml’, ‘OCaml’),
‘Perl’ => array(‘perl’, ‘Perl’, ‘pl’),
I am having some trouble adding another brush, I had a few I added to the old version which worked…
I made changes to a powershell brush, to reflect the new changes, bt I cannot get it to work.
I uploaded to brush to the \scripts dir with the name shBrushPowerShell.js
I edited the syntaxhighlighter.php file and added the following line:
‘PowerShell’ => array(‘powershell’, ‘posh’, ‘ps’, ‘psh’),
When I go to my site http://www.xipher.dk I get a popup saying that syntaxhighlighter is not able to find the brush posh or ps.
I have uploaded the files in .txt here:
http://xipher.dk/WordPress/wp-.....rShell.txt
And
http://xipher.dk/WordPress/wp-.....ighter.txt
It is probably something stupid I have overlooked, but I cant seem to figure it out.
Figured it out… I had typed in a couple of variables with capital letters.. It did not like that… Now we only need to get the copy to clipboard thing working :)
BTW Thanks for a great plugin
It does not work for me with 2.7.1, when I write something in
tags then save, everything in tags to be cleared.
how can I fix that ?
I have a suggestion: instead of manually entering the languages and their aliases in a big array, why not have syntaxhighlighter.php grep through the scripts directory, finding all the brush files and the line of javascript in which they specify the language’s alias. That way, if people want to add support for a new language, all they have to do is drop the appropriate brush file in the scripts folder, and it’ll automatically be supported. Here’s some code to do it:
replace $this->aliases = … with:
$aliases_js = array();
$aliases = array();
$aliasgrep =
‘cd ‘ . ABSPATH . PLUGINDIR .
‘/syntaxhighlighter-plus/syntaxhighlighter/scripts/; ‘ .
‘grep -P “SyntaxHighlighter\\.brushes\\.\\w+\\.aliases” *;’;
exec($aliasgrep, &$aliases_js);
$regex = ‘/brushes\.(\w+)\.aliases\s*=\s*\[\'(.*)\'\];/’;
foreach ($aliases_js as $a_js) {
preg_match($regex, $a_js, $matches);
$aliases[$matches[1]] = preg_split(‘/\’,\s*\’/', $matches[2]);
}
$this->aliases = apply_filters( ‘agsyntaxhighlighter_aliases’, $aliases );
By the way, I get an unusual error every time I try to submit a comment. A broken image appears next to the “submit comment” button, and then I get an error popup (looks like a javascript alert), and the page fails to reload. If I manually reload the site, everything’s fine, but it’s unsettling because my comments usually don’t show up immediately, and there’s no feedback to say that the error didn’t prevent my comment from going through.
The error is:
“ACP error!
TypeError: Undefined value”
Sorry for all the repeated comments.
I commented on this before, but it apparently didn’t go through (maybe wordpress didn’t appreciate all the php code).
I have a suggestion: instead of manually entering the languages and their aliases in a big array, why not have syntaxhighlighter.php grep through the scripts directory, finding all the brush files and the line of javascript in which they specify the language’s aliases. That way, if people want to add support for a new language, all they have to do is drop the appropriate brush file in the scripts folder, and it’ll automatically be supported. I have written the code for this, but it seems I can’t successfully submit it in a comment.
Fred, you don’t have any contact information anywhere. Would you like me to send you the code? If so, how can I get it to you? Thanks!
The new version (1.0b1) doesn’t work properly – it displays all the “greather than” signs as HTML entities. I’ve reverted to version 0.18 which works fine.
Here’s another test case for Python:
I would first like to say thanks for the +PLUS version of SyntaxHighlighter as it has been extremelly useful to me for the 6+ months I have been using it. The additions of bash and plain text are things I use all the time.
I am however having the same issues with the latest upgrade. Specifically a lot of the code I am posting is one off stuff where it may be one line of CLI from Linux thus the icons are falling over the top of over 50% of the code I am posting. I also do miss the “copy to clipboard” feature in previous versions.
For now I have downgraded back to an easrlier version (appears to be really early 0.18) but regardless I appreciate the plugin and look forward to future releases. I am also going upgrade to the release right before 2.0.
Hi,
@David: Your feature proposal sounds great… but your implementation is so awful :-/.
First…
It relays on specific-environments limitations (grep is for unix-like only)
Second….
Some hosting environments does not like the idea of giving you the power to do system calls…
And Third…
Scanning the directory every time the plugin is called, would cause a performance hit against your wordpress-powered-site, for the simple reason that it has to re-scan every time just for looking “if you have changed or added a new aliases”… even that the data can be cached on the DB, you have to agree that there are other ways to solve the problem.
IMHO,
The big aliases array is a great idea, since the aliases-scripts aren’t going to change ( of course: not unless fred want’s ;) ), but we can actually instead of making the david-proposal, fred can just put/add a plugin-hook were other developers can relay to add the aliases they want (the david-proposal actually implements this idea but for other reasons and more limitated)…
Some plugins out there are actually using this concept/approach cause sometimes you want more than the default behavior of a plugin and giving hooks to developers would be easy to maintain and also this way would not affect the plugin performance.
If i find some free time over the week, i would send a patch-proposal to fred which will implement this idea/concept to the plugin with -of course- a example of how to use it.
Best Regards
I’ve just started using this and have encountered a couple of problems:
1. I’m also using the Exec-PHP plugin in posts and sometimes the PHP is being parsed and screwing with the post being retrieved. I have to put a space between < and <?php to get it to work.
2. On one post that has code blocks in HTML, CSS & js, the HTML & CSS code blocks come out fine, but when I wrap the js code block in any kinda of tag, the whole content of the post gets eaten!
Good work! Just one note, PHP5 is required for this plugin to work.
Hi!
I’m also using this plugin, but I’m having problems with indentation: it seems all spaces and tabs are being “eated”…how can I fix this?
Great plugin but I have one problem. The plugin separates < and ?php when it should be <?php.
Any help on this issue would be great :)
Hello,
I have been using this plugin from quite while. Today, i happened to validate my blog using HTML Validator.
I see that your plugin adds link tags in the header section. HTML rules says for link tag /> is enough </link> gives html validation error. Can you change this in your next release?
Nice plugin and seems to be popular so I’ll try it out
I’m about to install it on my blog at http://www.webtechglobal.co.uk/?page=df/blog
I should need it for all languages over next couple of years so fingers crossed its the number 1 solution eh!
Oh well seems like another failed plugin!
When trying to use the code wrap syntax and update I get the following…
Warning: htmlspecialchars_decode() expects parameter 1 to be string, NULL given in /home/sites/webtechglobal.co.uk/public_html/blog/wp-includes/compat.php on line 105
Warning: Cannot modify header information – headers already sent by (output started at /home/sites/webtechglobal.co.uk/public_html/blog/wp-includes/compat.php:105) in /home/sites/webtechglobal.co.uk/public_html/blog/wp-includes/pluggable.php on line 850
Hey guys, great job on the plugin! I really like the results from it. Best syntax highlighter I’ve found.
Running into two minor issues.
When documenting a redirect in bash (>>) it is displaying as >> in the code block.
Also, the line numbers are offset from the code by about a half line.
Example here: http://jts-blog.com/?p=30
Suggestions? Thanks!
woops, in my last comment should be “>> is displaying as & gt ; & gt ; ” without the spaces) My text was auto-converted to >>
Nice highlighting plugin. I have used i at bit, and is trying different ways of blogging. I’m getting pretty fond of the XML-RPC way of posting, unfortunately when using any of the bracket solutions like
while this is not html, then the content will almost always be interpreted in a wrong way by the XML-RPC enabled editor.
A solution would be if it was possible to use the “old” syntax of the original syntaxhighlighter … . I tried this of course, but i get a warning that the brush could not be found.
Otherwise it’s a really nice integration of syntax highlighting in wordpress, a big thanks! :-)
On a side note, is it possible to add a check box to the configuration page to dis/enable the copy to clipboard icon?
Regards, Esben
Hi Fred,
Can you add a lang ‘
‘. I’ve lots of data wrapped between “
“. When I was using ig-syntax highlighter plugin.
Hi Fred,
In my website, the code is not coming as perfect as it is here.
The line numbers are overlapping the code, spaces are becoming line breaks.
I am using Text editor.
Please help me :(
Hey. Is there any way to enable the copy to clipboard links?
This would be most appreciated.
Thank you.
Also, do you know of any reason why this would cause some jQuery stuff (lavalamp, slideshow, etc) to fail, but only in google chrome?
Any help would be appreciated.
Hey,
I installed Syntax Highlighter Plus and it seems to work correctly (ie. it adds the pre tags around the code) but it doesnt add the css styles to the page. Any ideas?
Cheers
please put actionscript 3 in there