I read a lot about problems where ckeditor removes geshi tags.
The solution to stop that is adding this to the config.js in the root folder of ckeditor

 // do not touch code inside of <foo></foo> and [foo] [/foo]
   config.protectedSource.push( %\[.*\].*\[/.*\]%i );
   config.protectedSource.push( %\<.*\>.*\</.*\>%i );

That works and the correct geshi highlighting is applied.

Somehow there is another problem left. If you switch from source view to normal view. It will kill all formatting of tha code. Example code

/**
 * @file
 * Integrates client-side editors with Drupal.
 */

/**
 * Implements hook_entity_info().
 */
function wysiwyg_entity_info() {
  $types['wysiwyg_profile'] = array(
    'label' => t('Wysiwyg profile'),
    'base table' => 'wysiwyg',
    'controller class' => 'WysiwygProfileController',
    'fieldable' => FALSE,
    // When loading all entities, DrupalDefaultEntityController::load() ignores
    // its static cache. Therefore, wysiwyg_profile_load_all() implements a
    // custom static cache.
    'static cache' => FALSE,
    'entity keys' => array(
      'id' => 'format',
    ),
  );
  return $types;
}

will become:

/** * Implements hook_entity_info(). */ function wysiwyg_entity_info() { $types['wysiwyg_profile'] = array( 'label' =&gt; t('Wysiwyg profile'), 'base table' =&gt; 'wysiwyg', 'controller class' =&gt; 'WysiwygProfileController', 'fieldable' =&gt; FALSE, // When loading all entities, DrupalDefaultEntityController::load() ignores // its static cache. Therefore, wysiwyg_profile_load_all() implements a // custom static cache. 'static cache' =&gt; FALSE, 'entity keys' =&gt; array( 'id' =&gt; 'format', ), ); return $types; } 

so it seems the protected source config tag works not for the formatting options so i think it is neccessary to use: http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Output_Formatting

as of another post it seems that the ckeditor-3.0.js needs to be hacked to prevent the reformatting between the geshi tags (only guessing)

opinions? i will post the solution if i find one.

Comments

marcoka’s picture

following is on

[x] Apply source formatting (if not it complete removes every \r \t and all formatting is completely gone)
[x] Verify HTML
[x] Convert tags to styles
[x] Force cleanup on standard paste

rest is off

twod’s picture

Have you tried Wysiwyg GeSHi bridge?
I know it only has a D6 release but you should only need to change the version info in the .info file to make it work for D7 since it's just an implementation of our plugin hook.

marcoka’s picture

not yet. i will check that out and post if i succeed. thx

marcoka’s picture

geshi bridge will not solve this. if i understand it correctly it only enables buttons in the toolbar.
(i can not belive that the protected source tag actually does NOT protect the formatting).

maybe someone will answer for my topic in the ckeditor forum:
http://cksource.com/forums/viewtopic.php?f=11&t=22744

twod’s picture

The buttons provided by the GeSHi plugin for CKEditor applies a "style" to the current selection (or around just the caret), wrapping it in <pre language="php"></pre> tags.
The pre tags should keep the source from being mangled in the editor, and the GeSHi filter module should be able to find those pre tags and apply the proper highlighting during rendering.
The changes descriped on the plugin's project page may be needed if the editor turns < into &lt; etc.

Note that by default Wysiwyg module does not load CKEditor's config.js file since we like to avoid having to modify a library's files.

marcoka’s picture

oh. so my:

config.protectedSource.push( %\[.*\].*\[/.*\]%i );

is not beeing used because i added it to the stdandard config.js?

twod’s picture

Exactly. You'll need to set the customConfig setting to make it load if you need it. Just remember that the settings sent directly to the editor instance when it is created will override any corresponding setting from the config file (which is why Wysiwyg doesn't need it).

function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
  if ($context['profile']->editor == 'ckeditor') {
    $settings['customConfig'] = wysiwyg_get_path('ckeditor', TRUE) . '/config.js'; // Might need tweaks like param 2 = FALSE
  }
}
marcoka’s picture

ah ok so use the wysiwyg hook to make "own" ckeditor settings/config. thx i will try that

marcoka’s picture

Issue tags: +ckeditor, +syntax highlight, +geshi

all this protected stuff is all not working and you will waste a lot of time searching and finding a lot of discussions. non of them worked for me. even in the ckeditor forum, no reply.

BUT i found a way:

just use pre tags not [php] or [[php]]. the geshi authors are great giving such felxibility.

the following works and ckeditor will not fuck up the source code. yey!

<pre class="php"> 
if ( !function_exists('version_compare') || version_compare( phpversion(), '5', '&lt;' ) )
	include_once( 'ckeditor_php4.php' ) ;
else
	include_once( 'ckeditor_php5.php' ) ;
</pre>

everything inside the pre tags will now be highlighted and the formatting will be preseverd if you edit with ckeditor.

sun’s picture

Status: Active » Closed (fixed)

Not sure what the actual resolution in #9 is, but removing the bloat of invalid issue tags.

drupalfan81’s picture

What the guy in #9 is saying is that if you use the

 tags that it will not modify the layout of your code. But there is one more thing you need to make sure is disabled in the CKeditor advanced settings to ensure that < or > signs remain < and >. That is to disable HTML entities. Hope this helps!