Getting GeSHi Filter Working on CKEditor (using Wysiwyg)

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Obliwion's picture

I have searched around for this, and have tried multiple approaches. I have enabled and disabled, installed, removed and reinstalled modules, but I can't get this to work. I'm probably missing something minor, so I'm going to try the community option now.

Currently I have the following (relevant) modules installed: GeSHi field, GeSHi filter, GeSHi node, WYSIWYG, IMCE Wysiwyg API bridge, Wysiwyg, CKEditor. All of them are in site/all/modules, except for CKEditor, which only worked with wysiwyg if I put it inside libraries.

When I go to Administer > Site configuration > GeSHi Filter, it says the library is installed and all seems to be looking fine.
When I go to Administer > Site configuration > Wysiwyg, it says that CKEditor is installed and when opening "filtered HTML" (or full html or php code), I can see and enable the buttons: IMCE, Geshi-code, Geshi-php, Geshi-bas, Geshi-html and Geshi-css. I have all these enabled!

However, when I go to Content management > create content > blog entry (or something else), I can't see buttons for php, code, html or css. I don't see an IMCE button either, but it is working when I click the image button, so that's fine.

I've also tried Disabling rich-text and typing code or php-code, but neither are displayed in the blog entry when I submit it. Anyone out there that experienced similar problems and that can help me?

I'll be happy to answer more questions about this!
Thanks!

Comments

duplicate

ClearXS's picture

duplicate

Wysiwyg, CKEditor...

ClearXS's picture

I'm just a starter and came along this page because I have to install CKEditor TWO times at different places, what seems incorrect to me; it's in:
.../sites/all/modules/ckeditor/ckeditor/ckeditor.js
and now according to mysite/admin/settings/wysiwyg , I have to install it a second time in:
.../sites/all/libraries/ckeditor/ckeditor.js
Nice that developers suddenly decide applications should go in libraries, but what about the transition period..?
Luckely the readme.txt states:

Alternative directory can be sites/all/libraries/ckeditor, module automatically recognize proper path to editor. Libraries directory is default path when drush is used to download editor javascript.
The correct directory structure is as follows:

I'll move the /ckeditor/ckeditor subdir to /libraries/ckeditor and then it should work => NO; ofcourse wysiwyg recognizes, but my normal CKEditor is not working anymore on my articles and comments pages. And when I start editing an old article => redirect loop and for a moment the database unworkable on main page. Unvinked CKEditor module and deleted module. updat.php Redirect loop remains on editing. Installed Panels first + vinked - update.php. Then CKEditor module - update.php + cron.php + admin/content/node-settings/rebuild => NO, editor not working in article.

=> So installed two times the same ckeditor.js etc. => not working either anymore; what a hughe progress... UPDATE: Had to fill in the CKEditor again under: admin/settings/wysiwyg => works again (& the redirect loop on editing existing articles has to do with some of the url enhancing programs). But on renaming the modules/ckeditor/ckeditor dir, the editor stops working and can't find the libraries/ckeditor dir.

Are you trying to use both

brianmercer's picture

Are you trying to use both the CKEditor drupal module and the WYSIWYG drupal module at the same time? That should not be necessary and could cause problems. You probably need to choose one or the other.

You need both

Obliwion's picture

You need both, as in wysiwyg, you have to ADD an editor before it does anything. The only reason I installed WYSIWYG though, is to get GeSHi working - which isn't looking to promising. I could try Peter Petrik's solution again, but that didn't work either... . Starting to get pretty desperate. Especially since the intention of my site was to share code... .

Wysiwyg specs + CKEditor tric

ClearXS's picture

http://drupal.org/project/wysiwyg

Supported editors/plugins
* Editors: CKEditor, FCKeditor, jWysiwyg, markItUp, NicEdit, openWYSIWYG, TinyMCE, Whizzywig, WYMeditor, YUI editor.
* Plugins: Teaser break, Image Assist, IMCE (via IMCE Wysiwyg bridge)

And don't forget to read this page: WYSIWYG module (& compatibility)

All we probably need is more time (sometimes just stop and continue later), more reading and more trial and error... I'm now over 3 years with Drupal and finally getting near the site I wanted to build. Earlier the modules were not there, malfunctioning, or very slow and my skills and available time not sufficient.

These seam to be new complex integrated features and then there is the trial and error period almost by definition. Sometimes studying and trying, a way can be found around something. If not, it makes sense to report offically at the modules pages and wait for a module update that contains the new or repaired feature.

Anyway I progressed a little in my problem:
In admin/settings/ckeditor/editg (global profile CKEditor), I could specify the path where CKEditor can be found. Yes, it's a minor modules error that it doesn't look in the new libraries dir automatically, as it states that it should do. Here it states the contrary: that it does not, unless specified differently here. => deleted the modules/ckeditor/ckeditor subdir & CKEditor keeps working!

I don't understand what you are replying to...

Obliwion's picture

but I'm using the WYSIWYG GeSHi bride http://drupal.org/project/wysiwyg-geshi, which is obviously a supported plugin

Modules aren't working always

ClearXS's picture

Modules aren't working always under the many different cirumstances as they should and new releases to fix problems are neccessary, especially if you're going for a complex integration like:

Currently I have the following (relevant) modules installed: GeSHi field, GeSHi filter, GeSHi node, WYSIWYG, IMCE Wysiwyg API bridge, Wysiwyg, CKEditor. All of them are in site/all/modules, except for CKEditor, which only worked with wysiwyg if I put it inside libraries.

That WYSIWYG and CKEditor we have in common and errors can come from them + we are both trying to get different editing modules working together. Actually I will going to install the other modules you've mentioned too.

