TinyMCE + GeSHi filter compatibility

feelexit - June 12, 2008 - 20:11
Project:TinyMCE
Version:5.x-1.9-1
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

I have tinymce installed, i m wondering if theres a way we can get geshi hightlighter to work with tinymce

#1

soxofaan - June 13, 2008 - 08:53
Component:Code» User interface

I'm not familiar with tinymce, I will have to look into this.

What do you actually mean with "work with"?
Are there currently any conflicts or something?
Or do you want real time syntax highlighting in the tinymce text field?

#2

sibidiba - June 22, 2008 - 04:22
Version:5.x-2.8» 6.x-1.1
Category:support request» bug report

it is impossible to enter source code into the editor, because all special characters includeing < and > in the beginning tag get translated by the editor

#3

soxofaan - June 22, 2008 - 13:05
Title:can we make geshi work with tinymce» TinyMCE + GeSHi filter compatibility
Project:GeSHi Filter for syntax highlighting» TinyMCE
Version:6.x-1.1» 5.x-1.9-1
Category:bug report» support request
Status:active» won't fix

I just tried TinyMCE a bit and it indeed changes the special characters like "<" and ">" to "&lt;" and "&gt;".

I don't think this should be fixed/decoded again in GeSHi filter, doing so seems like opening can of worms to me (considering all the other options of WYSIWYG and non-WYSIWYG input modes around).
For example: since the TinyMCE editor can be made optional, you never know if a "&lt;" in the GeSHi filter input was intended as "&lt;" or as "<" by the writer.

This issue should be fixed in the TinyMCE editor itself, maybe as a sort of plugin or something, but I'm not familiar enough with TinyMCE to provide more insights :)

#4

soxofaan - June 22, 2008 - 13:08
Status:won't fix» active

(sorry, the "won't fix" was not necessary)

#5

elk-x - October 6, 2008 - 14:33

Any news or tutorials on this topic? Would love to get Code input working with a WYSIWYG editor

#6

eagereyes - November 17, 2008 - 01:03
Category:support request» feature request

I have the same problem. I just spent almost an hour looking for a tinymce plugin that uses GeShi or something similar. Most projects are dead or only seem to exist as rumors. One works, but inserts a textarea and doesn't seem to produce any highlighting for python.

So here is a suggestion: I know you're not interested in writing a tinyMCE plugin (though it would be great to do that using Ajax and GeShi, rather than the hacked-together solution I linked to above). But what about making geshi-node into a CCK field that can be added easily to any node? That would solve the GUI editor problem (at least largely), and would be more useful and flexible than geshi-node.

#7

eagereyes - November 17, 2008 - 01:48

Actually, what I describe above can be done to an extent by adding a nodereference field to your favorite content type and then selecting "full node" for display of that field in full node display. This essentially attaches the entire node, including title, submitted-by, etc. It's not too bad, but a proper field would certainly be a better solution.

#8

soxofaan - November 17, 2008 - 08:19

#6: There is a patch for a GeSHi CCK field here: #179097: Geshi Source Code CCK Field
I'd like it to have more testers before committing it, so be welcome to try it out.

#9

eagereyes - November 17, 2008 - 15:25

Great, thanks for the pointer! Though it doesn't seem to be compatible with 6.6 (see my note in the other thread).

#10

jakephot - March 1, 2009 - 20:42

Hi. I finally found a simple way to deal with the < and > problem.
Just add a few lines into geshi.php at around line 2016.

// Replace all newlines to a common form.
$code = str_replace("\r\n", "\n", $this->source);
$code = str_replace("\r", "\n", $code);

after this, add the following (take out the space between & and gt, lt

$code = str_replace("& gt;", ">", $code);
$code = str_replace("& lt;", "<", $code);

I'm using Drupal 6 and it worked as I intended.

#11

Bobby1290 - March 2, 2009 - 20:56

Thanks!

Another option using drupal 6 is the one I use;

- set the wysiwyg profile->cleanup and output to ONLY "Convert <font> tags to styles"

- use the brackets instead of the < / > signs for the geshi filter.
(ie. [code] instead of <code> )

I can just add the code to a tiny controlled area by using the html button.

And the formatting persists when saving multiple times.

#12

richardathome - April 5, 2009 - 12:48

It's also worth adding:

$code = str_replace("& amp;", "&", $code);

in the same place too.

Thanks for the tip :-)

 
 

Drupal is a registered trademark of Dries Buytaert.