WYSIWYG + CKEditor + GeSHI Filter syntax highlighting
By Emily Newsom
One of our goals for our new Drupal 7 site launch was to have a better blog section where we could discuss a few of the solutions we come up with to the everyday problems we encounter. For me, that means I need a good way to display formatted code to readers. Enter the GeSHI Filter. This module looked great and did what I wanted. Problem is, the wysiwyg editor, in my case CKEditor, butchered my text in such a way that by the time it got to GeSHI, the output was broken (a wysiwyg butchering something? surprise surprise!).
The solution I came up with was to simply use <pre> and </pre> to surround my code. CKEditor already knows about <pre>, so there was no hacking necessary to get it to leave the formatting alone. Even better, I could just highlight my code in CKEditor and select the "Formatted" paragraph format without typing any tags.
The last step was to get <pre> working with GeSHI Filter. Simply go to your GeSHI Filter options and add "pre" to the list of "generic syntax highlighting tags". You can select a default language if you aren't using <pre> for anything other than code formatting, or when you enter your code, you can quickly disable rich-text and add "language='php'" (css, c, etc) to your pre tag.
Not quite ready to take the plunge?
Subscribe if you're looking for help but aren't quite ready. We'll keep you informed of our availability and special promotions.