Furthermore I've Emfield to WYSIWYG. But the strange thing is that Anonymous users (another non-logged-in browser of mine) can use the CKEditor and dont have the embedded media fields, WHILE I AS ADMIN don't have the CKEditor, java jQuery doesnt seem to work (only on creating article) but do have the emfields. In all the settings I could find, I've put them all to Anonymous and Authenticated and Admin.

Then when I disable the CKEditor module, the Anonymous gets a WYSIWYG version of CKEditor (different colors) while still not having emfields, but nothing changes for me as Admin (no CKEditor and no emfields).

I'm just saying that you

brianmercer's picture

I'm just saying that you don't want to install both drupal modules i.e. http://drupal.org/project/wysiwyg and http://drupal.org/project/ckeditor, since they'll probably conflict. You do have to install the ckeditor code separately with whichever drupal module you use.

I took a look and for geshi integration into http://drupal.org/project/ckeditor there is a blog post at http://peterpetrik.com/blog/ckeditor-and-geshi-filter.

For integration with http://drupal.org/project/wysiwyg there is a project started at http://drupal.org/project/wysiwyg-geshi which is based on Mr. Petrik's post, but doesn't look fully baked as yet.

I tried going the wysiwyg +

brianmercer's picture

I tried going the wysiwyg + wysiwyg-geshi route since I use the wysiwyg module with ckeditor and not the ckeditor module.

It didn't work.

The wysiwyg-geshi module doesn't even have an alpha release atm, so it's far from an approved and supported module.

Well it sorta works:

brianmercer's picture

Well it sorta works. I've lost the bounding box, but the syntax highlighting is there, so it's pretty close.

Quick question for you guys.

brianmercer's picture

Quick question for you guys. Have you gone to https://test.brianmercer.com/admin/settings/filters and configure for the filter you're using and checked off the Geshi filter box?

Yes, I have.

Obliwion's picture

Yes, I have.

Saw your comment on my blog.

Slovak's picture

Saw your comment on my blog. The solution outlined there does NOT utilize the Wysiwyg module. I have found across many implementations that a straight CKeditor install with the Better Formats module offers more flexibility as well as ease of maintenance.

Ok, so HOW did you do that? I

Obliwion's picture

Ok, so HOW did you do that? I don't care about the bounding box. I guess I can add it in CSS anyway.

OK, lets try to get these

brianmercer's picture

OK, lets try to get these steps straight:

  1. install and enable these modules: wysiwyg, geshifilter, wysiwyg-geshi.
  2. download the ckeditor code to sites/libraries/ckeditor
  3. download and install the geshi code to sites/libraries/geshi
  4. go to admin/settings/geshifilter and change "Path to GeSHi library:" to sites/libraries/geshi
  5. go to admin/settings/geshifilter and change "Generic syntax highlighting tags:" to "code blockcode pre"
  6. hack sites/libraries/geshi/geshi.php to add the following below line 2046:
    // Replace all newlines to a common form.
    $code = str_replace(">", ">", $code);
    $code = str_replace("&lt;", "<", $code);
    $code = str_replace("&amp;", "&", $code);
    $code = str_replace("&#39;", "'", $code);
    $code = str_replace("&quot;", "\"", $code);
  7. go to admin/settings/filters and choose an input format to enable for code or create a new one.
  8. configure your chosen format and enable the Geshi filter by checking the checkbox.
  9. go to admin/settings/wysiwyg and next to your chosen input filter select ckeditor and save.
  10. stay at admin/settings/wysiwyg and click edit next to your chosen filter
  11. go to buttons and plugins and check off the "geshi" buttons at the bottom. Note that you will also have to enable all the other buttons you want as well. save.
  12. create a new node. select the input filter you chose. paste in some php code. select the code and then press the php button.

Other things that might cause problems:
1. If you have other filters enabled for your chosen input filter like htmlawed you might have to whitelist pre.

I think that's everything I did to get it working.

It looks like it's working

brianmercer's picture

It looks like it's working now. http://test.brianmercer.com/content/test-wysiwyg-and-geshi

Obliwion got his working also. The geshifilter module must have been flaky because a disable, uninstall, and re-enable of the geshifilter module solved the problem.

Glad to hear you got it

Slovak's picture

Glad to hear you got it working. I am puzzled as to why people depend on the WYSIWYG module when only using one editor. Using CKeditor directly allows for more toolbar customizations as well as better fine tuning for each role involved, especially when combined with the Better Formats module.

^^^ The above is curiosity, not criticism. I'd really like to see a use case scenario. ^^^

Better formats works fine

brianmercer's picture

Better formats works fine with WYSIWYG.

I believe that one of the goals of the WYSIWYG API module is make it easier to create helper modules that can be used with multiple editors, so the module work has wider application across the community, even if each individual member only uses a single editor.

The WYSIWYG-Geshi module is easier to install than following your instructions. Even if it is just a modulization of your work. Thanks. :)

That is indeed the reason I

Obliwion's picture

That is indeed the reason I installed wysiwyg. I tried Peter' solution first, but ran into a wide range of problems. Most of the times I couldn't see CKeditor any longer. After that I found out that somebody had made a module that could do all that for me... having just started playing around with Drupal, I obviously took that route. At this point it's as much about getting a functional website online, as learning about Drupal. A big thank you to both Peter and Brian though, without who I would've never have gotten this working.

OK, I admit it is a trade off

Slovak's picture

OK, I admit it is a trade off between ease of implementation and usability against finer control with more complexity.

Looks like Better Formats

Aren Cambre's picture

Looks like Better Formats only works with an entire field at a time? A goal of the GeSHi-WYSIWYG bridge module is to allow inline code pieces within any field and not require an entire field to be code.

Am I mistaken?

Wysiwyg

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week