Syntax Highlighting in Drupal

2.5k views Asked by At

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.

3

There are 3 answers

1
mac On BEST ANSWER

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!

0
Bell On

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.

0
user148908 On

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