views:

386

answers:

4

Which is the best module for Syntax Highligting in Drupal. I am using GeSHi for syntax highlighting my code. It was working fine then I installed a second module FCKeditor. Now GeSHi filter is not working with FCKeditor. Do anyone have any idea why these modules are not working together.

Thanks in advance.

+1  A: 

My suggestion for a code highlighter on a Drupal site would be a purely client side one, one that doesn't involve any hooks and any potential namespace conflicts.

The one I've the most luck with in various environments (but never tried alongside FCKEditor) is google-code-prettify. If it doesn't work alongside FCKEditor you may want to have a look at the comments on getting it working with Wordpress since I think some of those problems may be related to FCKEditor.

Bell
Hmm, it's CKEditor now.
TTT
+2  A: 

There is a rather complete answer in this post.

The post gives you some more details, but in essence is a matter of adding to the fckeditor.config.js file the following line:

FCKConfig.ProtectedSource.Add( /<blockcode language[\s\S]*?<\/blockcode>/gi  );

which essentially tells FCKeditor to leave the blockcode with syntax highlighting alone.

You can find some more details on the compatibility issues by visiting the FCKeditor module issue page, filtered for geshi.

Hope this helps!

mac
Thanks, but adding this line does'nt work for me. I have to add code for specific language. http://www.techpint.com/programming/syntax-highlighting-using-geshi-filter-and-fckeditor-drupal
vaibhav
+2  A: 

If I were you, I would switch to using the WYSIWYG module with TinyMCE amd use the Syntax Highlighter module for the syntax highlighting.

Follow these instructions for integrating the SyntaxHighlighter with TinyMCE - you can get a button that gives you a popup window from where you can select the language (php, MySQL, Bash etc etc) and enter your code.

You should probably also install my wysiwyg_preelementfix module, which ensures that characters are not escaped or double-escaped.

That is what I do on the KirkDesigns blog and it seems to work pretty well.

Failing that, I also wrote some instructions for using Geshi and FCKEditor together in Drupal

Point Noted Thanks.
vaibhav
A: 

I've documented my solution using GeSHi syntax filter at http://peterpetrik.com/blog/ckeditor-and-geshi-filter

Peter