Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax Highlighting in Drupal

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.

like image 765
Vaibhav Jain Avatar asked Dec 05 '25 18:12

Vaibhav Jain


2 Answers

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!

like image 108
mac Avatar answered Dec 08 '25 22:12

mac


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

like image 25
user148908 Avatar answered Dec 08 '25 22:12

user148908



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!