About Syntax highlighting
This blog engine make available plugin(s) for the syntax highlighting, but I can't found one that match I want. Colorize at least Powerbuilder and perl.
The first I found (syntaxHl) handled them on server side, but some perl expression was badly broken. Then I see that search.cpan.org was using an sh system that allow to dynamically switch colorization style, on the client side (javascript).
Taking a look at that system (http://shjs.sourceforge.net/) and I was surprised of the simplicity
of the language definition.
So I have decided to use it on my blog. Hopefully dotclear engine provide a plugin api, and this was one of the reasons I have choose it.
Take some days to build an alpha version, then I see that the perl syntax that was broken with the previous plugin was still wrongly colorized !
Here is a screenshot :

You can see the 3thd regular expression is colorized to the end of the split args, I suspect that the $/
variable was interpolated into the regex in the case another /
close the expression before the end of the line.
I may take time to investigate 
Today, it is colorized as : (fixeme)
while(<PROJECT>){
if($_=~/^appname "([^"]+)";$/gi){ $appName = $1; }
if($_=~/applib "([^"]+)";$/gi){ $appLib = $1; }
if($_=~/LibList "([^"]+)";$/gi){ @libList = split(/;/,$1); }
if($_ eq "/LibList ('[^']+)';$/gi"){ @libList = split(/;/,$1); }
if($_=~/LibList \/!([^!]+)!;$/gi){ @libList = split(/;/,$1); }
if($_=~/LibList \/"([^"]+)";$/gi){ @libList = split(/;/,$1); }
if(qr/this is \/ a test /g or qr/blabla/){ return "test - " x 10 };
if(m/this is \/ a test /g or m/blabla/){ return "test - " x 10 };
if(s/this is \/ a / replace test /g or s/bla/bla/){ return "test - " x 10 };
}
For those who are interested on that SH system with DotClear 2, you can find my alpha plugin attached to this post.
Rate this entry
3.5/5
- Note: 3.5
- Votes: 2
- Higher: 4
- Lower: 3
Comments
I am already working on v1.1, here is the CHANGES file
Changes file
for SyntaxHighlightJS 1.0
a DotClear 2 plugin
===================
TODO / IN MIND
format of JS + CSS
- dynamically discover css available
- add missing full size / "human readable" (depending of human
- fixe perl coloration on regex with $ sign at end
- add small header on <pre> blocks allowing to act on :
- copy to clip board (original text without line number)
- line number (show/hide)
- word wrap / line break
- add a scroll to <pre> tag when too large
- dynamically change language (usefull for hacks)
1.1 - Add cookie to remember client prefered style
1.0 - ( alpha ) based on SHJS 0.6 2 - patches applyed,
adding powerbuilder language support
+ ide-pb style
+ virant-ink style
tomorrow v1.2
- some perl fixe, see http://sourceforge.net/tracker/?fun... )
- a new theme found at http://khopesh.com/blog/adam-katz-m...
working a bit on css styling of my dotclear theme and sh_style in order to have scrollbar on source code and hacking a bit around line numbering in sh_main.js; the plugin change source code tabs as 2 spaces for better. I want to work a bit more on *.css an *.js before to release the v1.3 (dynamically allow to copy, change line numbers and word-warping).
Seam to have problem with diamond operator
while(<STREAM>){ ... }
became
wile(){ ... }
Now, I have limited the max-height of the code block, and patched the line numbers margin size . I think I could pack next version now
The version 1.3 was released !
CHANGELOG
========
- tab chars are transformed in 2 spaces
- add line numbers (autosize line's margin)
- add an horizontal scrollbar
- copy to clip board (original text without line number )
- line number (show/hide)
- word wrap / line break
- fix a bug in javascript loader (Readcookie not ready)
- fix a bug with chars <, > and & in source code
- specify a max-height for <pre> tag (340px)
I just book marked your blog on Digg and StumbleUpon.I enjoy reading your commentaries.