Drupal 7.10 WYSIWYG with syntax highlighting

Does anyone have a confirmed/tested working way of setting up a rich WYSIWYG (like CKEditor or TinyMCE) with support for syntax highlighting (for pasting and sharing java/php/etc.) in Drupal 7.10 ?

I have now tried a variety of combinations, and I have struggled to get any of them to work in Drupal 7.10. Here is what I have tried:

  • CKEditor (3.6.2) using CKEditor module (7.x-1.6) with Syntax Highlighter library and Syntax Highlighter Module (7x-1.1). I followed betuts.com/guide-install-syntax-highlighter-ckeditorckeditor-syntax-highlighter-plugin-drupal-7.

    Problem : I could not get a code button into my CKEditor. I just would not appear no matter what I did - perhaps it has something to do with the new drag-and-drop method of adding buttons that has replaced the old text-based one.

  • CKEditor (3.6.2)with CKEditor module (7.x-1.6) GeSHi Filter (7x-1.0) module and GeSHi libarary following this guide peterpetrik.com/blog/ckeditor-and-geshi-filter.

    Problem : Same as above, I cannot seem to get the code button to appear in my CKEditor.

  • WYSIWYG module with CKEditor and Google Code Prettifier module + library.

    Problem : Although this solution is simple and works beautifully with no editor, I simply cannot find a good way of getting CKEditor (or any of the other RTEs) to stop HTML-escaping code inside <pre> tags.

  • I appreciate your help (this is my first post :-)!


    After some more work I got the following combination to work. I also did a more elaborated guide here.

  • Using WYSIWYG module with CKEditor library. I can insert my code into pre tags (using the Formatted style), and this should also be possible with most other RTEs you can use with the WYSIWYG module.
  • For the markup itself I installed the Prettify module with the Google Code Prettify library. This will syntax highlight any code within pre or code tags. BUT if you also enable the prettify filter, you will get unwanted html-escapes inside your tags. This is what caused me to think it was CKEditor who did the escapes as described in scenario 3 above.
  • So this is verified to work with Drupal 7.10, WYSIWYG 7-2.1, and Prettify 7-1.x-dev.


    Lars,

    We ran into similar issue on our site when posting to our own site and had to modify CKEditor plugin.

    Modified plugin code is posted on https://github.com/dbrain/ckeditor-syntaxhighlight/tree/ckeditor-4

    链接地址: http://www.djcxy.com/p/89988.html

    上一篇: 我如何从插件插入一个PHP代码到CKEditor中?

    下一篇: Drupal 7.10所见即所得的语法高亮显示