Please support the GeSHi Filter for syntax highlighting module.

http://peterpetrik.com/blog/ckeditor-and-geshi-filter gives an example of how to do it but with CKeditor, but it uses the CKeditor module.

Comments

TwoD’s picture

Status: Active » Closed (won't fix)

Wysiwyg module provides a way to tell editors about native plugins via hook_wysiwyg_plugin and since the solution you linked to is implemented as such, this should be no problem. You'd basically follow the same steps as for ckeditor.module, but there is no need to modify the original CKEditor files (ckeditor.config.js). Instead you implement hook_wysiwyg_plugin and provide the information the editor needs there. It makes updating Wysiwyg, CKEditor, and the plugin a lot easier since they are kept separate.

For now, we only include plugins which are needed for compatibility with Drupal Core functionality in Wysiwyg module, so this is a "won't fix".
There is more info about implementing the hook in wysiwyg.api.php (Wysiwyg 6.x-2.x-dev version of the file is most up to date.)

Here's how to implement the hook:
Create sites/all/modules/wysiwyg_geshi/ and put a wysiwyg_geshi.info file in it, same as for all other Drupal modules.
Then create wysiwyg_geshi.module:

// wysiwyg_geshi.module
function wysiwyg_geshi_wysiwyg_plugin($editor, $version) {
  switch ($editor) {
    case 'ckeditor':
        return array(
          'geshi' => array(
            'url' => 'http://peterpetrik.com/blog/ckeditor-and-geshi-filter',
            'path' => drupal_get_path('module', 'wysiwyg_geshi') . '/ckeditor/',
            'buttons' => array(
              'Geshi-code' => t('Geshi-code'),
              'Geshi-php' => t('Geshi-php'),
              'Geshi-bash' => t('Geshi-bash'),
              'Geshi-html' => t('Geshi-html'),
              'Geshi-css' => t('Geshi-css'),
            ),
            'options' => array(
               'coreStyles_code' => array('element' => 'pre'),
               'coreStyles_php' => array('element' => 'pre', 'attributes' => array('language' => 'php')),
               'coreStyles_bash' => array('element' => 'pre', 'attributes' => array('language' => 'bash')),
               'coreStyles_html' => array('element' => 'pre', 'attributes' => array('language' => 'html4strict')),
               'coreStyles_css' => array('element' => 'pre', 'attributes' => array('language' => 'css')),
            ),
            'load' => TRUE,
          ),
        );
      break;
  }
}

Create sites/all/modules/wysiwyg_geshi/ckeditor and place the plugin.js file from the blog post in it.
Enable the wysiwyg_geshi module in your Drupal installation, then enable the Geshi buttons you need in admin/settings/wysiwyg/ for each editor profile.

Remember that you still need the geshifilter.module and the Geshi library. Wysiwyg module will not run any code when the rendered node is Viewed, the Geshi Filter module takes care of that part, and the Geshi library is of course the actual highlighting code it uses.

You will also need to add the CSS from the post (under "Toolbar button theme") to your theme's stylesheets and make the necessary modifications to geshifilter.module (under "GeSHi configuration"). It might actually be a good idea to file a feature request to geshifilter.module about adding that php code as an optional filter setting, then you'd not have to modify either module anymore.

Aren Cambre’s picture

Project: Wysiwyg » WYSIWYG - GeSHi bridge
Version: 6.x-2.x-dev »
Category: feature » task
Status: Closed (won't fix) » Active

Thanks for the detailed rundown. Moving to new project.

Aren Cambre’s picture

Assigned: Unassigned » Aren Cambre
Aren Cambre’s picture

[comment deleted]